From 8572d6adf04d397505770b0b0d5cfd91cf6a92a8 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 8 Jul 2002 02:26:47 +0000 Subject: Major updates in preparation for 3.80. New version of the manual, put into the doc subdir. Enhancements: $(eval ...) and $(value ...) functions, various bug fixes, etc. See the ChangeLog. More to come. --- ChangeLog | 6733 +-------------------- ChangeLog.2 | 6648 +++++++++++++++++++++ Makefile.am | 14 +- NEWS | 18 +- README.cvs | 17 +- configure.in | 9 +- dep.h | 1 + doc/Makefile.am | 29 + doc/make.texi | 10141 ++++++++++++++++++++++++++++++++ function.c | 40 +- gpl.texinfo | 396 -- implicit.c | 13 +- main.c | 47 +- maintMakefile | 102 + make-stds.texi | 916 --- make.h | 4 +- make.texinfo | 9955 ------------------------------- misc.c | 10 +- read.c | 1318 +++-- remake.c | 23 +- tests/ChangeLog | 6 + tests/scripts/functions/eval | 60 + tests/scripts/functions/value | 30 + tests/scripts/variables/MAKEFILE_LIST | 30 + tests/scripts/variables/flavors | 17 + variable.c | 316 +- variable.h | 17 +- 27 files changed, 18219 insertions(+), 18691 deletions(-) create mode 100644 ChangeLog.2 create mode 100644 doc/Makefile.am create mode 100644 doc/make.texi delete mode 100755 gpl.texinfo delete mode 100644 make-stds.texi delete mode 100644 make.texinfo create mode 100644 tests/scripts/functions/eval create mode 100644 tests/scripts/functions/value create mode 100644 tests/scripts/variables/MAKEFILE_LIST diff --git a/ChangeLog b/ChangeLog index 32b4813..2e22c52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,88 @@ +2002-07-07 Paul D. Smith + + * variable.c (do_variable_definition) [W32]: On W32 using cmd + rather than a shell you get an exception. Make sure we look up + the variable. Patch provided by Eli Zaretskii . + + * remake.c (notice_finished_file): Fix handling of -t flag. + Patch provided by Henning Makholm . + + * implicit.c (pattern_search): Some systems apparently run short + of stack space, and using alloca() in this function caused an + overrun. I modified it to use xmalloc() on the two variables + which seemed like they might get large. Bug #476. + + * main.c (print_version): Update copyright notice to conform with + GNU standards. + (print_usage): Update help output. + + * function.c (func_eval): Create a new make function, $(eval + ...). Expand the arguments, put them into a buffer, then invoke + eval_buffer() on the resulting string. + (func_quote): Create a new function, $(quote VARNAME). Inserts + the value of the variable VARNAME without expanding it any + further. + + * read.c (struct ebuffer): Change the linebuffer structure to an + "eval buffer", which can be either a file or a buffer. + (eval_makefile): Move the code in the old read_makefile() which + located a makefile into here: create a struct ebuffer with that + information. Have it invoke the new function eval() with that + ebuffer. + (eval_buffer): Create a new function that creates a struct ebuffer + that holds a string buffer instead of a file. Have it invoke + eval() with that ebuffer. + (eval): New function that contains the guts of the old + read_makefile() function: this function parses makefiles. Obtains + data to parse from the provided ebuffer. Some modifications to + make the flow of the function cleaner and clearer. Still could + use some work here... + (do_define): Takes a struct ebuffer instead of a FILE*. Read the + contents of the define/endef variable from the ebuffer. + (readstring): Read the next line from a string-style ebuffer. + (readline): Read the next line from an ebuffer. If it's a string + ebuffer, invoke readstring(). If it's a FILE* ebuffer, read it + from the file. + + * dep.h (eval_buffer): Prototype eval_buffer(); + + * variable.c (do_variable_definition): Make sure that all + non-target-specific variables are registered in the global set. + If we're invoked from an $(eval ...) we might be inside a $(call + ...) or other function which has pushed a variable scope; we still + want to define our variables from evaluated makefile code in the + global scope. + +2002-06-18 Paul D. Smith + + * make.texinfo: Updates for next revision. New date/rev/etc. + Recreate all Info menus. Change license on the manual to the GNU + Free Documentation License. A number of typos. + (Variables Simplify): Don't use "-" before it's defined. + (Automatic Prerequisites): Rewrite the target example to work + properly if the compile fails. Remove incorrect comments about + how "set -e" behaves. + (Text Functions): Move the "word", "wordlist", "words", and + "firstword" functions here, from "File Name Functions". + * make-stds.texi: Update from latest GNU version. + * fdl.texi: (created) Import the latest GNU version. + +2002-06-06 Paul D. Smith + + * variable.c (do_variable_definition): New function: extract the + part of try_variable_definition() that actually sets the value + into a separate function. + (try_variable_definition): Call do_variable_definition() after + parsing the variable definition string. + (define_variable_in_set): Make the name argument const. + + * variable.h (enum variable_flavor): Make public. + (do_variable_definition): Create prototype. + + * read.c (read_all_makefiles): Create a new built-in variable, + MAKEFILE_LIST. + (read_makefile): Add each makefile read in to this variable value. + 2002-05-09 Paul D. Smith * file.c (file_timestamp_now): Use K&R function declaration. @@ -398,6651 +483,5 @@ * make.texinfo, NEWS, TODO.private: Minor spelling corrections. Ran spell-check on make.texinfo. -2000-06-23 Paul D. Smith - - * main.c (main): Replace EXIT_SUCCESS, EXIT_FAILURE, and - EXIT_TROUBLE with MAKE_SUCCESS, MAKE_FAILURE, and MAKE_TROUBLE. - * make.h: Define these macros. - - * Version 3.79.1 released. - - * configure.in: Add a new option, --disable-nsec-timestamps, to - avoid using sub-second timestamps on systems that support it. It - can lead to problems, e.g. if your makefile relies on "cp -p". - * README.template: Document the issue with "cp -p". - - * config.guess, config.sub: Updated. - -2000-06-22 Paul D. Smith - - * job.c (start_job_command): Increment commands_started before the - special check for ":" (empty command) to avoid spurious "is up to - date" messages. Also move the test for question_flag after we - expand arguments, and only stop if the expansion provided an - actual command to run, not just whitespace. This fixes PR/1780. - -2000-06-21 Paul D. Smith - - * read.c (read_makefile): If we find a semicolon in the target - definition, remember where it was. If the line turns out to be a - target-specific variable, add back the semicolon and everything - after it. Fixes PR/1709. - -2000-06-19 Paul D. Smith - - * config.h-vms.template: #define uintmax_t for this system. - * config.ami.template: Ditto. - * config.h.W32.template: Ditto. - - * configure.in: We don't use select(2) anymore, so don't bother - checking for it. - * acconfig.h: Ditto. - * acinclude.m4: Ditto. - - * file.c (all_secondary): New static global; if 1 it means - .SECONDARY with no prerequisites was seen in the makefile. - (snap_deps): Set it appropriately. - (remove_intermediates): Check it. - (num_intermediates): Remove this global, it's not used anywhere. - (considered): Move this to remake.c and make it static. - - * NEWS: Document the change to .SECONDARY. - * make.texinfo (Special Targets): Document the change to .SECONDARY. - - * implicit.c (pattern_search): Remove the increment of - num_intermediates; it's not used. - * filedef.h: Remove num_intermediates and considered. - - * function.c (handle_function): If the last argument was empty, we - were pretending it didn't exist rather than providing an empty - value. Keep looking until we're past the end, not just at the end. - - * implicit.c (pattern_search): Multi-target implicit rules weren't - expanding the "also made" targets correctly if the pattern didn't - contain a slash but the target did; in that case the directory - part wasn't being added back to the stem on the "also made" - targets. Reported by Seth M LaForge , with - a patch. - -2000-06-17 Eli Zaretskii - - * Makefile.DOS.template (DESTDIR, bindir, datadir, libdir) - (infodir, mandir, includedir): Support installation under a - non-default DESTDIR. - - * remake.c (f_mtime): Fix the spelling of __MSDOS__. - - * configh.DOS.template (HAVE_FDOPEN, HAVE_MKSTEMP): Define. - -2000-06-14 Paul D. Smith - - * acinclude.m4 (pds_WITH_GETTEXT): rewrite fp_WITH_GETTEXT and - rename it to avoid confusion. This version is very specific: it - won't accept any gettext that isn't GNU. If the user doesn't - explicitly ask for the included gettext, we look to see if the - system gettext is GNU (testing both the actual libintl library, - and the libintl.h header file). Only if the system gettext is - really GNU gettext will we allow it to be used. - (pds_CHECK_SYSTEM_GETTEXT): A helper function. - -2000-06-13 Paul D. Smith - - * gettext.h: If we have libintl.h, use that instead of any of the - contents of gettext.h. We won't check for libintl.h unless we're - using the system gettext. - - * function.c (func_word): Clarify error message. - -2000-06-10 Paul Eggert - - Support nanosecond resolution on hosts with 64-bit time_t and - uintmax_t (e.g. 64-bit Sparc Solaris), by splitting - FILE_TIMESTAMP into a 30-bit part for nanoseconds, with the - rest for seconds, if FILE_TIMESTAMP is at least 64 bits wide. - - * make.h: Always define FILE_TIMESTAMP to be uintmax_t, for - simplicity. - - * filedef.h (FILE_TIMESTAMP_HI_RES, FILE_TIMESTAMP_LO_BITS) - (UNKNOWN_MTIME, NONEXISTENT_MTIME, OLD_MTIME) - (ORDINARY_MTIME_MIN, ORDINARY_MTIME_MAX): New macros. - (FILE_TIMESTAMP_STAT_MODTIME): Now takes fname arg. All uses changed. - (FILE_TIMESTAMP_DIV, FILE_TIMESTAMP_MOD) - (FILE_TIMESTAMP_FROM_S_AND_NS): Remove. - (FILE_TIMESTAMP_S, FILE_TIMESTAMP_NS): Use shifts instead of - multiplication and division. Offset the timestamps by - ORDINARY_MTIME_MIN. - (file_timestamp_cons): New decl. - (NEW_MTIME): Now just the maximal timestamp value, as we no longer use - -1 to refer to nonexistent files. - - * file.c (snap_deps, print_file): Use NONEXISTENT_MTIME, - UNKNOWN_MTIME, and OLD_MTIME instead of magic constants. - * filedef.h (file_mtime_1): Likewise. - * main.c (main): Likewise. - * remake.c (update_file_1, notice_finished_file, check_dep) - (f_mtime, name_mtime, library_search): Likewise. - * vpath.c (selective_vpath_search): Likewise. - - * remake.c (f_mtime): Do not assume that (time_t) -1 equals - NONEXISTENT_MTIME. When futzing with time stamps, adjust by - multiples of 2**30, not 10**9. Do not calculate timestamp - adjustments on DOS unless they are needed. - - * commands.c (delete_target): Do not assume that - FILE_TIMESTAMP_S yields -1 for a nonexistent file, as that is - no longer true with the new representation. - - * file.c (file_timestamp_cons): New function, replacing - FILE_TIMESTAMP_FROM_S_AND_NS. All uses changed. - (file_timestamp_now): Use FILE_TIMESTAMP_HI_RES instead of 1 < - FILE_TIMESTAMPS_PER_S to determine whether we're using hi-res - timestamps. - (print_file): Print OLD_MTIME values as "very old" instead of - as a timestamp. - -2000-05-31 Paul Eggert - - * remake.c (name_mtime): Check for stat failures. Retry if EINTR. - -2000-05-24 Paul D. Smith - - * main.c (decode_switches): The "positive_int" switch uses atoi() - which succeeds for any input, and doesn't notice if extra, - non-digit text is after the number. This causes make to mis-parse - command lines like "make -j 5foo" as "make -j5" (ignoring "foo" - completely) instead of "make -j0 5foo" (where "5foo" is a - target). Fix this by checking the value by hand. We could use - strtol() if we were sure of having it; this is the only - questionable use of atoi() I found so we'll just stick with that. - Fixes PR/1716. - - * i18n/ja.po, i18n/nl.po, i18n/pt_BR.po: New translation files. - * configure.in (ALL_LINGUAS): Added pt_BR. - -2000-05-22 Paul Eggert - - * remake.c (f_mtime): Fix bug when handling future odd - timestamps in the WINDOWS32 case. Do not bother initializing - static var to zero. Simplify code that works around WINDOWS32 - and __MSDOS__ time skew brain damage. - -2000-05-22 Paul Eggert - - * job.c: Don't include time.h, as make.h already does this. - -2000-05-22 Paul Eggert - - * configure.in (AC_CHECK_HEADERS): Add sys/time.h. - (AC_HEADER_TIME): Add. - (clock_gettime): Prefer -lrt to -lposix4, for Solaris 7. - (gettimeofday): Add check for standard version of gettimeofday. - This merges changes written by Paul D. Smith. - - * file.c (file_timestamp_now): Use gettimeofday if available - and if clock_gettime does not work. Don't bother with - high-resolution clocks if file timestamps have only one-second - resolution. - - * make.h : Include, conditionally on the usual - TIME_WITH_SYS_TIME and HAVE_SYS_TIME_H macros. This is needed - for gettimeofday. - -2000-05-20 Paul D. Smith - - * read.c (read_makefile): We weren't keeping makefile names around - unless there was a rule defined in them; but now we need to keep - them for variables as well. Forget trying to be fancy: just keep - every makefile name we successfully open. - - * remote-cstms.c (start_remote_job_p): Change DB_EXTRA (?) to DB_JOBS. - -2000-05-17 Paul Eggert - - * commands.c (chop_commands): Ensure ctype macro args are nonnegative. - * expand.c (variable_expand_string): Likewise. - * function.c (subst_expand, lookup_function, msdos_openpipe): - Likewise. - * job.c (vms_redirect, start_job_command, new_job, child_execute_job, - construct_command_argv_internal, construct_command_argv): Likewise. - * main.c (decode_env_switches, quote_for_env): Likewise. - * misc.c (collapse_continuations, end_of_token, end_of_token_w32, - next_token): Likewise. - * read.c (read_makefile, do_define, conditional_line, - find_char_unquote,get_next_mword): Likewise. - * variable.c (try_variable_definition): Likewise. - * vpath.c (construct_vpath_list): Likewise. - * w32/pathstuff.c (convert_vpath_to_windows32): Likewise. - -2000-05-10 Eli Zaretskii - - * main.c (main) [__MSDOS__]: Add SIGFPE to signals we block when - running child programs, to prevent Make from dying on Windows 9X - when the child triggers an FP exception. - -2000-05-08 Paul D. Smith - - * dir.c (find_directory) [WINDOWS32]: If we strip a trailing "\" - from the directory name, remember to add it back. The argument - might really be inside a longer string (e.g. %Path%) and if you - don't restore the "\" it'll be truncated permanently. Fixes PR/1722. - Reported by - -2000-05-02 Paul D. Smith - - * job.c (construct_command_argv_internal) [WINDOWS32]: Added "rd" - and "rmdir" to the list of command.com commands. - Reported by Elod Horvath - -2000-04-24 Paul D. Smith - - * i18n/ja.po: New translation file from the Japanese language team. - -2000-04-18 Paul D. Smith - - * remake.c (f_mtime): If ar_member_date() returns -1 (the member - doesn't exist), then return (FILE_TIMESTAMP)-1 rather than - returning the timestamp calculated from the value -1. Fixes PR/1696. - Reported by Gilles Bourhis . - -2000-04-17 Paul D. Smith - - * config.h.W32.template: Add LOCALEDIR macro resolving to "". - * w32/subproc/sub_proc.c (process_begin): Remove reference to - debug_flag; change it to a DB() call. Fixes PR/1700. - Reported by Jim Smith - -2000-04-17 Bruno Haible - - * arscan.c [BeOS]: Add replacement for nonexistent from GNU - binutils. - -2000-04-11 Paul D. Smith - - * function.c (expand_builtin_function): If no arguments were - provided, just quit early rather than changing each function to - test for this. - (function_table[]): Change the min # of arguments to 0 for all - those functions for which it makes sense (currently everything - that used to take a minimum of 1 argument, except $(call ...)). - Fixes PR/1689. - -2000-04-09 Eli Zaretskii - - * README.DOS: Add instructions to install a binary distro. - Mention latest versions of Windows. - -2000-04-07 Eli Zaretskii - - * main.c (main): Rename TMP_TEMPLATE into DEFAULT_TMPDIR, and use - it for the directory of the temporary file. If P_tmpdir is - defined, use it in preference to "/tmp/". Try $TMPDIR, $TEMP, and - $TMP in the environment before defaulting to DEFAULT_TMPDIR. - (print_version): Add year 2000 to the Copyright line. - -2000-04-04 Paul D. Smith - - * Version 3.79 released. - - * make.texinfo: Update documentation with new features for 3.79. - - * function.c (func_wordlist): Don't re-order arguments to - wordlist. - -2000-04-03 Paul D. Smith - - * remake.c (f_mtime): Archive member timestamps are stored as - time_t, without nanoseconds. But, f_mtime() wants to return - nanosecond info on those systems that support it. So, convert the - return value of ar_member_date() into a FILE_TIMESTAMP, using 0 as - the nanoseconds. - -2000-03-28 Paul D. Smith - - * Version 3.78.92 released. - - * build.template: Updates for gettext support; some bugs fixed. - -2000-03-27 Paul D. Smith - - * config.guess, config.sub: Updated from config CVS archive at - :pserver:anoncvs@subversions.gnu.org:/home/cvs as of today. - - * read.c (record_files): Check if expanding a static pattern - rule's prerequisite pattern leaves an empty string as the - prerequisite, and issue an error if so. Fixes PR/1670. - (read_makefile): Store the starting linenumber for a rule in - TGTS_STARTED. - (record_waiting_files): Use the TGTS_STARTED value for the file - location passed to record_file() instead of the current - linenumber, so error messages list the line where the target was - defined instead of the line after the end of the rule definition. - - * remake.c (start_updating, finish_updating, is_updating): Fix - PR/1671; circular dependencies in double-colon rules are not - diagnosed. These macros set the updating flag in the root - double-colon file instead of the current one, if it's part of a - double-colon list. This solution provided by Tim Magill - ; I just changed the macro names :). - (update_file_1): Call them. - (check_dep): Call them. - - The change to not automatically evaluate the $(call ...) - function's arguments breaks recursive use of call. Although using - $(if ...) and $(foreach ...) in $(call ...) macros is important, - the error conditions generated are simply to obscure for me to - feel comfortable with. If a method is devised to get both - working, we'll revisit. For now, remove this change. - - * function.c (function_table): Turn on the expand bit for func_call. - (func_call): Don't expand arguments for builtin functions; that - will have already been done. - -2000-03-26 Paul D. Smith - - * file.c (remove_intermediates): Never remove targets explicitly - requested on the command-line by checking the cmd_target flag. - Fixed PR/1669. - -2000-03-23 Paul Eggert - - * filedef.h (FILE_TIMESTAMP_STAT_MODTIME): Use st_mtime instead of - st_mtim.tv_sec; the latter doesn't work on Unixware. - -2000-03-18 Paul D. Smith - - * file.c (file_hash_enter): If we're trying to change a file into - itself, just return. We used to assert this wasn't true, but - someone came up with a weird case involving archives. After - playing with it for a while I decided it was OK to ignore it. - - * default.c: Define COFLAGS to empty to avoid spurious warnings. - - * filedef.h: Change #if ST_MTIM_NSEC to #ifdef; this is a macro - containing the name of the nsec field, not true/false. - * make.h: Ditto. - Reported by Marco Franzen . - -2000-03-08 Tim Magill - - * remake.c (update_file): Return the exit status of the pruned - file when pruning, not just 0. Fixes PR/1634. - -2000-02-24 Paul D. Smith - - * configure.in: Close a minor potential security hole; if you're - reading makefiles from stdin (who does that?) you could run into a - race condition with the temp file using mktemp() or tmpnam(). Add - a check for mkstemp() and fdopen(). - * main.c (open_tmpfile): New function to open a temporary file. - If we have mkstemp() (and fdopen()), use that. If not use - mktemp() or tmpnam(). If we have fdopen(), use open() to open the - file O_CREAT|O_EXCL. If not, fall back to normal fopen() (insecure). - (main): Call it. - * job.c (child_execute_job) [VMS]: Call it. - - * variable.c (lookup_variable): If we find a variable which is - being expanded, then note it but keep looking through the rest of - the set list to see if we can find one that isn't. If we do, - return that. If we don't, return the original. Fix for PR/1610. - - While implementing this I realized that it also solves PR/1380 in - a much more elegant way. I don't know what I was smoking before. - So, remove the hackage surrounding the original fix for that (see - below). Change this function back to lookup_variable and remove - the extra setlist argument. - * variable.h (recursively_expand_setlist): Remove the macro, - rename the prototype, and remove the extra setlist argument. - (lookup_variable): Ditto. - * expand.c (recursively_expand): Rename and remove the extra - setlist argument. - (reference_variable): Use lookup_variable() again. - (allocated_variable_append): Remove the extra setlist argument. - -2000-02-21 Paul D. Smith - - * README.template: A few updates. - - * i18n/de.po: New version from the German translation team. - -2000-02-09 Paul D. Smith - - * Version 3.78.91 released. - -2000-02-07 Paul D. Smith - - * read.c (read_makefile): Reset *p2 to ':', not *colonp. If any - filenames contained backslashes the resulting output (without - backslashes) will be shorter, so setting *colonp doesn't change - the right character. Fix for PR/1586. - - For += target-specific variables we need to remember which - variable set we found the variable in, so we can start looking - from there in the next iteration (otherwise we might see it again - in recursively_expand and fail!). This is turning into a hack; if - it gets any worse we'll have to rethink this entire algorithm... - implementing expansion of these references separately from the - "normal" expansion, say, instead of using the same codepath. - Actually, it's already "worse enough" :-/. - Fix for PR/1380. - - * variable.h (recursively_expand_setlist): Rename - recursively_expand to add a struct variable_set_list argument, and - make a macro for recursively_expand. - (lookup_variable_setlist): Rename lookup_variable to add a struct - variable_set_list argument, and make a macro for lookup_variable. - - * expand.c (recursively_expand_setlist): Take an extra struct - variable_set_list argument and pass it to allocated_variable_append(). - (reference_variable): Use lookup_variable_setlist() and pass the - returned variable_set_list to recursively_expand_setlist. - (allocated_variable_append): Take an extra setlist argument and - use this as the starting place when searching for the appended - expansion. If it's null, use current_variable_set_list as before. - - * variable.c (lookup_variable_setlist): If the LISTP argument is - not nil, set it to the list containing the variable we found. - -2000-02-04 Paul D. Smith - - * variable.c (print_variable): Write out filename/linenumber - information for the variable definition if present. - (define_variable_in_set): Store filename information if provided. - (define_variable, define_variable_for_file): Removed. - (try_variable_definition): Use define_variable_loc() to keep - variable definition location information. - * read.c (read_makefile): Keep variable definition location info. - (do_define): Ditto. - (record_target_var): Ditto. - * variable.h (define_variable_in_set): New fileinfo argument. - (define_variable, define_variable_loc, define_variable_for_file): - Declare new macros. - - Fix PR/1407: - - * filedef.h (struct file): Rename patvar to pat_variables and make - it just a variable_set_list; we need our own copy of the pattern - variable's variable set list here to avoid overwriting the global - one. - * variable.c (initialize_file_variables): Move the instantiation - of the pat_variables pointer here. Only do the search after we're - done reading the makefiles so we don't search too early. If - there's a pat_variables value, set up the variables next ptr. - * expand.c (variable_expand_for_file): Remove the setup of the - pat_variables info; it's done earlier now to ensure the parent's - pattern variables are set up correctly as well. - -2000-02-03 Paul D. Smith - - * job.c (sh_chars_dos) [WINDOWS32]: Add "&" as a shell - metacharacter for the W32 DOS shell. - Reported by Warren Jones . - -2000-02-02 Paul D. Smith - - Fixes for the OpenVMS port from Hartmut Becker - - * config.h-vms [VMS]: Define LOCALEDIR to something; needed for - the expansion of bindtextdomain() even though it's a no-op. - * vmsfunctions.c (strcmpi): Remove duplicate definition of strcmpi(). - (readdir): Use DB() instead of testing debug_flag. - * dir.c (file_impossible) [VMS]: Search "p" not "name". - * job.c [VMS]: Switch from debug_flag to the new DB macro. Add - some i18n _() macros (even though VMS doesn't yet support it). - - * function.c (patsubst_expand): Change "len" to not be unsigned to - avoid type mismatches. - - * main.c (main): Declare signame_init() if we're going to call it. - -2000-01-29 Eli Zaretskii - - * Makefile.DOS.template: Track changes in Makefile.in - (install-recursive, uninstall-recursive): Add missing targets. - (DESTDIR): Define. - (install-binPROGRAMS, uninstall-binPROGRAMS): Use $(DESTDIR). - - * default.c (default_variables) [__MSDOS__]: Define CXX to gpp. - -2000-01-27 Paul D. Smith - - * gettext.c: Some warning cleanups, and a fix for systems which - don't define HAVE_ALLOCA (the workaround code was included - twice). - -2000-01-26 Paul D. Smith - - * Version 3.78.90 released. - -2000-01-25 Paul D. Smith - - Change gettext support to use the simplified version in libit 0.7. - - * getopt.c, make.h: Use gettext.h instead of libintl.h. - * ABOUT-NLS, gettext.h, gettext.c: New files from libit 0.7. - Modified to remove some static declarations which aren't defined. - * acconfig.h: Use new gettext #defines. - * acinclude.m4: Add fp_WITH_GETTEXT; remove AM_GNU_GETTEXT. - * configure.in: Call fp_WITH_GETTEXT instead. - * Makefile.am: New gettext stuff. Also force inclusion of glob - files for systems which have LIBC glob. - - * i18n/Makefile.am, i18n/.cvsignore: New dir for translation files. - * i18n/de.po, i18n/es.po, i18n/fr.po, i18n/ko.po, i18n/nl.po: - * i18n/pl.po, i18n/ru.po: Import translations already done for - earlier versions of GNU make. Thanks for that work!! - - * po/Makefile.in.in, po/POTFILES.in: Removed. - -2000-01-23 Paul D. Smith - - * main.c (decode_debug_flags): If debug_flag is set, enable all - debugging levels. - (debug_flag): Resurrect this flag variable. - (switches): Make -d give the old behavior of turning on all - debugging. Change --debug alone to emit basic debugging and take - optional arguments to expand debugging. - * NEWS: Document the new debugging options. - - * remake.c (no_rule_error): Remove this function. This tries to - fix a real problem--see the description with the introduction of - this function below. However, the cure is worse than the disease - and this approach won't work. - (remake_file): Put the code from no_rule_error back here. - (update_file_1): Remove call to no_rule_error. - - * filedef.h (struct file): Remove mfile_status field. - -2000-01-22 Paul D. Smith - - Integrate GNU gettext support. - - * configure.in: Add AM_GNU_GETTEXT. - * Makefile.am: Add options for setting LOCALEDIR, -Iintl, etc. - * acinclude.m4: Add gettext autoconf macros. - * acconfig.h: Add new gettext #defines. - * make.h: Include libintl.h. Make sure _() and N_() macros are - declared. Make gettext() an empty macro is NLS is disabled. - * main.c (struct command_switch switches[]): Can't initialize - static data with _() (gettext calls), so use N_() there then use - gettext() directly when printing the strings. - * remake.c (no_rule_error): The string constants can't be static - when initializing _() macros. - * file.c (print_file): Reformat a few strings to work better for - translation. - * po/POTFILES.in, po/Makefile.in.in: New files. Take - Makefile.in.in from the latest GNU tar distribution, as that - version works better than the one that comes with gettext. - * NEWS: Mention i18n ability. - -2000-01-21 Paul D. Smith - - Installed patches for the VMS port. - Patches provided by: Hartmut Becker - - * readme.vms, arscan.c, config.h-vms, default.c, dir.c, file.c: - * implicit.c, job.c, make.h, makefile.com, makefile.vms, rule.c: - * variable.c, vmsdir.h, vmsfunctions.c, vmsify.c, glob/glob.c: - * glob/glob.h: Installed patches. See readme.vms for details. - -2000-01-14 Andreas Schwab - - * dir.c (read_dirstream): Initialize d_type if it exists. - -2000-01-11 Paul D. Smith - - Resolve PR/xxxx: don't automatically evaluate the $(call ...) - function's arguments. While we're here, clean up argument passing - protocol to always use simple nul-terminated strings, instead of - sometimes using offset pointers to mark the end of arguments. - This change also fixes PR/1517. - Reported by Damien GIBOU . - - * function.c (struct function_table_entry): Remove the negative - required_args hack; put in explicit min and max # of arguments. - (function_table): Add in the max value. Turn off the expand bit - for func_call. - (expand_builtin_function): Test against minimum_args instead of - the obsolete required_args. - (handle_function): Rewrite this. We don't try to be fancy and - pass one style of arguments to expanded functions and another - style to non-expanded functions: pass pointers to nul-terminated - strings to all functions. - (func_call): Rewrite this. If we are invoking a builtin function - and it's supposed to have its arguments expanded, do that (since - it's not done by handle_function for $(call ...) anymore). For - non-builtins, just add the variables as before but mark them as - recursive so they'll be expanded later, as needed. - (func_if): All arguments are vanilla nul-terminated strings: - remove trickery with "argv[1]-1". - (func_foreach): Ditto. - - * expand.c (expand_argument): If the second arg is NULL, expand - the entire first argument. - - * job.c (new_job): Zero the child struct. This change was just - made to keep some heap checking software happy, not because there - was an actual bug (the important memory was being cleared properly). - -1999-12-15 Paul D. Smith - - * variable.c (print_variable): Print the variable with += if the - append flag is set. - - * implicit.c (pattern_search): Remove the extra check of the - implicit flag added on 8/24/1998. This causes problems and the - reason for the change was better resolved by the change made to - check_deps() on 1998-08-26. This fixes PR/1423. - -1999-12-08 Paul D. Smith - - * dir.c (dir_setup_glob): On 64 bit ReliantUNIX (5.44 and above) - in LFS mode, stat() is actually a macro for stat64(). Assignment - doesn't work in that case. So, stat is a macro, make a local - wrapper function to invoke it. - (local_stat): Wrapper function, if needed. - Reported by Andrej Borsenkow . - -1999-12-02 Paul D. Smith - - * remake.c (update_file): Move the considered test outside the - double-colon loop, _but_ make sure we test the double_colon target - not the "current" target. If we stop early because one - double-colon target is running, mark all the rest considered and - try to start their prerequisites (so they're marked considered). - Fix for PR/1476 suggested by Tim Magill . - -1999-11-22 Rob Tulloh - - * function.c (windows32_openpipe, func_shell): Correct Windows32 - problem where $(shell nosuchfile) would incorrectly exit make. The - fix is to print the error and let make continue. - Reported by David Masterson . - - * w32/subproc/misc.c (arr2envblk): Memory leak fix. - -1999-11-21 Paul D. Smith - - Rework GNU make debugging to provide different levels of output. - - * NEWS: mention it. - * debug.h: New file. Define various debugging levels and macros. - * function.c, implicit.c, job.c, main.c, misc.c, read.c, remake.c - * remote-cstms.c, vmsfunctions.c: Replace all code depending on - debug_flag with invocations of debugging macros. - * make.h: Remove debug_flag and DEBUGPR, add db_level. - -1999-11-18 Paul Eggert - - * acinclude.m4 (AC_SYS_LARGEFILE_FLAGS): Work around a problem - with the QNX 4.25 shell, which doesn't propagate exit status of - failed commands inside shell assignments. - -1999-11-17 Paul D. Smith - - * function.c (func_if): Find the end of the arg list by testing - the next item for NULL; any other test is not correct. - Reported by Graham Reed (PR/1429). - - Fix += when used in a target-specific variable context. - - * variable.h: New bitfield APPEND set if we have a += - target-specific variable. - - * variable.c (try_variable_definition): Add an argument to specify - if we're trying a target-specific variable. If we are and it's an - append style, don't append it, record it as normal recursive, but - set the APPEND flag so it'll be expanded later. - * main.c (handle_non_switch_argument): Use new - try_variable_definition() signature. - * read.c (read_makefile,record_target_var): Ditto. - - * expand.c (allocated_variable_append): New function: like - allocated_variable_expand(), but we expand the same variable name - in the context of the ``next'' variable set, then we append this - expanded value. - (recursively_expand): Invoke it, if the APPEND bit is set. - -1999-11-10 Paul D. Smith - - * file.c (snap_deps): If the .NOTPARALLEL target is defined, turn - off parallel builds for this make only (still allow submakes to be - run in parallel). - * main.c: New variable, ``not_parallel''. - * make.h: Add an extern for it. - * job.c (new_job): Test NOT_PARALLEL as well as JOB_SLOTS. - * NEWS: Add info on .NOTPARALLEL. - * make.texinfo (Special Targets): Document it. - - * configure.in (GLOBDIR): Set to "glob" if we need to build the - glob library. - * Makefile.am (SUBDIRS): Use the GLOBDIR variable instead of - "glob" so we don't try to build glob if we don't need to (if we - have GLIBC glob). Reported by Lars Hecking . - - * main.c (main): Don't put "***" in the clock skew warning - message. Reported by karl@gnu.org. - - * make.h: Remove unneeded signal setup. - - * signame.c: Remove extraneous #includes; some versions of Ultrix - don't protect against multiple inclusions and it causes compile - errors. Reported by Simon Burge . - -1999-10-15 Paul D. Smith - - * main.c (quote_for_env): Rename from quote_as_word(). - - * make.h, *.c: Prefer strchr() and strrchr() in the code - rather than index() and rindex(). Define strchr/strrchr in terms - of index/rindex if the former aren't supported. - - * default.c (CHECKOUT,v): Replace the fancy, complicated - patsubst/filter expression with a simple $(if ...) expression. - - * main.c (print_usage): Add the bug reporting mailing address to - the --help output, as per the GNU coding standards. - Reported by Paul Eggert . - - * README.customs: Installed information on running Customs-ized - GNU make and setuid root, collected by Ted Stern . - - * read.c (read_all_makefiles): PR/1394: Mark the end of the next - token in the MAKEFILES value string _before_ we dup it. - -1999-10-13 Paul D. Smith - - * configure.in (make_cv_sys_gnu_glob): We used to add the -Iglob - flag to CPPFLAGS, but that loses if the user specifies his own - CPPFLAGS; this one gets added _after_ his and if he happens to - have an old or broken glob.h--boom. Instead, put it in GLOBINC - and SUBST it. - - * Makefile.am (INCLUDES): Add @GLOBINC@ to the INCLUDES macro; - these things get on the compile line well before the user's - CPPFLAGS. - -1999-10-12 Paul D. Smith - - * remake.c (notice_finished_file): If we get here and -n is set, - see if all the command lines are marked recursive. If so, then we - ran every command there is, so check the mtime on this file just - like we would normally. If not, we assume the command we didn't - run would updates the target and set mtime of the target to "very new". - - * job.c (start_job_command): Update lines_flags in the file's cmds - structure with any per-line tokens we found (`@', `-', `+'). - -1999-10-08 Paul D. Smith - - * variable.c (initialize_file_variables): Always recurse to - initialize the parent's file variables: the parent might not have - any rules to run so it might not have been initialized before - this--we need this to set up the chain properly for - target-specific variables. - -1999-09-29 Paul Eggert - - * main.c (quote_as_word): Always quote for decode_env_switches - instead of for the shell, so that arguments with strange - characters are are passed to submakes correctly. Remove - double_dollars arg; we always double dollars now. All callers - changed. - (decode_env_switches): Don't run off the end of an environment - variable whose contents ends in a unescaped backslash. - -1999-09-23 Paul D. Smith - - * commands.c, function.c, job.c, read.c: Cast arguments to - ctype.h functions/macros to _unsigned_ char for portability. - - * remake.c, function.c: Compiler warning fixes: the second - argument to find_next_token() should be an _unsigned_ int*. - Reported by Han-Wen Nienhuys . - -1999-09-23 Paul D. Smith - - * Version 3.78.1 released. - - * make.texinfo: Update version/date stamp. - - * main.c (main): Argh. For some reason we were closing _all_ the - jobserver pipes before we re-exec'd due to changed makefiles. - This means that any re-exec got a "jobserver unavailable" error :-/. - I can't believe we didn't notice this before. - -1999-09-22 Paul D. Smith - - * Version 3.78 released. - - * main.c (main): Only fail on multiple --jobserver-fds options if - they aren't all the same. Some makefiles use things like - $(MAKE) $(MFLAGS) which will cause multiple, identical copies of - --jobserver-fds to show up. - -1999-09-16 Paul D. Smith - - * main.c (define_makeflags): Zero out FLAGSTRING to avoid - uninitialized memory reads when checking *p != '-' in the loop. - -1999-09-15 Paul D. Smith - - * Version 3.77.97 released. - - * configure.in (MAKE_HOST): AC_SUBST this so it will go into the - makefile. - * Makefile.am (check-local): Print a success banner if the check - succeeds. - (check-regression): A bit of fine-tuning. - -1999-09-15 Eli Zaretskii - - * README.DOS.template: Document requirements for the test suite. - * Makefile.DOS.template: Updates to allow the test suite to run - from "make check". - - * main.c (main): Handle it if argv[0] isn't an absolute path. - -1999-09-13 Paul D. Smith - - * Version 3.77.96 released. - - * Makefile.am (loadavg): Use CPPFLAGS, etc. to make sure we get - all the right #defines to compile. - (check-regression): Look for the regression test suite in the make - package itself. If we're building remotely, use symlinks to make - a local copy. - (dist-hook): Put the test suite into the tar file. - - * configure.in: Look for perl for the test suite. - -1999-09-10 Paul Eggert - - * acinclude.m4 (AC_SYS_LARGEFILE_FLAGS): If on HP-UX 10.20 or - later, and using GCC, define __STDC_EXT__; this works around a - bug in GCC 2.95.1. - -1999-09-08 Paul D. Smith - - * main.c (print_version): Ugh. GLIBC's configure tries to check - make version strings and is too aggressive with their matching - expressions. I've struck a deal with them to leave the version - output as-is for 3.78, and they'll change their configure checks - so that I can change this back in the future. - -1999-09-07 Eli Zaretskii - - * job.c (construct_command_argv_internal) [__MSDOS__]: Add "echo" - and "unset" to the list of builtin shell commands. - - * configh.DOS.template (MAKE_HOST): Define to "i386-pc-msdosdjgpp" - which is the canonical name of the DJGPP host. - -1999-09-05 Paul D. Smith - - * Version 3.77.95 released. - - * make.texinfo (Make Errors): Document some new jobserver error - messages. - -1999-09-04 Eli Zaretskii - - * make.texinfo (Make Errors): Document the hint about 8 spaces - instead of a TAB. - (Call Function, Quick Reference): Use @code{$(1)}, not @var. - - * main.c (main) [__MSDOS__]: Say "on this platform" instead of "on - MS-DOS", since the MSDOS version could run on Windows. - -1999-09-03 Paul D. Smith - - * remake.c (notice_finished_file): Always set mtime_before_update - if it's not been set, not just if we ran some rules. Otherwise we - may have a situation where a target's prerequisite was rebuilt but - not changed, so this target's rules weren't run, then - update_goal_chain() sees mtime_before_update != last_mtime and - thinks that the top-level target changed when it really didn't. - This can cause an infinite loop when remaking makefiles. - (update_goal_chain): If we get back to the top and we don't know - what the goal's last_mtime was, find it now. We need to know so - we can compare it to mtime_before_update later (this is only - crucial when remaking makefiles--should we only do it then?) - -1999-09-02 Paul D. Smith - - * read.c (read_makefile): If "override" appears as the first - prerequisite, look further to ensure this is really a - target-specific variable definition, and not just some - prerequisite named "override". - -1999-09-01 Paul D. Smith - - * function.c (IS_PATHSEP) [WINDOWS32]: Allow backslash separators - for W32 platforms. - * read.c (record_files) [WINDOWS32]: Allow backslash separators - for W32 platforms. - * implicit.c (pattern_search) [WINDOWS32]: Allow backslash - separators for W32 platforms. - - * configure.in (MAKE_HOST): Define it to be the canonical build - host info, now that we need AC_CANONICAL_HOST anyway (for large - file support). - * version.c (make_host): Define a variable to MAKE_HOST so we're - sure to get it from the local config.h. - * main.c (print_version): Use it in the version information. - * config.ami.template: Add MAKE_HOST. - * configh.dos.template: Ditto. - * config.h.W32.template: Ditto. - * config.h-vms.template: Ditto. - - * main.c (main): Close the jobserver file descriptors if we need - to re-exec ourselves. - Also print more reasonable error if users force -jN for submakes. - This may be common for a while until people use the jobserver - feature. If it happens, we ignore the existing jobserver stuff - and use whatever they specified on the commandline. - (define_makeflags): Fixed a long-standing bug: if a long name - only option comes immediately after a single letter option with no - argument, then the option string is constructed incorrectly. For - example, with -w and --jobserver-fds you get "-w-jobserver-fds..." - instead of "-w --jobserver-fds..."; add in an extra " -". - - * make.texinfo (Phony Targets): Add another example of using - .PHONY with subdirectories/recursive make. - -1999-08-30 Paul D. Smith - - * README.W32.template: Renamed from README.W32 so it's - autogenerated during the dist. A few minor modifications. - - * configure.in: Check for kstat_open before AC_FUNC_GETLOADAVG - since the latter needs to know whether the former exists to give - an accurate result. - -1999-08-26 Rob Tulloh - - * NMakefile [WINDOWS32]: Now more robust. If you change a file - under w32/subproc, the make.exe will be relinked. Also added some - tests to make sure erase commands won't fail when executed in a - pristine build environment. - - * w32/subproc/sub_proc.c [WINDOWS32]: Added support for - HAVE_CYGWIN_SHELL. If you are using the Cygwin B20.1 release, it - is now possible to have have native support for this shell without - having to rely on klutzy BATCH_MODE_ONLY_SHELL. - - * config.h.W32 [WINDOWS32]: Added HAVE_CYGWIN_SHELL macro which - users can define if they want to build make to use this shell. - - * README.W32 [WINDOWS32]: Added informaton about - HAVE_CYGWIN_SHELL. Cleaned up text a bit to make it more current. - -1999-08-26 Paul Eggert - - Support large files in AIX, HP-UX, and IRIX. - - * acinclude.m4 (AC_LFS): Remove. Superseded by AC_SYS_LARGEFILE. - (AC_SYS_LARGEFILE_FLAGS, AC_SYS_LARGEFILE_SPACE_APPEND, - AC_SYS_LARGEFILE_MACRO_VALUE, AC_SYS_LARGEFILE): New macros. - (jm_AC_TYPE_UINTMAX_T): Check for busted compilers that can't - shift or divide unsigned long long. - (AM_PROG_CC_STDC): New macro; a temporary workaround of a bug in - automake 1.4. - - * configure.in (AC_CANONICAL_HOST): Add; required by new - AC_SYS_LARGEFILE. - (AC_SYS_LARGEFILE): Renamed from AC_LFS. - (AM_PROG_CC_STDC): Add. - - * config.guess, config.sub: New files, needed for AC_CANONICAL_HOST. - -1999-08-25 Paul Eggert - - * make.h (CHAR_MAX): New macro. - * main.c (struct command_switch): c is now int, - so that it can store values greater than CHAR_MAX. - (switches): Replace small numbers N with CHAR_MAX+N-1, - to avoid problems with non-ASCII character sets. - (short_option): New macro. - (init_switches, print_usage, define_makeflags): Use it instead of - isalnum. - -1999-08-25 Paul D. Smith - - * Version 3.77.94 released. - - * main.c (main) [__MSDOS__]: If the user uses -j, warn that it's - not supported and reset it. - - * make.h (ISDIGIT): Obtained this from the textutils distribution. - * main.c (decode_switches): Use it. - * function.c (is_numeric): Use it. - - * main.c (struct command_switch): Store the switch char in an - unsigned char to shut up GCC about using it with ctype.h macros. - Besides, it _is_ always unsigned. - -1999-08-24 Paul D. Smith - - * make.texinfo: Change "dependency" to "prerequisite" and - "dependencies" to "prerequisites". Various other cleanups related - to the terminology change. - * file.c: Change debugging and error messages to use - "prerequisite" instead of "dependency". - * implicit.c: Ditto. - * remake.c: Ditto. - * NEWS: Document it. - -1999-08-23 Paul D. Smith - - * remake.c (update_file): Move the considered check into the - double-colon rule loop, so we consider double-colon rules - individually (otherwise after the first is pruned, the rest won't - get run). - - * README.template: Minor changes. - - Remove the debugging features of the jobserver, so it no longer - writes distinct tokens to the pipe. Thus, we don't need to store - the token we get. A side effect of this is to remove a potential - "unavailable token" situation: make-1 invokes make-2 with its - special token and make-3 with a normal token; make-2 completes. - Now we're waiting for make-3 but using 2 tokens; our special token - is idle. In the new version we don't have special tokens per se, - we merely decide if we already have a child or not. If we don't, - we don't need a token. If we do, we have to get one to run the - next child. Similar for putting tokens back: if we're cleaning up - the last child, we don't put a token back. Otherwise, we do. - - * main.c: Add a new, internal flag --jobserver-fds instead of - overloading the meaning of -j. Remove job_slots_str and add the - stringlist jobserver_fds. - (struct command_switch): We don't need the int_string type. - (switches[]): Add a new option for --jobserver-fds and remove - conditions around -j. Make the description for the former 0 so it - doesn't print during "make --help". - (main): Rework jobserver parsing. If we got --jobserver-fds - make sure it's valid. We only get one and job_slots must be 0. - If we're the toplevel make (-jN without --jobserver-fds) create - the pipe and write generic tokens. - Create the stringlist struct for the submakes. - Clean up the stringlist where necessary. - (init_switches): Remove int_string handling. - (print_usage): Don't print internal flags (description ptr is 0). - (decode_switches): Remove int_string handling. - (define_makeflags): Remove int_string handling. - - * job.c: Remove my_job_token flag and all references to the - child->job_token field. - (free_job_token): Remove this and merge it into free_child(). - (reap_children): Rework the "reaped a child" logic slightly. - Don't call defunct free_job_token anymore. Always call - free_child, even if we're dying. - (free_child): If we're not freeing the only child, put a token - back in the pipe. Then, if we're dying, don't bother to free. - (new_job): If we are using the jobserver, loop checking to see if - a) there are no children or b) we get a token from the pipe. - - * job.h (struct child): Remove the job_token field. - -1999-08-20 Paul D. Smith - - * variable.c (try_variable_definition): Allocate for variable - expansion in f_append with a simple variable: if we're looking at - target-specific variables we don't want to trash the buffer. - Noticed by Reiner Beninga . - -1999-08-16 Eli Zaretskii - - * main.c (main) [__MSDOS__]: Mirror any backslashes in argv[0], to - avoid problems in shell commands that use backslashes as escape - characters. - -1999-08-16 Paul D. Smith - - * Version 3.77.93 released. - -1999-08-13 Paul D. Smith - - Another jobserver algorithm change. We conveniently forgot that - the blocking bit is shared by all users of the pipe, it's not a - per-process setting. Since we have many make processes all - sharing the pipe we can't use the blocking bit as a signal handler - flag. Instead, we'll dup the pipe's read FD and have the SIGCHLD - handler close the dup'd FD. This will cause the read() to fail - with EBADF the next time we invoke it, so we know we need to reap - children. We then re-dup and reap. - - * main.c (main): Define the job_rfd variable to hold the dup'd FD. - Actually dup the read side of the pipe. Don't bother setting the - blocking bit on the file descriptor. - * make.h: Declare the job_rfd variable. - * job.c (child_handler): If the dup'd jobserver pipe is open, - close it and assign -1 to job_rfd to notify the main program that - we got a SIGCHLD. - (start_job_command): Close the dup'd FD before exec'ing children. - Since we open and close this thing so often it doesn't seem - worth it to use the close-on-exec bit. - (new_job): Remove code for testing/setting the blocking bit. - Instead of EAGAIN, test for EBADF. If the dup'd FD has been - closed, re-dup it before we reap children. - - * function.c (func_shell): Be a little more accurate about the - length of the error string to allocate. - - * expand.c (variable_expand_for_file): If there's no filenm info - (say, from a builtin command) then reset reading_file to 0. - -1999-08-09 Paul D. Smith - - * maintMakefile: Use g in sed (s///g) to replace >1 variable per - line. - - * Makefile.DOS.template [__MSDOS__]: Fix mostlyclean-aminfo to - remove the right files. - -1999-08-01 Eli Zaretskii - - * function.c (msdos_openpipe) [__MSDOS__]: *Really* return a FILE - ptr. - -1999-08-01 Paul D. Smith - - New jobserver algorithm to avoid a possible hole where we could - miss SIGCHLDs and get into a deadlock. The original algorithm was - suggested by Roland McGrath with a nice refinement by Paul Eggert. - Many thanks as well to Tim Magill and Howard Chu, who also - provided many viable ideas and critiques. We all had a fun week - dreaming up interesting ways to use and abuse UNIX syscalls :). - - Previously we could miss a SIGCHLD if it happened after we reaped - the children but before we re-entered the blocking read. If this - happened to all makes and/or all children, make would never wake - up. - - We avoid this by having the SIGCHLD handler reset the blocking bit - on the jobserver pipe read FD (normally read does block in this - algorithm). Now if the handler is called between the time we reap - and the time we read(), and there are no tokens available, the - read will merely return with EAGAIN instead of blocking. - - * main.c (main): Set the blocking bit explicitly here. - * job.c (child_handler): If we have a jobserver pipe, set the - non-blocking bit for it. - (start_waiting_job): Move the token stuff back to new_job; if we - do it here then we're not controlling the number of remote jobs - started! - (new_job): Move the check for job slots to _after_ we've created a - child structure. If the read returns without getting a token, set - the blocking bit then try to reap_children. - - * make.h (EINTR_SET): Define to test errno if EINTR is available, - or 0 otherwise. Just some code cleanup. - * arscan.c (ar_member_touch): Use it. - * function.c (func_shell): Use it. - * job.c (reap_children): Use it. - * remake.c (touch_file): Use it. - -1999-07-28 Paul D. Smith - - * make.h: Define _() and N_() macros as passthrough to initiate - NLS support. - * : Add _()/N_() around translatable strings. - -1999-07-27 Paul D. Smith - - * read.c: Make sure make.h comes before other headers. - -1999-07-26 Paul D. Smith - - * make.texinfo (Quick Reference): Update with the new features. - -1999-07-25 Eli Zaretskii - - * remake.c [__MSDOS__]: Don't include variables.h, it's already - included. - - * function.c (msdos_openpipe) [__MSDOS__]: Return FILE ptr. - (func_shell) [__MSDOS__]: Fix the argument list. - - * Makefile.DOS.template: Update from Makefile.in. - - * README.DOS.template: Configure command fixed. - - * configh.dos.template: Update to provide definitions for - uintmax_t, fd_set_size_t, and HAVE_SELECT. - -1999-07-24 Paul D. Smith - - * Version 3.77.91 released. - - * configure.in: Changes to the boostrapping code: if build.sh.in - doesn't exist configure spits an error and generates an empty - build.sh file which causes make to be confused. - * maintMakefile: Don't build README early. - -1999-07-23 Paul D. Smith - - * job.c (my_job_token): This variable controls whether we've - handed our personal token to a subprocess or not. Note we could - probably infer this from the value of job_slots_used, but it's - clearer to just keep it separately. Job_slots_used isn't really - relevant when running the job server. - (free_job_token): New function: free a job token. If we don't - have one, no-op. If we have the personal token, reclaim it. If - we have another token, write it back to the pipe. - (reap_children): Call free_job_token. - (free_child): Call free_job_token. - (start_job_command): Remove duplicate test for '+' in the command. - If we don't appear to be running a recursive make, close the - jobserver filedescriptors. - (start_waiting_job): If our personal token is available, use that - instead of going to the server pipe. - (*): Add the token value to many debugging statements, and print - the child target name in addition to the ptr hex value. - Change the default "no token" value from '\0' to '-' so it looks - better in the output. - - * main.c (main): Install the child_handler with sigaction() - instead of signal() if we have it. On SysV systems, signal() uses - SysV semantics which are a pain. But sigaction() always does what - we want. - (main): If we got job server FDs from the environment, test them - to see if they're open. If not, the parent make closed them - because it didn't think we were a submake. Print a warning and - suggestion to use "+" on the submake invocation, and hard-set to - -j1 for this instance of make. - (main): Change the algorithm for assigning slots to be more - robust. Previously make checked to see if it thought a subprocess - was a submake and if so, didn't give it a token. Since make's - don't consume tokens we could spawn many of makes fighting for a - small number of tokens. Plus this is unreliable because submakes - might not be recognized by the parent (see above) then all the - tokens could be used up by unrecognized makes, and no one could - run. Now every make consumes a token from its parent. However, - the make can also use this token to spawn a child. If the make - wants more than one, it goes to the jobserver pipe. Thus there - will never be more than N makes running for -jN, and N*2 processes - (N makes and their N children). Every make can always run at - least one job, and we'll never deadlock. (Note the closing of the - pipe for non-submakes also solves this, but this is still a better - algorithm.) So! Only put N-1 tokens into the pipe, since the - topmost make keeps one for itself. - - * configure.in: Find sigaction. Disable job server support unless - the system provides it, in addition to either waitpid() or - wait3(). - -1999-07-22 Rob Tulloh - - * arscan.c (ar_member_touch) [WINDOWS32]: The ar_date field is a - string on Windows, not a timestamp. - -1999-07-21 Paul D. Smith - - * Version 3.77.90 released. - - * Makefile.am (AUTOMAKE_OPTIONS): Require automake 1.4. - - * function.c: Rearrange so we don't need to predeclare the - function_table array; K&R C compilers don't like that. - - * acinclude.m4 (AC_FUNC_SELECT): Ouch; this requires an ANSI C - compiler! Change to work with K&R compilers as well. - - * configure.in (AC_OUTPUT): Put build.sh back. I don't know how I - thought it would work this way :-/. We'll have to think of - something else. - * Makefile.am: Remove rule to create build.sh. - - * default.c (default_suffix_rules): Rearrange the default command - lines to conform to POSIX rules (put the filename argument $< - _after_ the OUTPUT_OPTION, not before it). - - * various: Changed !strncmp() calls to strneq() macros. - - * misc.c (sindex): Make slightly more efficient. - - * dir.c (file_impossible): Change savestring(X,strlen(X)) to xstrdup(). - * implicit.c (pattern_search): Ditto. - * main.c (enter_command_line_file): Ditto. - (main): Ditto. - * misc.c (copy_dep_chain): Ditto. - * read.c (read_makefile): Ditto. - (parse_file_seq): Ditto. - (tilde_expand): Ditto. - (multi_glob): Ditto. - * rule.c (install_pattern_rule): Ditto. - * variable.c (define_variable_in_set): Ditto. - (define_automatic_variables): Ditto. - * vpath.c (construct_vpath_list): Ditto. - - * misc.c (xrealloc): Some reallocs are non-standard: work around - them in xrealloc by calling malloc if PTR is NULL. - * main.c (main): Call xrealloc() directly instead of testing for - NULL. - - * function.c (func_sort): Don't try to free NULL; some older, - non-standard versions of free() don't like it. - - * configure.in (--enable-dmalloc): Install some support for using - dmalloc (http://www.dmalloc.com/) with make. Use --enable-dmalloc - with configure to enable it. - - * function.c (function_table_entry): Whoops! The function.c - rewrite breaks backward compatibility: all text to a function is - broken into arguments, and extras are ignored. So $(sort a,b,c) - returns "a"! Etc. Ouch. Fix it by making a positive value in - the REQUIRED_ARGS field mean exactly that many arguments to the - function; any "extras" are considered part of the last argument as - before. A negative value means at least that many, but may be - more: in this case all text is broken on commas. - (handle_function): Stop when we've seen REQUIRED_ARGS args, if >0. - (expand_builtin_function): Compare number of args to the absolute - value of REQUIRED_ARGS. - -1999-07-20 Paul D. Smith - - * job.c (start_job_command): Ensure that the state of the target - is cs_running. It might not be if we skipped all the lines due to - -n (for example). - - * commands.c (execute_file_commands): If we discover that the - command script is empty and succeed early, set cs_running so the - modtime of the target is still rechecked. - - * rule.c (freerule): Free the dependency list for the rule. - - * implicit.c (pattern_search): When turning an intermediate file - into a real target, keep the also_make list. - Free the dep->name if we didn't use it during enter_file(). - -1999-07-16 Paul D. Smith - - * read.c (read_makefile): Don't allocate the commands buffer until - we're sure we found a makefile and won't return early (mem leak). - - * job.c (start_job_command): Broken #ifdef test: look for F_SETFD, - not FD_SETFD. Close-on-exec isn't getting set on the bad_stdin - file descriptor and it's leaking :-/. - * getloadavg.c (getloadavg): Ditto. - -1999-07-15 Paul D. Smith - - * read.c (read_makefile): Fix some potential memory stomps parsing - `define' directives where no variable name is given. - - * function.c (func_call): Rename from func_apply. Various code - cleanup and tightening. - (function_table): Add "call" as a valid builtin function. - - * make.texinfo (Call Function): Document it. - - * NEWS: Announce it. - -1999-07-09 Eli Zaretskii - - * variable.c (try_variable_definition) [__MSDOS__, WINDOWS32]: - Treat "override SHELL=" the same as just "SHELL=". - -1999-07-09 Paul D. Smith - - * job.c (start_waiting_job): Don't get a second job token if we - already have one; if we're waiting on the load to go down - start_waiting_job() might get called twice on the same file. - - * filedef.h (struct file): Add new field, mtime_before_update. - When notice_finished_file runs it assigns the cached last_mtime to - this field. - * remake.c (update_goal_chain): Notice that a file wasn't updated - by asking if it changed (g->changed) and comparing the current - cached time (last_mtime) with the previous one, stored in - mtime_before_update. The previous check ("did last_mtime changed - during the run of update_file?") fails for parallel builds because - last_mtime is set during reap_children, before update_file is run. - This causes update_goal_chain to always return -1 (nothing - rebuilt) when running parallel (-jN). This is OK during "normal" - builds since our caller (main) treats these cases identically in - that case, but if when rebuilding makefiles the difference is very - important, as it controls whether we re-exec or not. - * file.c (file_hash_enter): Copy the mtime_before_update field. - (snap_deps): Initialize mtime_before_update to -1. - * main.c (main): Initialize mtime_before_update on old (-o) and - new (-W) files. - -1999-07-08 Paul D. Smith - - * main.c (switches): Define a new switch -R (or - --no-builtin-variables). This option disables the defining of all - the GNU make builtin variables. - (main): If -R was given, force -r as well. - * default.c (define_default_variables): Test the new flag. - * make.h: Declare global flag. - * make.texinfo (Options Summary): Document the new option. - (Implicit Variables): Ditto. - -1999-07-06 Paul D. Smith - - * make.texinfo (Options Summary): Correct examples in - --print-data-base option summary (problem reported by David Morse - ). - - * arscan.c: Add support for archives in Windows (VC++). Frank - Libbrecht provided info on how to do - this. - * NMakefile.template (CFLAGS_any): Remove NO_ARCHIVES from the - compile line. - * build_w32.bat: Ditto. - - * remake.c (no_rule_error): Fix -include/sinclude so it doesn't - give errors if you try to -include the same file twice. - (updating_makefiles): New variable: we need to know this info in - no_rule_error() so we know whether to print an error or not. - (update_file_1): Unconditionally call no_rule_error(), don't try - to play games with the dontcare flag. - -1999-06-14 Paul D. Smith - - * make.texinfo (Remaking Makefiles): Add a description of how to - prevent implicit rule searches for makefiles. - - * make.1: Remove statement that make continues processing when -v - is given. - -1999-06-14 Paul D. Smith - - * read.c (read_makefile): Cast -1 arguments to - variable_expand_string() to long. Alexandre Sauve - reports that without casts, this breaks - on a NEC SUPER-UX SX-4 system (and it's wrong without a cast - anyway). Of course, (a) I'd really love to start using function - prototypes, and (b) there's a whole slew of issues related to int - vs. long and signed vs. unsigned in the length handling of - variable buffers, etc. Gross. Needs a complete mucking-out. - * expand.c (variable_expand): Ditto. - - * acinclude.m4 (AC_FUNC_SELECT): Slight enhancement for AIX 3.2 by - Lars Hecking . - - * read.c (get_next_mword): Allow colons to be escaped in target - names: fix for regression failure. - -1999-04-26 Paul D. Smith - - * main.c (main): Reset read_makefiles to empty after processing so - we get the right error message. - -1999-04-25 Paul D. Smith - - * make.texinfo: Updates to @dircategory and @direntry suggested by - Karl Berry . - -1999-04-23 Eli Zaretskii - - * job.c (start_job_command) [__MSDOS__]: Call unblock_sigs before - turning off dos_command_running, so child's signals produce the - right effect. - - * commands.c (fatal_error_signal) [__MSDOS__]: Use EXIT_FAILURE - instead of 1. - -1999-04-18 Eli Zaretskii - - * configh.dos.template: Update to recognize that version 2.02 of - DJGPP contains sys_siglist stuff. - -1999-04-14 Paul D. Smith - - * make.texinfo (Options/Recursion): Document the job server. - (Parallel): Tweaks. - -1999-04-13 Paul D. Smith - - Implement a new "job server" feature; the implementation was - suggested by Howard Chu . - - * configure.in (job-server): New disable option for job server - support--it's enabled by default. If it works well this will go - away. - - * NEWS: Summarize the new feature. - - * acconfig.h: New definition MAKE_JOBSERVER if job server support - is enabled. - * config.h-vms.template: Undef MAKE_JOBSERVER for this port. - * config.h.W32.template: Ditto. - * config.ami.template: Ditto. - - * main.c (struct command_switch): Add a new type: int_string. - (switches[]) Use int_string for -j if MAKE_JOBSERVER. - (init_switches): Initialize the new int_string switch type. - (print_usage): New function, extracted from decode_switches(). - (decode_switches): Call it. Decode the new int_string switch type. - (define_makeflags): Add new int_string switch data to MAKEFLAGS. - (job_fds[]) Array to contain the pipe file descriptors. - (main): Parse the job_slots_str option results. If necessary, - create the pipe and seed it with tokens. Set the non-blocking bit - for the read fd. Enable the signal handler for SIGCHLD even if we - have a non-hanging wait; it's needed to interrupt the select() in - job.c:start_waiting_job(). - - * make.h: Declare job_fds[]. - - * job.h (struct child): Add job_token field to store the token for - this job (if any). - - * job.c (reap_children): When a child is fully reaped, release the - token back into the pipe. - (free_child): If the child to be freed still has a token, put it - back. - (new_job): Initialize the job_token member. - (start_waiting_job): For local jobs, if we're using the pipe, get - a token before we check the load, etc. We do this by performing a - non-blocking read in a loop. If the read fails, no token is - available. Do a select on the fd to wait for a token. We need to - re-enable the signal handler for SIGCHLD even if we have a - non-hanging waitpid() or wait3(), so that the signal will - interrupt the select() and we can wake up to reap children. - (child_handler): Re-enable the signal handler. The count is still - kept although it's not needed or used unless you don't have - waitpid() or wait3(). - -1999-04-10 Paul D. Smith - - * main.c (main): Reset the considered bit on all the makefiles if - something failed to update; we need to examine them again if they - appear as normal targets in order to get the proper error message. - -1999-04-09 Paul D. Smith - - Performance enhancement from Tim Magill . - - * remake.c (update_file): If you have large numbers of - dependencies and you run in parallel, make can spend considerable - time each pass through the graph looking at branches it has - already seen. Since we only reap_children() when starting a pass, - not in the middle, if a branch has been seen already in that pass - nothing interesting can happen until the next pass. So, we toggle - a bit saying whether we've seen this target in this pass or not. - (update_goal_chain): Initially set the global considered toggle to - 1, since all targets initialize their boolean to 0. At the end of - each pass, toggle the global considered variable. - * filedef.h (struct file): Per-file considered toggle bit. - * file.c: New global toggle variable considered. - -1999-04-05 Paul D. Smith - - * arscan.c (ar_scan): Added support for ARFZMAG (compressed - archives?) for Digital UNIX C++. Information provided by - Patrick E. Krogel . - (ar_member_touch): Ditto. - -1999-04-03 Paul D. Smith - - * remake.c (f_mtime): If: a) we found a file and b) we didn't - create it and c) it's not marked as an implicit target and d) it - is marked as an intermediate target, then it was so marked due to - an .INTERMEDIATE special target, but it already existed in the - directory. In this case, unset the intermediate flag so we won't - delete it when make is done. It feels like it would be cleaner to - put this check in update_file_1() but I worry it'll get missed... - -1999-04-01 Paul D. Smith - - * job.c (construct_command_argv_internal): Use bcopy() to copy - overlapping strings, rather than strcpy(). ISO C says the latter - is undefined. Found this in a bug report from 1996! Ouch! - -1999-03-31 Paul D. Smith - - * read.c (readline): Ignore carriage returns at the end of the - line, to allow Windows-y CRLF line terminators. - -1999-03-30 Paul D. Smith - - * configure.in: Don't put build.sh here, since build.sh.in doesn't - exist initially. This cause autoreconf and automake to fail when - run on a clean CVS checkout. Instead, we create build.sh in the - Makefile (see below). - - * Makefile.am: Remove BUILT_SOURCES; this is no longer relevant. - Put those files directly into EXTRA_DIST so they're distributed. - Create a local build rule to create build.sh. - Create a local maintainer-clean rule to delete all the funky - maintainers files. - - * maintMakefile: Makefile.in depends on README, since automake - fails if it doesn't exist. Also don't remove glob/Makefile.in - here, as it causes problems. - -1999-03-26 Paul D. Smith - - * configure.in: Substitute GLOBLIB if we need the link the - glob/libglob.a library. - * Makefile.am (make_LDADD): Use the subst variable GLOBLIB so we - don't link the local libglob.a at all if we don't need it. - * build.template: Don't compile glob/*.o unless we want globlib. - * maintMakefile (build.sh.in): Substitute the glob/*.o files - separately. - -1999-03-25 Paul D. Smith - - * make.texinfo: Various typos and additions, pointed out by James - G. Sack . - -1999-03-22 Paul D. Smith - - * make.texinfo (Functions): Add a new section documenting the new - $(error ...) and $(warning ...) functions. Also updated copyright - dates. - * NEWS: Updated for the new functions. - * function.c (func_error): Implement the new $(error ...) and - $(warning ...) functions. - (function_table): Insert new functions into the table. - (func_firstword): Don't call find_next_token() with argv[0] - itself, since that function modifies the pointer. - * function.c: Cleanups and slight changes to the new method of - calling functions. - -1999-03-20 Han-Wen Nienhuys - - * function.c: Rewrite to use one C function per make function, - instead of a huge switch statement. Also allows some cleanup of - multi-architecture issues, and a cleaner API which makes things - like func_apply() simple. - - * function.c (func_apply): Initial implementation. Expand either - a builtin function or a make variable in the context of some - arguments, provided as $1, $2, ... $N. - -1999-03-19 Eli Zaretskii -1999-03-19 Rob Tulloh - - * job.c (construct_command_argv_internal): Don't treat _all_ - backslashes as escapes, only those which really escape a special - character. This allows most normal "\" directory separators to be - treated normally. - -1999-03-05 Paul D. Smith - - * configure.in: Check for a system strdup(). - * misc.c (xstrdup): Created. Suggestion by Han-Wen Nienhuys - . - * make.h: Prototype xstrdup(). - * remake.c (library_search): Use it. - * main.c (main): Use it. - (find_and_set_default_shell): Use it. - * job.c (construct_command_argv_internal): Use it. - * dir.c (find_directory): Use it. - - * Makefile.am, configure.in: Use AC_SUBST_FILE to insert the - maintMakefile instead of "include", to avoid automake 1.4 - incompatibility. - -1999-03-04 Paul D. Smith - - * amiga.c, amiga.h, ar.c, arscan.c, commands.c, commands.h, - * default.c, dep.h, dir.c, expand.c, file.c, filedef.h, function.c, - * implicit.c, job.c, job.h, main.c, make.h, misc.c, read.c, remake.c - * remote-cstms.c, remote-stub.c, rule.h, variable.c, variable.h, - * vpath.c, Makefile.ami, NMakefile.template, build.template, - * makefile.vms: Updated FSF address in the copyright notice. - - * variable.c (try_variable_definition): If we see a conditional - variable and we decide to set it, re-type it as recursive so it - will be expanded properly later. - -1999-02-22 Paul D. Smith - - * NEWS: Mention new .LIBPATTERNS feature. - - * make.texinfo (Libraries/Search): Describe the use and - ramifications of the new .LIBPATTERNS variable. - - * remake.c (library_search): Instead of searching only for the - hardcoded expansion "libX.a" for a library reference "-lX", we - obtain a list of patterns from the .LIBPATTERNS variable and - search those in order. - - * default.c: Added a new default variable .LIBPATTERNS. The - default for UNIX is "lib%.so lib%.a". Amiga and DOS values are - also provided. - - * read.c: Remove bogus HAVE_GLOB_H references; always include - vanilla glob.h. - -1999-02-21 Paul D. Smith - - * function.c (expand_function): Set value to 0 to avoid freeing it. - * variable.c (pop_variable_scope): Free the value of the variable. - (try_variable_definition): For simple variables, use - allocated_variable_expand() to avoid stomping on the variable - buffer when we still need it for other things. - - * arscan.c: Modified to support AIX 4.3 big archives. The changes - are based on information provided by Phil Adams - . - -1999-02-19 Paul D. Smith - - * configure.in: Check to see if the GNU glob library is already - installed on the system. If so, _don't_ add -I./glob to the - compile line. Using the system glob code with the local headers - is very bad mojo! - Rewrite SCCS macros to use more autoconf facilities. - - * Makefile.am: Move -Iglob out of INCLUDES; it'll get added to - CPPFLAGS by configure now. - Automake 1.4 introduced its own "include" feature which conflicts - with the maintMakefile stuff. A hack that seems to work is add a - space before the include :-/. - - * build.template: Move -Iglob out of the compile line; it'll get - added to CPPFLAGS by configure now. - -1999-02-16 Glenn D. Wolf - - * arscan.c (ar_scan) [VMS]: Initialized VMS_member_date before - calling lbr$get_index since if the archive is empty, - VMS_get_member_info won't get called at all, and any leftover date - will be used. This bug shows up if any member of any archive is - made, followed by a dependency check on a different, empty - archive. - -1998-12-13 Martin Zinser - - * config.h-vms [VMS]: Set _POSIX_C_SOURCE. Redefine the getopt - functions so we don't use the broken VMS versions. - * makefile.com [VMS]: Allow debugging. - * dir.c (dir_setup_glob) [VMS]: Don't extern stat() on VMS. - -1998-11-30 Paul D. Smith - - * signame.c (init_sig): Check the sizes of signals being set up to - avoid array overwrites (if the system headers have problems). - -1998-11-17 Paul D. Smith - - * read.c (record_files): Clean up some indentation. - -1998-11-08 Han-Wen Nienhuys - - * rule.c (print_rule_data_base): Fix arguments to fatal() call. - -1998-10-13 Paul D. Smith - - * job.c (start_job_command): If the command list resolves to no - chars at all (e.g.: "foo:;$(empty)") then command_ptr is NULL; - quit early. - -1998-10-12 Andreas Schwab - - * rule.c (print_rule_data_base): Ignore num_pattern_rules if it is - zero. - -1998-10-09 Paul D. Smith - - * read.c (read_makefile): Allow non-empty lines to expand to the - empty string after variable, etc., expansion, and be ignored. - -1998-09-21 Paul D. Smith - - * job.c (construct_command_argv_internal): Only add COMMAND.COM - "@echo off" line for non-UNIXy shells. - -1998-09-09 Paul D. Smith - - * w32/subproc/sub_proc.c: Add in missing HAVE_MKS_SHELL tests. - -1998-09-04 Paul D. Smith - - * read.c (read_makefile): If we hit the "missing separator" error, - check for the common case of 8 spaces instead of a TAB and give an - extra comment to help people out. - -1998-08-29 Paul Eggert - - * configure.in (AC_STRUCT_ST_MTIM_NSEC): - Renamed from AC_STRUCT_ST_MTIM. - - * acinclude.m4 (AC_STRUCT_ST_MTIM_NSEC): Likewise. - Port to UnixWare 2.1.2 and pedantic Solaris 2.6. - - * acconfig.h (ST_MTIM_NSEC): - Renamed from HAVE_ST_MTIM, with a new meaning. - - * filedef.h (FILE_TIMESTAMP_FROM_S_AND_NS): - Use new ST_MTIM_NSEC macro. - -1998-08-26 Paul D. Smith - - * remake.c (check_dep): For any intermediate file, not just - secondary ones, try implicit and default rules if no explicit - rules are given. I'm not sure why this was restricted to - secondary rules in the first place. - -1998-08-24 Paul D. Smith - - * make.texinfo (Special Targets): Update documentation for - .INTERMEDIATE: if used with no dependencies, then it does nothing; - old docs said it marked all targets as intermediate, which it - didn't... and which would be silly :). - - * implicit.c (pattern_search): If we find a dependency in our - internal tables, make sure it's not marked intermediate before - accepting it as a found_file[]. - -1998-08-20 Paul D. Smith - - * ar.c (ar_glob): Use existing alpha_compare() with qsort. - (ar_glob_alphacompare): Remove it. - - Modify Paul Eggert's patch so we don't abandon older systems: - - * configure.in: Warn the user if neither waitpid() nor wait3() is - available. - - * job.c (WAIT_NOHANG): Don't syntax error on ancient hosts. - (child_handler, dead_children): Define these if WAIT_NOHANG is not - available. - (reap_children): Only track the dead_children count if no - WAIT_NOHANG. Otherwise, it's a boolean. - - * main.c (main): Add back signal handler if no WAIT_NOHANG is - available; only use default signal handler if it is. - -1998-08-20 Paul Eggert - - Install a more robust signal handling mechanism for systems which - support it. - - * job.c (WAIT_NOHANG): Define to a syntax error if our host - is truly ancient; this should never happen. - (child_handler, dead_children): Remove. - (reap_children): Don't try to keep separate track of how many - dead children we have, as this is too bug-prone. - Just ask the OS instead. - (vmsHandleChildTerm): Fix typo in error message; don't mention - child_handler. - - * main.c (main): Make sure we're not ignoring SIGCHLD/SIGCLD; - do this early, before we could possibly create a subprocess. - Just use the default behavior; don't have our own handler. - -1998-08-18 Eli Zaretskii - - * read.c (read_makefile) [__MSDOS__, WINDOWS32]: Add code to - recognize library archive members when dealing with drive spec - mess. Discovery and initial fix by George Racz . - -1998-08-18 Paul D. Smith - - * configure.in: Check for stdlib.h explicitly (some hosts have it - but don't have STDC_HEADERS). - * make.h: Use HAVE_STDLIB_H. Clean up some #defines. - * config.ami: Re-compute based on new config.h.in contents. - * config.h-vms: Ditto. - * config.h.W32: Ditto. - * configh.dos: Ditto. - - * dir.c (find_directory) [WINDOWS32]: Windows stat() fails if - directory names end with `\' so strip it. - -1998-08-17 Paul D. Smith - - * make.texinfo: Added copyright year to the printed copy. Removed - the price from the manual. Change the top-level reference to - running make to be "Invoking make" instead of "make Invocation", - to comply with GNU doc standards. - - * make.h (__format__, __printf__): Added support for these in - __attribute__ macro. - (message, error, fatal): Use ... prototype form under __STDC__. - Add __format__ attributes for printf-style functions. - - * configure.in (AC_FUNC_VPRINTF): Check for vprintf()/_doprnt(). - - * misc.c (message, error, fatal): Add preprocessor stuff to enable - creation of variable-argument functions with appropriate - prototypes, that works with ANSI, pre-ANSI, varargs.h, stdarg.h, - v*printf(), _doprnt(), or none of the above. Culled from GNU - fileutils and slightly modified. - (makefile_error, makefile_error): Removed (merged into error() and - fatal(), respectively). - * amiga.c: Use them. - * ar.c: Use them. - * arscan.c: Use them. - * commands.c: Use them. - * expand.c: Use them. - * file.c: Use them. - * function.c: Use them. - * job.c: Use them. - * main.c: Use them. - * misc.c: Use them. - * read.c: Use them. - * remake.c: Use them. - * remote-cstms.c: Use them. - * rule.c: Use them. - * variable.c: Use them. - - * make.h (struct floc): New structure to store file location - information. - * commands.h (struct commands): Use it. - * variable.c (try_variable_definition): Use it. - * commands.c: Use it. - * default.c: Use it. - * file.c: Use it. - * function.c: Use it. - * misc.c: Use it. - * read.c: Use it. - * rule.c: Use it. - -1998-08-16 Paul Eggert - - * filedef.h (FILE_TIMESTAMP_PRINT_LEN_BOUND): Add 10, for nanoseconds. - -1998-08-16 Paul Eggert - - * filedef.h (FLOOR_LOG2_SECONDS_PER_YEAR): New macro. - (FILE_TIMESTAMP_PRINT_LEN_BOUND): Tighten bound, and try to - make it easier to understand. - -1998-08-14 Paul D. Smith - - * read.c (read_makefile): We've already unquoted any colon chars - by the time we're done reading the targets, so arrange for - parse_file_seq() on the target list to not do so again. - -1998-08-05 Paul D. Smith - - * configure.in: Added glob/configure.in data. We'll have the glob - code include the regular make config.h, rather than creating its - own. - - * getloadavg.c (main): Change return type to int. - -1998-08-01 Paul Eggert - - * job.c (reap_children): Ignore unknown children. - -1998-07-31 Paul D. Smith - - * make.h, filedef.h, dep.h, rule.h, commands.h, remake.c: - Add prototypes for functions. Some prototypes needed to be moved - in order to get #include order reasonable. - -1998-07-30 Paul D. Smith - - * make.h: Added MIN/MAX. - * filedef.h: Use them; remove FILE_TIMESTAMP_MIN. - -1998-07-30 Paul Eggert - - Add support for sub-second timestamp resolution on hosts that - support it (just Solaris 2.6, so far). - - * acconfig.h (HAVE_ST_MTIM, uintmax_t): New undefs. - * acinclude.m4 (jm_AC_HEADER_INTTYPES_H, AC_STRUCT_ST_MTIM, - jm_AC_TYPE_UINTMAX_T): New defuns. - * commands.c (delete_target): Convert file timestamp to - seconds before comparing to archive timestamp. Extract mod - time from struct stat using FILE_TIMESTAMP_STAT_MODTIME. - * configure.in (C_STRUCT_ST_MTIM, jm_AC_TYPE_UINTMAX_T): Add. - (AC_CHECK_LIB, AC_CHECK_FUNCS): Add clock_gettime. - * file.c (snap_deps): Use FILE_TIMESTAMP, not time_t. - (file_timestamp_now, file_timestamp_sprintf): New functions. - (print_file): Print file timestamps as FILE_TIMESTAMP, not - time_t. - * filedef.h: Include if available and if HAVE_ST_MTIM. - (FILE_TIMESTAMP, FILE_TIMESTAMP_STAT_MODTIME, FILE_TIMESTAMP_MIN, - FILE_TIMESTAMPS_PER_S, FILE_TIMESTAMP_FROM_S_AND_NS, - FILE_TIMESTAMP_DIV, FILE_TIMESTAMP_MOD, FILE_TIMESTAMP_S, - FILE_TIMESTAMP_NS, FILE_TIMESTAMP_PRINT_LEN_BOUND): New macros. - (file_timestamp_now, file_timestamp_sprintf): New decls. - (struct file.last_mtime, f_mtime, file_mtime_1, NEW_MTIME): - time_t -> FILE_TIMESTAMP. - * implicit.c (pattern_search): Likewise. - * vpath.c (vpath_search, selective_vpath_search): Likewise. - * main.c (main): Likewise. - * remake.c (check_dep, name_mtime, library_search, f_mtime): Likewise. - (f_mtime): Use file_timestamp_now instead of `time'. - Print file timestamp with file_timestamp_sprintf. - * vpath.c (selective_vpath_search): Extract file time stamp from - struct stat with FILE_TIMESTAMP_STAT_MODTIME. - -1998-07-28 Paul D. Smith - - * Version 3.77 released. - - * dosbuild.bat: Change to DOS CRLF line terminators. - - * make-stds.texi: Update from latest version. - - * make.texinfo (Options Summary): Clarify that the -r option - affects only rules, not builtin variables. - -1998-07-27 Paul D. Smith - - * make.h: Make __attribute__ resolve to empty for non-GCC _and_ - for GCC pre-2.5.x. - - * misc.c (log_access): Print UID/GID's as unsigned long int for - maximum portability. - - * job.c (reap_children): Print PIDs as long int for maximum - portability. - -1998-07-24 Eli Zaretskii - - * Makefile.DOS (*_INSTALL, *_UNINSTALL): Replace `true' with `:'. - -1998-07-25 Paul D. Smith - - * Version 3.76.94 released. - -1998-07-23 Paul D. Smith - - * config.h.W32.template: Make sure all the #defines of macros here - have a value (e.g., use ``#define HAVE_STRING_H 1'' instead of - just ``#define HAVE_STRING_H''. Keeps the preprocessor happy in - some contexts. - - * make.h: Remove __attribute__((format...)) stuff; using it with - un-prototyped functions causes older GCC's to fail. - - * Version 3.76.93 released. - -1998-07-22 Paul D. Smith - - * file.c (print_file_data_base): Fix average calculation. - -1998-07-20 Paul D. Smith - - * main.c (die): Postpone the chdir() until after - remove_intermediates() so that intermediate targets with relative - pathnames are removed properly. - -1998-07-17 Paul D. Smith - - * filedef.h (struct file): New flag: did we print an error or not? - - * remake.c (no_rule_error): New function to print error messages, - extraced from remake_file(). - - * remake.c (remake_file): Invoke the new error print function. - (update_file_1): Invoke the error print function if we see that we - already tried this target and it failed, but that an error wasn't - printed for it. This can happen if a file is included with - -include or sinclude and couldn't be built, then later is also - the dependency of another target. Without this change, make just - silently stops :-/. - -1998-07-16 Paul D. Smith - - * make.texinfo: Removed "beta" version designator. - Updated ISBN for the next printing. - -1998-07-13 Paul Eggert - - * acinclude.m4: New AC_LFS macro to determine if special compiler - flags are needed to allow access to large files (e.g., Solaris 2.6). - * configure.in: Invoke it. - -1998-07-08 Eli Zaretskii - - * Makefile.DOS: track changes in Makefile.in. - -1998-07-07 Paul D. Smith - - * remote-cstms.c (start_remote_job): Move gethostbyaddr() to the - top so host is initialized early enough. - - * acinclude.m4: New file. Need some special autoconf macros to - check for network libraries (-lsocket, -lnsl, etc.) when - configuring Customs. - - * configure.in (make_try_customs): Invoke new network libs macro. - -1998-07-06 Paul D. Smith - - * Version 3.76.92 released. - - * README.customs: Added to the distribution. - - * configure.in (make_try_customs): Rewrite to require an installed - Customs library, rather than looking at the build directory. - - * Makefile.am (man_MANS): Install make.1. - * make.1: Renamed from make.man. - - * make.texinfo (Bugs): New mailing list address for GNU make bug - reports. - -1998-07-02 Paul D. Smith - - * Version 3.76.91 released. - - * default.c: Added default rule for new-style RCS master file - storage; ``% :: RCS/%''. - Added default rules for DOS-style C++ files with suffix ".cpp". - They use the new LINK.cpp and COMPILE.cpp macros, which are set by - default to be equal to LINK.cc and COMPILE.cc. - -1998-06-19 Eli Zaretskii - - * job.c (start_job_command): Reset execute_by_shell after an empty - command was skipped. - -1998-06-09 Paul D. Smith - - * main.c (main): Keep track of the temporary filename created when - reading a makefile from stdin (-f-) and attempt to remove it - as soon as we know we're not going to re-exec. If we are, add it - to the exec'd make's cmd line with "-o" so the exec'd make doesn't - try to rebuild it. We still have a hole: if make re-execs then - the temporary file will never be removed. To fix this we'd need - a brand new option that meant "really delete this". - * AUTHORS, getopt.c, getopt1.c, getopt.h, main.c (print_version): - Updated mailing addresses. - -1998-06-08 Paul D. Smith - - * main.c (main): Andreas Luik points out that the - check for makefile :: rules with commands but no dependencies - causing a loop terminates incorrectly. - - * maintMakefile: Make a template for README.DOS to update version - numbers. - -1998-05-30 Andreas Schwab - - * remake.c (update_file_1): Don't free the memory for the - dependency structure when dropping a circular dependency. - -1998-05-30 Eli Zaretskii - - * dir.c (file_exists_p, file_impossible_p, file_impossible) - [__MSDOS__, WINDOWS32]: Retain trailing slash in "d:/", and make - dirname of "d:foo" be "d:". - -1998-05-26 Andreas Schwab - - * read.c (read_makefile): Avoid running past EOS when scanning - file name after `include'. - -1998-05-26 Andreas Schwab - - * make.texinfo (Flavors): Correct description of conditional - assignment, which is not equivalent to ifndef. - (Setting): Likewise. - -1998-05-24 Paul D. Smith - - * arscan.c (ar_name_equal): strncmp() might be implemented as a - macro, so don't put preprocessor conditions inside the arguments - list. - -1998-05-23 Eli Zaretskii - - * read.c (read_makefile) [__MSDOS__, WINDOWS32]: Skip colons in - drive specs when parsing targets, target-specific variables and - static pattern rules. A colon can only be part of drive spec if - it is after the first letter in a token. - -1998-05-22 Eli Zaretskii - - * remake.c (f_mtime) [__MSDOS__]: Allow up to 3 sec of skew before - yelling bloody murder. - - * dosbuild.bat: Use -DINCLUDEDIR= and -DLIBDIR= where appropriate. - - * read.c (parse_file_seq): Combine the special file-handling code - for WINDOWS32 and __MSDOS__ into a single snippet. - (get_next_mword) [__MSDOS__, WINDOWS32]: Allow a word to include a - colon as part of a drive spec. - - * job.c (batch_mode_shell) [__MSDOS__]: Declare. - -1998-05-20 Paul D. Smith - - * Version 3.76.90 released. - -1998-05-19 Paul D. Smith - - * make.texinfo (Make Errors): Added a new appendix describing - common errors make might generate and how to resolve them (or at - least more information on what they mean). - - * maintMakefile (NMAKEFILES): Use the new automake 1.3 feature - to create a dependency file to construct Makefile.DOS, SMakefile, - and NMakefile. - (.dep_segment): Generate the dependency fragment file. - -1998-05-14 Paul D. Smith - - * make.man: Minor changes. - -1998-05-13 Paul D. Smith - - * function.c (pattern_matches,expand_function): Change variables - and types named "word" to something else, to avoid compilation - problems on Cray C90 Unicos. - * variable.h: Modify the function prototype. - -1998-05-11 Rob Tulloh - - * job.c (construct_command_argv_internal) [WINDOWS32]: Turn off - echo when using a batch file, and make sure the command ends in a - newline. - -1998-05-03 Paul D. Smith - - * configure.in (make_try_customs): Add some customs flags if the - user configures custom support. - - * job.c, remote-cstms.c: Merge in changes for custom library. - - * remote-stub.c: Add option to stub start_remote_job_p(). - -1998-05-01 Paul D. Smith - - * remake.c (f_mtime): Install VPATH+ handling for archives; use - the hname field instead of the name field, and rehash when - appropriate. - -1998-04-30 Paul D. Smith - - * rule.c (print_rule_data_base): Print out any pattern-specific - variable values into the rules database. - - * variable.c (print_variable_set): Make this variable extern, to - be called by print_rule_data_base() for pattern-specific variables. - - * make.texinfo (Pattern-specific): Document pattern-specific - variables. - -1998-04-29 Paul D. Smith - - * expand.c (variable_expand_for_file): Make static; its only - called internally. Look up this target in the list of - pattern-specific variables and insert the variable set into the - queue to be searched. - - * filedef.h (struct file): Add a new field to hold the - previously-found pattern-specific variable reference. Add a new - flag to remember whether we already searched for this file. - - * rule.h (struct pattern_var): New structure for storing - pattern-specific variable values. Define new function prototypes. - - * rule.c: New variables pattern_vars and last_pattern_var for - storage and handling of pattern-specific variable values. - (create_pattern_var): Create a new pattern-specific variable value - structure. - (lookup_pattern_var): Try to match a target to one of the - pattern-specific variable values. - -1998-04-22 Paul D. Smith - - * make.texinfo (Target-specific): Document target-specific - variables. - -1998-04-21 Paul D. Smith - - * variable.c (define_variable_in_set): Made globally visible. - (lookup_variable_in_set): New function: like lookup_variable but - look only in a specific variable set. - (target_environment): Use lookup_variable_in_set() to get the - correct export rules for a target-specific variable. - (create_new_variable_set): Create a new variable set, and just - return it without installing it anywhere. - (push_new_variable_scope): Reimplement in terms of - create_new_variable_set. - - * read.c (record_target_var): Like record_files, but instead of - files create a target-specific variable value for each of the - listed targets. Invoked from read_makefile() when the target line - turns out to be a target-specific variable assignment. - -1998-04-19 Paul D. Smith - - * read.c (read_makefile): Rewrite the entire target parsing - section to implement target-specific variables. In particular, we - cannot expand the entire line as soon as it's read in, since we - may want to evaluate parts of it with different variable contexts - active. Instead, start expanding from the beginning until we find - the `:' (or `::'), then determine what kind of line this is and - continue appropriately. - - * read.c (get_next_mword): New function to parse a makefile line - by "words", considering an entire variable or function as one - word. Return the type read in, along with its starting position - and length. - (enum make_word_type): The types of words that are recognized by - get_next_mword(). - - * variable.h (struct variable): Add a flag to specify a per-target - variable. - - * expand.c: Make variable_buffer global. We need this during the - new parsing of the makefile. - (variable_expand_string): New function. Like variable_expand(), - but start at a specific point in the buffer, not the beginning. - (variable_expand): Rewrite to simply call variable_expand_string(). - -1998-04-13 Paul D. Smith - - * remake.c (update_goal_chain): Allow the rebuilding makefiles - step to use parallel jobs. Not sure why this was disabled: - hopefully we won't find out :-/. - -1998-04-11 Paul D. Smith - - * main.c (main): Set the CURDIR makefile variable. - * make.texinfo (Recursion): Document it. - -1998-03-17 Paul D. Smith - - * misc.c (makefile_fatal): If FILE is nil, invoke plain fatal(). - * variable.c (try_variable_definition): Use new feature. - -1998-03-10 Paul D. Smith - - * main.c (main): Don't pass included, rebuilt makefiles to - re-exec'd makes with -o. Reopens a possible loop, but it caused - too many problems. - -1998-03-02 Paul D. Smith - - * variable.c (try_variable_definition): Implement ?=. - * make.texinfo (Setting): Document it. - -1998-02-28 Eli Zaretskii - - * job.c (start_job_command): Reset execute_by_shell after an empty - command, like ":", has been seen. - -Tue Oct 07 15:00:00 1997 Phil Brooks - - * make.h [WINDOWS32]: make case sensitivity configurable - * dir.c [WINDOWS32]: make case sensitivity configurable - * README.W32: Document case sensitivity - * config.ami: Share case warping code with Windows - -Mon Oct 6 18:48:45 CDT 1997 Rob Tulloh - - * w32/subproc/sub_proc.c: Added support for MKS toolkit shell - (turn on HAVE_MKS_SHELL). - * read.c [WINDOWS32]: Fixed a problem with multiple target rules - reported by Gilbert Catipon (gcatipon@tibco.com). If multiple - path tokens in a rule did not have drive letters, make would - incorrectly concatenate the 2 tokens together. - * main.c/variable.c [WINDOWS32]: changed SHELL detection code to - follow what MSDOS did. In addition to watching for SHELL variable - updates, make's main will attempt to default the value of SHELL - before and after makefiles are parsed. - * job.c/job.h [WINDOWS32]: The latest changes made to enable use - of the GNUWIN32 shell from make could cause make to fail due to a - concurrency condition between parent and child processes. Make - now creates a batch file per job instead of trying to reuse the - same singleton batch file. - * job.c/job.h/function.c/config.h.W32 [WINDOWS32]: Renamed macro - from HAVE_CYGNUS_GNUWIN32_TOOLS to BATCH_MODE_ONLY_SHELL. Reworked - logic to reduce complexity. WINDOWS32 now uses the unixy_shell - variable to detect Bourne-shell compatible environments. There is - also a batch_mode_shell variable that determines whether not - command lines should be executed via script files. A WINDOWS32 - system with no sh.exe installed would have unixy_shell set to - FALSE and batch_mode_shell set to TRUE. If you have a unixy shell - that does not behave well when invoking things via 'sh -c xxx', - you may want to turn on BATCH_MODE_ONLY_SHELL and see if things - improve. - * NMakefile: Added /D DEBUG to debug build flags so that unhandled - exceptions could be debugged. - -Mon Oct 6 00:04:25 1997 Rob Tulloh - - * main.c [WINDOWS32]: The function define_variable() does not - handle NULL. Test before calling it to set Path. - * main.c [WINDOWS32]: Search Path again after makefiles have been - parsed to detect sh.exe. - * job.c [WINDOWS32]: Added support for Cygnus GNU WIN32 tools. - To use, turn on HAVE_CYGNUS_GNUWIN32_TOOLS in config.h.W32. - * config.h.W32: Added HAVE_CYGNUS_GNUWIN32_TOOLS macro. - -Sun Oct 5 22:43:59 1997 John W. Eaton - - * glob/glob.c (glob_in_dir) [VMS]: Globbing shouldn't be - case-sensitive. - * job.c (child_execute_job) [VMS]: Use a VMS .com file if the - command contains a newline (e.g. from a define/enddef block). - * vmsify.c (vmsify): Return relative pathnames wherever possible. - * vmsify.c (vmsify): An input string like "../.." returns "[--]". - -Wed Oct 1 15:45:09 1997 Rob Tulloh - - * NMakefile: Changed nmake to $(MAKE). - * subproc.bat: Take the make command name from the command - line. If no command name was given, default to nmake. - * job.c [MSDOS, WINDOWS32]: Fix memory stomp: temporary file names - are now always created in heap memory. - * w32/subproc/sub_proc.c: New implementation of make_command_line() - which is more compatible with different Bourne shell implementations. - Deleted the now obsolete fix_command_line() function. - * main.c [WINDOWS32]: Any arbitrary spelling of Path can be - detected. Make will ensure that the special spelling `Path' is - inserted into the environment when the path variable is propagated - within itself and to make's children. - * main.c [WINDOWS32]: Detection of sh.exe was occurring too - soon. The 2nd check for the existence of sh.exe must come after - the call to read_all_makefiles(). - -Fri Sep 26 01:14:18 1997 - - * makefile.com [VMS]: Fixed definition of sys. - * readme.vms: Comments on what's changed lately. - -Fri Sep 26 01:14:18 1997 John W. Eaton - - * read.c (read_all_makefiles): Allow make to find files named - "MAKEFILE" with no extension on VMS. - * file.c (lookup_file): Lowercase filenames on VMS. - -1997-09-29 Paul D. Smith - - * read.c (read_makefile): Reworked target detection again; the old - version had an obscure quirk. - -Fri Sep 19 09:20:49 1997 Paul D. Smith - - * Version 3.76.1 released. - - * Makefile.am: Add loadavg files to clean rules. - - * configure.in (AC_OUTPUT): Remove stamp-config; no longer needed. - * Makefile.ami (distclean): Ditto. - * SMakefile (distclean): Ditto. - - * main.c (main): Arg count should be int, not char! Major braino. - -Tue Sep 16 10:18:22 1997 Paul D. Smith - - * Version 3.76 released. - -Tue Sep 2 10:07:39 1997 Paul D. Smith - - * function.c (expand_function): When processing $(shell...) - translate a CRLF (\r\n) sequence as well as a newline (\n) to a - space. Also remove an ending \r\n sequence. - * make.texinfo (Shell Function): Document it. - -Fri Aug 29 12:59:06 1997 Rob Tulloh - - * w32/pathstuff.c (convert_Path_to_windows32): Fix problem where - paths which contain single character entries like `.' are not - handled correctly. - - * README.W32: Document path handling issues on Windows systems. - -Fri Aug 29 02:01:27 1997 Paul D. Smith - - * Version 3.75.93. - -Thu Aug 28 19:39:06 1997 Rob Tulloh - - * job.c (exec_command) [WINDOWS32]: If exec_command() is invoked - from main() to re-exec make, the call to execvp() would - incorrectly return control to parent shell before the exec'ed - command could run to completion. I believe this is a feature of - the way that execvp() is implemented on top of WINDOWS32 APIs. To - alleviate the problem, use the supplied process launch function in - the sub_proc library and suspend the parent process until the - child process has run. When the child exits, exit the parent make - with the exit code of the child make. - -Thu Aug 28 17:04:47 1997 Paul D. Smith - - * Makefile.DOS.template (distdir): Fix a line that got wrapped in - email. - - * Makefile.am (loadavg): Give the necessary cmdline options when - linking loadavg. - - * configure.in: Check for pstat_getdynamic for getloadvg on HP. - - * job.c (start_job_command) [VMS, _AMIGA]: Don't perform empty - command optimization on these systems; it doesn't make sense. - -Wed Aug 27 17:09:32 1997 Paul D. Smith - - * Version 3.75.92 - -Tue Aug 26 11:59:15 1997 Paul D. Smith - - * main.c (print_version): Add '97 to copyright years. - - * read.c (do_define): Check the length of the array before looking - at a particular offset. - - * job.c (construct_command_argv_internal): Examine the last byte - of the previous arg, not the byte after that. - -Sat Aug 23 1997 Eli Zaretskii - - * Makefile.DOS.template: New file (converted to Makefile.DOS in - the distribution). - - * configure.bat: Rewrite to use Makefile.DOS instead of editing - Makefile.in. Add support for building from outside of the source - directory. Fail if the environment block is too small. - - * configh.dos: Use . - - * README.DOS: Update instructions. - -Fri Aug 22 1997 Eli Zaretskii - - * job.c (start_job_command) [__MSDOS__]: Don't test for "/bin/sh" - literally, use value of unixy_shell instead. - - * filedef.h (NEW_MTIME): Use 1 less than maximum possible value if - time_t is unsigned. - -Sat Aug 16 00:56:15 1997 John W. Eaton - - * vmsify.c (vmsify, case 11): After translating `..' elements, set - nstate to N_OPEN if there are still more elements to process. - (vmsify, case 2): After translating `foo/bar' up to the slash, - set nstate to N_OPEN, not N_DOT. - -Fri Aug 8 15:18:09 1997 John W. Eaton - - * dir.c (vmsstat_dir): Leave name unmodified on exit. - * make.h (PATH_SEPARATOR_CHAR): Set to comma for VMS. - * vpath.c: Fix comments to refer to path separator, not colon. - (selective_vpath_search): Avoid Unixy slash handling for VMS. - -Thu Aug 7 22:24:03 1997 John W. Eaton - - * ar.c [VMS]: Don't declare ar_member_touch. - Delete VMS version of ar_member_date. - Enable non-VMS versions of ar_member_date and ar_member_date_1 for - VMS too. - * arscan.c (VMS_get_member_info): New function. - (ar_scan): Provide version for VMS systems. - (ar_name_equal): Simply compare name and mem on VMS systems. - Don't define ar_member_pos or ar_member_touch on VMS systems. - - * config.h-vms (pid_t, uid_t): Don't define. - - * remake.c: Delete declaration of vms_stat. - (name_mtime): Don't call vms_stat. - (f_mtime) [VMS]: Funky time value manipulation no longer necessary. - - * file.c (print_file): [VMS] Use ctime, not cvt_time. - - * make.h [VMS]: Don't define POSIX. - - * makefile.com (filelist): Include ar and arscan. - Also include them in the link commands. - Don't define NO_ARCHIVES in cc command. - - * makefile.vms (ARCHIVES, ARCHIVES_SRC): Uncomment. - (defines): Delete NO_ARCHIVES from list. - - * remake.c (f_mtime): Only check to see if intermediate file is - out of date if it also exists (i.e., mtime != (time_t) -1). - - * vmsdir.h (u_long, u_short): Skip typedefs if using DEC C. - -Fri Jun 20 23:02:07 1997 Rob Tulloh - - * w32/subproc/sub_proc.c: Get W32 sub_proc to handle shebang - (#!/bin/sh) in script files correctly. - Fixed a couple of memory leaks. - Fixed search order in find_file() (w32/subproc/sub_proc.c) so that - files with extensions are preferred over files without extensions. - Added search for files with .cmd extension too. - * w32/subproc/misc.c (arr2envblk): Fixed memory leak. - -Mon Aug 18 09:41:08 1997 Paul D. Smith - - * Version 3.75.91 - -Fri Aug 15 13:50:54 1997 Paul D. Smith - - * read.c (do_define): Remember to count the newline after the endef. - -Thu Aug 14 23:14:37 1997 Paul D. Smith - - * many: Rewrote builds to use Automake 1.2. - - * AUTHORS: New file. - * maintMakefile: Contains maintainer-only make snippets. - * GNUmakefile: This now only runs the initial auto* tools. - * COPYING,texinfo.tex,mkinstalldirs,install-sh: Removed (obtained - automatically by automake). - * compatMakefile: Removed (not needed anymore). - * README,build.sh.in: Removed (built from templates). - * config.h.in,Makefile.in: Removed (built by tools). - -Wed Aug 13 02:22:08 1997 Paul D. Smith - - * make.texinfo: Updates for DOS/Windows information (Eli Zaretskii) - * README,README.DOS: Ditto. - - * remake.c (update_file_1,f_mtime): Fix GPATH handling. - * vpath.c (gpath_search): Ditto. - - * file.c (rename_file): New function: rehash, but also rename to - the hashname. - * filedef.h: Declare it. - - * variable.c (merge_variable_set_lists): Remove free() of variable - set; since various files can share variable sets we don't want to - free them here. - -Tue Aug 12 10:51:54 1997 Paul D. Smith - - * configure.in: Require autoconf 2.12 - - * make.texinfo: Replace all "cd subdir; $(MAKE)" examples with a - more stylistically correct "cd subdir && $(MAKE)". - - * main.c: Global variable `clock_skew_detected' defined. - (main): Print final warning if it's set. - * make.h: Declare it. - * remake.c (f_mtime): Test and set it. - - * job.c (start_job_command): Add special optimizations for - "do-nothing" rules, containing just the shell no-op ":". This is - useful for timestamp files and can make a real difference if you - have a lot of them (requested by Fergus Henderson ). - - * configure.in,Makefile.in: Rewrote to use the new autoconf - program_transform_name macro. - - * function.c (function_strip): Strip newlines as well as spaces - and TABs. - -Fri Jun 6 23:41:04 1997 Rob Tulloh - - * remake.c (f_mtime): Datestamps on FAT-based files are rounded to - even seconds when stored, so if the date check fails on WINDOWS32 - systems, see if this "off-by-one" error is the problem. - - * General: If your TZ environment variable is not set correctly - then all your timestamps will be off by hours. So, set it! - -Mon Apr 7 02:06:22 1997 Paul D. Smith - - * Version 3.75.1 - - * compatMakefile (objs): Define & use the $(GLOB) variable so - that it's removed correctly from build.sh.in when it's built. - - * configure.in: On Solaris we can use the kstat_*() functions to - get load averages without needing special permissions. Add a - check for -lkstat to see if we have it. - - * getloadavg.c (getloadavg): Use HAVE_LIBKSTAT instead of SUN5 as - the test to enable kstat_open(), etc. processing. - -Fri Apr 4 20:21:18 1997 Eli Zaretskii - - * : Fixes to work in the DJGPP DOS environment. - -Mon Mar 31 02:42:52 1997 Paul D. Smith - - * function.c (expand_function): Added new function $(wordlist). - - * make.texinfo (Filename Functions): Document $(wordlist) function. - - * vpath.c (build_vpath_lists): Construct the GPATH variable - information in the same manner we used to construct VPATH. - (gpath_search): New function to search GPATH. - - * make.h: Declare the new function. - - * remake.c (update_file_1): Call it, and keep VPATH if it's found. - - * make.texinfo (Search Algorithm): Document GPATH variable. - -Sun Mar 30 20:57:16 1997 Paul D. Smith - - * main.c (handle_non_switch_argument): Defined the MAKECMDGOALS - variable to contain the user options passed in on the cmd line. - - * make.texinfo (Goals): Document MAKECMDGOALS variable. - - * remake.c (f_mtime): Print a warning if we detect a clock skew - error, rather than failing. - - * main.c (main): If we rebuild any makefiles and need to re-exec, - add "-o" options for each makefile rebuilt to avoid - infinite looping. - -Fri Mar 28 15:26:05 1997 Paul D. Smith - - * job.c (construct_command_argv_internal): Track whether the last - arg in the cmd string was empty or not (Roland). - (construct_command_argv_internal): If the shell line is empty, - don't do anything (Roland). - - * glob/glob.h,glob/glob.c,glob/fnmatch.c,glob/fnmatch.h: Install - the latest changes from the GLIBC version of glob (Ulrich Drepper). - - * getloadavg.c,make-stds.texi: New version (Roland). - - * (ALL): Changed WIN32 to W32 or WINDOWS32 (RMS). - -Mon Mar 24 15:33:34 1997 Rob Tulloh - - * README.W32: Describe preliminary FAT support. - - * build_w32.bat: Use a variable for the final exe name. - - * dir.c (find_directory): W32: Find the filesystem type. - (dir_contents_file_exists_p): W32: for FAT filesystems, always - rehash since FAT doesn't change directory mtime on change. - - * main.c (handle_runtime_exceptions): W32: Add an - UnhandledExceptionFilter so that when make bombs due to ^C or a - bug, it won't cause a GUI requestor to pop up unless debug is - turned on. - (main): Call it. - -Mon Mar 24 00:57:34 1997 Paul D. Smith - - * configure.in, config.h.in, config.ami, config.h-vms, config.h.w32: - Check for memmove() function. - - * make.h (bcopy): If memmove() available, define bcopy() to use it. - Otherwise just use bcopy(). Don't use memcpy(); it's not guaranteed - to handle overlapping moves. - - * read.c (read_makefile): Fix some uninitialized memory reads - (reported by Purify). - - * job.c (construct_command_argv_internal): Use bcopy() not - strcpy(); strcpy() isn't guaranteed to handle overlapping moves. - - * Makefile.in: Change install-info option ``--infodir'' to - ``--info-dir'' for use with new texinfo. - - * function.c (expand_function): $(basename) and $(suffix) should - only search for suffixes as far back as the last directory (e.g., - only the final filename in the path). - -Sun Mar 23 00:13:05 1997 Paul D. Smith - - * make.texinfo: Add @dircategory/@direntry information. - (Top): Remove previous reference to (dir) (from RMS). - (Static Usage): Add "all:" rule to example. - (Automatic Dependencies): fix .d file creation example. - - * Install VPATH+ patch: - - * filedef.h (struct file): Add in hname field to store the hashed - filename, and a flag to remember if we're using the vpath filename - or not. Renamed a few functions for more clarity. - - * file.c (lookup_file,enter_file,file_hash_enter): Store filenames - in the hash table based on their "hash name". We can change this - while keeping the original target in "name". - (rehash_file): Renamed from "rename_file" to be more accurate. - Changes the hash name, but not the target name. - - * remake.c (update_file_1): Modify -d output for more detailed - VPATH info. If we don't need to rebuild, use the VPATH name. - (f_mtime): Don't search for vpath if we're ignoring it. Call - renamed function rehash_file. Call name_mtime instead of - file_mtime, to avoid infinite recursion since the file wasn't - actually renamed. - - * implicit.c (pattern_search): if we find an implicit file in - VPATH, save the original name not the VPATH name. - - * make.texinfo (Directory Search): Add a section on the new VPATH - functionality. - -Sun Dec 1 18:36:04 1996 Andreas Schwab - - * dir.c (file_exists_p, file_impossible, file_impossible_p): If - dirname is empty replace it by the name of the root directory. - Note that this doesn't work (yet) for W32, Amiga, or VMS. - -Tue Oct 08 13:57:03 1996 Rob Tulloh - - * main.c (main): W32 bug fix for PATH vars. - -Tue Sep 17 1996 Paul Eggert - - * filedef.h (NEW_MTIME): Don't assume that time_t is a signed - 32-bit quantity. - - * make.h: (CHAR_BIT, INTEGER_TYPE_SIGNED, INTEGER_TYPE_MAXIMUM, - INTEGER_TYPE_MINIMUM): New macros. - -Tue Aug 27 01:06:34 1996 Roland McGrath - - * Version 3.75 released. - - * main.c (print_version): Print out bug-reporting address. - -Mon Aug 26 19:55:47 1996 Roland McGrath - - * main.c (print_data_base): Don't declare ctime; headers do it for us - already. - -Sun Jul 28 15:37:09 1996 Rob Tulloh (tulloh@tivoli.com) - - * w32/pathstuff.c: Turned convert_vpath_to_w32() into a - real function. This was done so that VPATH could contain - white space separated pathnames. Please note that directory - paths (in VPATH/vpath context) containing white space are not - supported (just as they are not under Unix). See README.W32 - for suggestions. - - * w32/include/pathstuff.h: Added prototype for the new - function convert_vpath_to_w32. Deleted macro for same. - - * README.W32: Added some notes about why I chose not to try - and support pathnames which contain white space and some - workaround suggestions. - -Thu Jul 25 19:53:31 1996 Roland McGrath - - * GNUmakefile (mkdep-nolib): Use -MM option unconditionally. - - * Version 3.74.7. - - * main.c (define_makeflags): Back up P to point at null terminator - when killing final space and dash before setting MFLAGS. - - From Robert Hoehne : - * dir.c [__MSDOS__ && DJGPP > 1]: Include and defin - `__opendir_flags' initialized to 0. - (dosify) [__MSDOS__ && DJGPP > 1]: Return name unchanged if _USE_LFN. - (find_directory) [__MSDOS__ && DJGPP > 1]: If _USE_LGN, set - __opendir_flags to __OPENDIR_PRESERVE_CASE. - - * vmsfunctions.c (vms_stat): `sys$dassgn (DevChan);' added by kkaempf. - - * GNUmakefile (w32files): Add NMakefile. - - * NMakefile (LDFLAGS_debug): Value fixed by tulloh. - -Sat Jul 20 12:32:10 1996 Klaus Kämpf (kkaempf@progis.de) - - * remake.c (f_mtime) [VMS]: Add missing `if' conditional for future - modtime check. - * config.h-vms, makefile.vms, readme.vms, vmsify.c: Update address. - -Sat Jul 20 05:29:43 1996 Roland McGrath - - * configure.in: Require autoconf 2.10 or later. - -Fri Jul 19 16:57:27 1996 Roland McGrath - - * Version 3.74.6. - - * GNUmakefile (w32files): New variable. - (distfiles): Add it. - * w32: Updated by Rob Tulloh. - - * makefile.vms (LOADLIBES): Fix typo. - -Sun Jul 14 12:59:27 1996 Roland McGrath - - * job.c (construct_command_argv_internal): Fix up #else, #endifs. - - * configh.dos: Define HAVE_DIRENT_H instead of DIRENT. - - * remake.c (f_mtime): Don't compare MTIME to NOW if MTIME == -1. - - * Version 3.74.5. - - * main.c (main): Exit with status 2 when update_goal_chain returns 2. - -Sat Jun 22 14:56:05 1996 Roland McGrath - - * configure.in: Don't check for _sys_siglist. - * make.h [HAVE__SYS_SIGLIST]: Don't test this; just punt if there is - no strsignal or sys_siglist. - - * read.c (conditional_line): Strip ws in `ifeq (a , b)' so it is the - same as `ifeq (a, b)'. - - * job.c (reap_children): Don't call die if handling_fatal_signal. - - * file.c (file_hash_enter): Allow renaming :: to : when latter is - non-target, or : to :: when former is non-target. - - * job.c (start_job_command): Call block_sigs. - (block_sigs): New function, broken out of start_job_command. - (reap_children): Block fatal signals around removing dead child from - chain and adjusting job_slots_used. - * job.h: Declare block_sigs. - - * remote-stub.c (remote_setup, remote_cleanup): New (empty) functions. - * main.c (main): Call remote_setup. - (die): Call remote_cleanup. - - * job.c (reap_children): Quiescent value of shell_function_pid is - zero, not -1. - - * main.c (print_version): Add 96 to copyright years. - -Sat Jun 15 20:30:01 1996 Andreas Schwab - - * read.c (find_char_unquote): Avoid calling strlen on every call - just to throw away the value most of the time. - -Sun Jun 2 12:24:01 1996 Roland McGrath - - * main.c (decode_env_switches): Prepend '-' to ARGV[1] if it contains - no '=', regardless of ARGC. - (define_makeflags): Elide leading '-' from MAKEFLAGS value if first - word is short option, regardless of WORDS. - -Wed May 22 17:24:51 1996 Roland McGrath - - * makefile.vms: Set LOADLIBES. - * makefile.com (link_using_library): Fix typo. - -Wed May 15 17:37:26 1996 Roland McGrath - - * dir.c (print_dir_data_base): Use %ld dev and ino and cast them to - long. - -Wed May 15 10:14:14 CDT 1996 Rob Tulloh - - * dir.c: W32 does not support inode. For now, fully qualified - pathname along with st_mtime will be keys for files. - Fixed problem where vpath can be confused when files - are added to a directory after the directory has already been - read in. The code now attempts to reread the directory if it - discovers that the datestamp on the directory has changed since - it was cached by make. This problem only seems to occur on W32 - right now so it is lumped under port #ifdef WINDOWS32. - - * function.c: W32: call subproc library (CreateProcess()) instead of - fork/exec. - - * job.c: W32: Added the code to do fork/exec/waitpid style processing - on W32 systems via calls to subproc library. - - * main.c: W32: Several things added here. First, there is code - for dealing with PATH and SHELL defaults. Make tries to figure - out if the user has %PATH% set in the environment and sets it to - %Path% if it is not set already. Make also looks to see if sh.exe - is anywhere to be found. Code path through job.c will change - based on existence of a working Bourne shell. The checking for - default shell is done twice: once before makefiles are read in - and again after. Fall back to MSDOS style execution mode if no sh.exe - is found. Also added some debug support that allows user to pause make - with -D switch and attach a debugger. This is especially useful for - debugging recursive calls to make where problems appear only in the - sub-make. - - * make.h: W32: A few macros and header files for W32 support. - - * misc.c: W32: Added a function end_of_token_w32() to assist - in parsing code in read.c. - - * read.c: W32: Fixes similar to MSDOS which allow colon to - appear in filenames. Use of colon in filenames would otherwise - confuse make. - - * remake.c: W32: Added include of io.h to eliminate compiler - warnings. Added some code to default LIBDIR if it is not set - on W32. - - * variable.c: W32: Added support for detecting Path/PATH - and converting them to semicolon separated lists for make's - internal use. New function sync_Path_environment() - which is called in job.c and function.c before creating a new - process. Caller must set Path in environment since we don't - have fork() to do this for us. - - * vpath.c: W32: Added detection for filenames containing - forward or backward slashes. - - * NMakefile: W32: Visual C compatible makefile for use with nmake. - Use this to build GNU make the first time on Windows NT or Windows 95. - - * README.W32: W32: Contains some helpful notes. - - * build_w32.bat: W32: If you don't like nmake, use this the first - time you build GNU make on Windows NT or Windows 95. - - * config.h.W32: W32 version of config.h - - * subproc.bat: W32: A bat file used to build the - subproc library from the top-level NMakefile. Needed because - WIndows 95 (nmake) doesn't allow you to cd in a make rule. - - * w32/include/dirent.h - * w32/compat/dirent.c: W32: opendir, readdir, closedir, etc. - - * w32/include/pathstuff.h: W32: used by files needed functions - defined in pathstuff.c (prototypes). - - * w32/include/sub_proc.h: W32: prototypes for subproc.lib functions. - - * w32/include/w32err.h: W32: prototypes for w32err.c. - - * w32/pathstuff.c: W32: File and Path/Path conversion functions. - - * w32/subproc/build.bat: W32: build script for subproc library - if you don't wish to use nmake. - - * w32/subproc/NMakefile: W32: Visual C compatible makefile for use - with nmake. Used to build subproc library. - - * w32/subproc/misc.c: W32: subproc library support code - * w32/subproc/proc.h: W32: subproc library support code - * w32/subproc/sub_proc.c: W32: subproc library source code - * w32/subproc/w32err.c: W32: subproc library support code - -Mon May 13 14:37:42 1996 Roland McGrath - - * Version 3.74.4. - - * GNUmakefile (vmsfiles): Fix typo. - - * GNUmakefile (amigafiles): Add amiga.h. - -Sun May 12 19:19:43 1996 Aaron Digulla - - * dir.c: New function: amigafy() to fold filenames - Changes HASH() to HASHI() to fold filenames on Amiga. - Stringcompares use strieq() instead of streq() - The current directory on Amiga is "" instead of "." - * file.c: Likewise. - - * amiga.c: New function wildcard_expansion(). Allows to use - Amiga wildcards with $(wildcard ) - - * amiga.h: New file. Prototypes for amiga.c - - * function.c: Use special function wildcard_expansion() for - $(wildcard ) to allow Amiga wildcards - The current directory on Amiga is "" instead of "." - - * job.c: No Pipes on Amiga, too - (load_too_high) Neither on Amiga - ENV variable on Amiga are in a special directory and are not - passed as third argument to main(). - - * job.h: No envp on Amiga - - * make.h: Added HASHI(). This is the same as HASH() but converts - it's second parameter to lowercase on Amiga to fold filenames. - - * main.c: (main), variable.c Changed handling of ENV-vars. Make - stores now the names of the variables only and reads their contents - when they are accessed to reflect that these variables are really - global (ie. they CAN change WHILE make runs !) This handling is - made in lookup_variable() - - * Makefile.ami: renamed file.h to filedep.h - Updated dependencies - - * read.c: "find_semicolon" is declared as static but never defined. - No difference between Makefile and makefile on Amiga; added - SMakefile to *default_makefiles[]. - (read_makefile) SAS/C want's two_colon and pattern_percent be set - before use. - The current directory on Amiga is "" instead of "." - Strange #endif moved. - - * README.Amiga: updated feature list - - * SMakefile: Updated dependencies - - * variable.c: Handling of ENV variable happens inside lookup_variable() - -Sat May 11 17:58:32 1996 Roland McGrath - - * variable.c (try_variable_definition): Count parens in lhs variable - refs to avoid seeing =/:=/+= inside a ref. - -Thu May 9 13:54:49 1996 Roland McGrath - - * commands.c (fatal_error_signal) [SIGQUIT]: Make SIGQUIT check - conditional. - - * main.c (main): Use unsigned for fread return. - - * read.c (parse_file_seq): Use `int' for char arg to avoid widening - conflict issues. - * dep.h: Fix prototype. - - * function.c (expand_function) [_AMIGA]: Fix some typos. - (patsubst_expand): Make len vars unsigned. - - * GNUmakefile (globfiles): Add AmigaDOS support files. - (distfiles): Add $(amigafiles). - (amigafiles): New variable. - -Thu Nov 7 10:18:16 1995 Aaron Digulla - - * Added Amiga support in commands.c, dir.c, function.c, - job.c, main.c, make.h, read.c, remake.c - * commands.c: Amiga has neither SIGHUP nor SIGQUIT - * dir.c: Amiga has filenames with Upper- and Lowercase, - but "FileName" is the same as "filename". Added strieq() - which is use to compare filenames. This is like streq() - on all other systems. Also there is no such thing as - "." under AmigaDOS. - * function.c: On Amiga, the environment is not passed as envp, - there are no pipes and Amiga can't fork. Use my own function - to create a new child. - * job.c: default_shell is "" (The system automatically chooses - a shell for me). Have to use the same workaround as MSDOS for - running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't - known on Amiga. Cloned code to run children from MSDOS. Own - version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga. - * main.c: Force stack to 20000 bytes. Read environment from ENV: - device. On Amiga, exec_command() does return, so I exit() - afterwards. - * make.h: Added strieq() to compare filenames. - * read.c: Amiga needs special extension to have passwd. Only - one include-dir. "Makefile" and "makefile" are the same. - Added "SMakefile". Added special code to handle device names (xxx:) - and "./" in rules. - * remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib" - instead of "lib%s.a". - * main.c, rule.c, variable.c: Avoid floats at all costs. - * vpath.c: Get rid of as many alloca()s as possible. - -Thu May 9 13:20:43 1996 Roland McGrath - - * read.c (read_makefile): Grok `sinclude' as alias for `-include'. - -Wed Mar 20 09:52:27 1996 Roland McGrath - - * GNUmakefile (vmsfiles): New variable. - (distfiles): Include $(vmsfiles). - -Tue Mar 19 20:21:34 1996 Roland McGrath - - Merged VMS port from Klaus Kaempf . - * make.h (PARAMS): New macro. - * config.h-vms: New file. - * makefile.com: New file. - * makefile.vms: New file. - * readme.vms: New file. - * vmsdir.h: New file. - * vmsfunctions.c: New file. - * vmsify.c: New file. - * file.h: Renamed to filedef.h to avoid conflict with VMS system hdr. - * ar.c: Added prototypes and changes for VMS. - * commands.c: Likewise. - * commands.h: Likewise. - * default.c: Likewise. - * dep.h: Likewise. - * dir.c: Likewise. - * expand.c: Likewise. - * file.c: Likewise. - * function.c: Likewise. - * implicit.c: Likewise. - * job.c: Likewise. - * job.h: Likewise. - * main.c: Likewise. - * make.h: Likewise. - * misc.c: Likewise. - * read.c: Likewise. - * remake.c: Likewise. - * remote-stub.c: Likewise. - * rule.c: Likewise. - * rule.h: Likewise. - * variable.c: Likewise. - * variable.h: Likewise. - * vpath.c: Likewise. - * compatMakefile (srcs): Rename file.h to filedef.h. - -Sat Aug 19 23:11:00 1995 Richard Stallman - - * remake.c (check_dep): For a secondary file, try implicit and - default rules if appropriate. - -Wed Aug 2 04:29:42 1995 Richard Stallman - - * remake.c (check_dep): If an intermediate file exists, - do consider its actual date. - -Sun Jul 30 00:49:53 1995 Richard Stallman - - * file.h (struct file): New field `secondary'. - * file.c (snap_deps): Check for .INTERMEDIATE and .SECONDARY. - (remove_intermediates): Don't delete .SECONDARY files. - -Sat Mar 2 16:26:52 1996 Roland McGrath - - * compatMakefile (srcs): Add getopt.h; prepend $(srcdir)/ to getopt*. - -Fri Mar 1 12:04:47 1996 Roland McGrath - - * Version 3.74.3. - - * remake.c (f_mtime): Move future modtime check before FILE is - clobbered by :: loop. - - * dir.c: Use canonical code from autoconf manual for dirent include. - [_D_NAMLEN]: Redefine NAMLEN using this. - (dir_contents_file_exists_p): Use NAMLEN macro. - (read_dirstream) [_DIRENT_HAVE_D_NAMLEN]: Only set d_namlen #if this. - - * compatMakefile (objs): Add missing backslash. - -Wed Feb 28 03:56:20 1996 Roland McGrath - - * default.c (default_terminal_rules): Remove + prefix from RCS cmds. - (default_variables): Put + prefix in $(CHECKOUT,v) value instead. - - * remake.c (f_mtime): Check for future timestamps; give error and mark - file as "failed to update". - -Fri Jan 12 18:09:36 1996 Roland McGrath - - * job.c: Don't declare unblock_sigs; job.h already does. - -Sat Jan 6 16:24:44 1996 Roland McGrath - - * acconfig.h (HAVE_SYSCONF_OPEN_MAX): #undef removed. - - * job.c (NGROUPS_MAX): Don't try to define this macro. - -Fri Dec 22 18:44:44 1995 Roland McGrath - - * compatMakefile (GETOPT, GETOPT_SRC, GLOB): Variables removed. - (objs, srcs): Include their values here instead of references. - -Thu Dec 14 06:21:29 1995 Roland McGrath - - * Version 3.74.2. - - * job.c (reap_children): Call unblock_sigs after start_job_command. - -Thu Dec 14 07:22:03 1995 Roland McGrath - - * dir.c (dir_setup_glob): Don't use lstat; glob never calls it anyway. - Avoid & before function names to silence bogus sunos4 compiler. - - * configure.in: Remove check for `sysconf (_SC_OPEN_MAX)'. - -Tue Dec 12 00:48:42 1995 Roland McGrath - - * Version 3.74.1. - - * dir.c (read_dirstream): Fix braino: fill in the buffer when not - reallocating it! - -Mon Dec 11 22:26:15 1995 Roland McGrath - - * misc.c (collapse_continuations): Fix skipping of trailing \s so - it can never dereference before the beginning of the array. - - * read.c (find_semicolon): Function removed. - (read_makefile): Don't use find_semicolon or remove_comments for - rule lines. Use find_char_unquote directly and handle quoted comments - properly. - - * default.c: Remove all [M_XENIX] code. - - * dir.c [HAVE_D_NAMLEN]: Define this for __GNU_LIBRARY__ > 1. - (D_NAMLEN): Macro removed. - (FAKE_DIR_ENTRY): New macro. - (dir_contents_file_exists_p): Test HAVE_D_NAMLEN instead of using - D_NAMLEN. - (read_dirstream): Return a struct dirent * for new glob interface. - (init_dir): Function removed. - (dir_setup_glob): New function. - * main.c (main): Don't call init_dir. - * read.c (multi_glob): Call dir_setup_glob on our glob_t and use - GLOB_ALTDIRFUNC flag. - - * misc.c (safe_stat): Function removed. - * read.c, commands.c, remake.c, vpath.c: Use plain stat instead of - safe_stat. - -Sat Nov 25 20:35:18 1995 Roland McGrath - - * job.c [HAVE_UNION_WAIT]: Include sys/wait.h. - - * main.c (log_working_directory): Made global. - Print entering msg only once. - * make.h (log_working_directory): Declare it. - * misc.c (message): Take new arg PREFIX. Print "make: " only if - nonzero. Call log_working_directory. - * remake.c: Pass new arg in `message' calls. - * job.c (start_job_command): Pass new arg to `message'; fix - inverted test in that call. - -Tue Nov 21 19:01:12 1995 Roland McGrath - - * job.c (start_job_command): Use `message' to print the command, - and call it with null if the command is silent. - * remake.c (touch_file): Use message instead of printf. - -Tue Oct 10 14:59:30 1995 Roland McGrath - - * main.c (enter_command_line_file): Barf if NAME is "". - -Sat Sep 9 06:33:20 1995 Roland McGrath - - * commands.c (delete_target): Ignore unlink failure if it is ENOENT. - -Thu Aug 17 15:08:57 1995 Roland McGrath - - * configure.in: Don't check for getdtablesize. - * job.c (getdtablesize): Remove decls and macros. - -Thu Aug 10 19:10:03 1995 Roland McGrath - - * main.c (define_makeflags): Omit command line variable - definitions from MFLAGS value. - - * arscan.c (ar_scan) [AIAMAG]: Check for zero MEMBER_OFFSET, - indicating a valid, but empty, archive. - -Mon Aug 7 15:40:03 1995 Roland McGrath - - * dir.c (file_impossible_p): Correctly reset FILENAME to name - within directory before hash search. - - * job.c (child_error): Do nothing if IGNORED under -s. - - * job.c (exec_command): Correctly use ARGV[0] for script name when - running shell directly. - -Tue Aug 1 14:39:14 1995 Roland McGrath - - * job.c (child_execute_job): Close STDIN_FD and STDOUT_FD after - dup'ing from them. Don't try to close all excess descriptors; - getdtablesize might return a huge value. Any open descriptors in - the parent should have FD_CLOEXEC set. - (start_job_command): Set FD_CLOEXEC flag on BAD_STDIN descriptor. - -Tue Jun 20 03:47:15 1995 Roland McGrath - - * read.c (read_all_makefiles): Properly append default makefiles - to the end of the `read_makefiles' chain. - -Fri May 19 16:36:32 1995 Roland McGrath - - * Version 3.74 released. - -Wed May 10 17:43:34 1995 Roland McGrath - - * Version 3.73.3. - -Tue May 9 17:15:23 1995 Roland McGrath - - * compatMakefile ($(infodir)/make.info): Make sure $$dir is set in - install-info cmd. - -Wed May 3 15:56:06 1995 Roland McGrath - - * file.c (print_file): Grok update_status of 1 for -q. - -Thu Apr 27 12:39:35 1995 Roland McGrath - - * Version 3.73.2. - -Wed Apr 26 17:15:57 1995 Roland McGrath - - * file.c (remove_intermediates): Fix inverted test to bail under - -n for signal case. Bail under -q or -t. - Skip files with update_status==-1. - - * job.c (job_next_command): Skip empty lines. - (new_job): Don't test the return of job_next_command. - Just let start_waiting_job handle the case of empty commands. - -Wed Apr 19 03:25:54 1995 Roland McGrath - - * function.c [__MSDOS__]: Include . From DJ Delorie. - - * Version 3.73.1. - -Sat Apr 8 14:53:24 1995 Roland McGrath - - * remake.c (notice_finished_file): Set FILE->update_status to zero - if it's -1. - -Wed Apr 5 00:20:24 1995 Roland McGrath - - * Version 3.73 released. - -Tue Mar 28 13:25:46 1995 Roland McGrath - - * main.c (main): Fixed braino in assert. - - * Version 3.72.13. - -Mon Mar 27 05:29:12 1995 Roland McGrath - - * main.c: Avoid string in assert expression. Some systems are broken. - -Fri Mar 24 00:32:32 1995 Roland McGrath - - * main.c (main): Handle 1 and 2 returns from update_goal_chain - makefile run properly. - - * Version 3.72.12. - - * main.c (handle_non_switch_argument): New function, broken out of - decode_switches. - (decode_switches): Set optind to 0 to reinitialize getopt, not to 1. - When getopt_long returns EOF, break the loop and handle remaining args - with a simple second loop. - - * remake.c (remake_file): Set update_status to 2 instead of 1 for - no rule to make. Mention parent (dependent) in error message. - (update_file_1): Handle FILE->update_status == 2 in -d printout. - * job.c (start_job_command, reap_children): Set update_status to 2 - instead of 1 for failed commands. - -Tue Mar 21 16:23:38 1995 Roland McGrath - - * job.c (search_path): Function removed (was already #if 0'd out). - * configure.in: Remove AC_TYPE_GETGROUPS; nothing needs it any more. - -Fri Mar 17 15:57:40 1995 Roland McGrath - - * configure.bat: Write @CPPFLAGS@ translation. - -Mon Mar 13 00:45:59 1995 Roland McGrath - - * read.c (parse_file_seq): Rearranged `l(a b)' -> `l(a) l(b)' loop - to not skip the elt immediately preceding `l(...'. - -Fri Mar 10 13:56:49 1995 Roland McGrath - - * Version 3.72.11. - - * read.c (find_char_unquote): Make second arg a string of stop - chars instead of a single stop char. Stop when any char in the - string is hit. All callers changed. - (find_semicolon): Pass stop chars "#;" to one find_char_unquote call, - instead of using two calls. If the match is not a ; but a #, - return zero. - * misc.c: Changed find_char_unquote callers here too. - - * Version 3.72.10. - - * read.c (read_makefile, parse_file_seq): Fix typo __MS_DOS__ -> - __MSDOS__. - - * GNUmakefile (globfiles): Add glob/configure.bat. - (distfiles): Add configh.dos, configure.bat. - -Wed Mar 8 13:10:57 1995 Roland McGrath - - Fixes for MS-DOS from DJ Delorie. - * read.c (read_makefile, parse_file_seq) [__MS_DOS__]: Don't see : - as separator in "C:\...". - * configh.dos (STDC_HEADERS): Define only if undefined. - (HAVE_SYS_PARAM_H): Don't define this. - (HAVE_STRERROR): Define this. - * job.c (construct_command_argv_internal) [__MSDOS__]: Fix typos. - - * Version 3.72.9. - - * main.c (decode_switches): Reset optind to 1 instead of 0. - -Tue Mar 7 17:31:06 1995 Roland McGrath - - * main.c (decode_switches): If non-option arg is "-", ignore it. - -Mon Mar 6 23:57:38 1995 Roland McGrath - - * Version 3.72.8. - -Wed Feb 22 21:26:36 1995 Roland McGrath - - * Version 3.72.7. - -Tue Feb 21 22:10:43 1995 Roland McGrath - - * main.c (main): Pass missing arg to tmpnam. - - * configure.in: Check for strsignal. - * job.c (child_error): Use strsignal. - * main.c (main): Don't call signame_init #ifdef HAVE_STRSIGNAL. - - * misc.c (strerror): Fix swapped args in sprintf. - -Mon Feb 13 11:50:08 1995 Roland McGrath - - * configure.in (CFLAGS, LDFLAGS): Don't set these variables. - -Fri Feb 10 18:44:12 1995 Roland McGrath - - * main.c (print_version): Add 95 to copyright years. - - * Version 3.72.6. - - * job.c (start_job_command): Remember to call notice_finished_file - under -n when not recursing. To do this, consolidate that code - under the empty command case and goto there for the -n case. - -Tue Feb 7 13:36:03 1995 Roland McGrath - - * make.h [! STDC_HEADERS]: Don't declare qsort. Sun headers - declare it int. - -Mon Feb 6 17:37:01 1995 Roland McGrath - - * read.c (read_makefile): For bogus line starting with tab, ignore - it if blank after removing comments. - - * main.c: Cast results of `alloca' to `char *'. - * expand.c: Likewise. - -Sun Feb 5 18:35:46 1995 Roland McGrath - - * Version 3.72.5. - - * configure.in: Check for mktemp. - * main.c (main) [! HAVE_MKTEMP]: Use tmpnam instead of mktemp. - - * configure.in (make_cv_sysconf_open_max): New check for `sysconf - (_SC_OPEN_MAX)'. - * acconfig.h: Added #undef HAVE_SYSCONF_OPEN_MAX. - * job.c [HAVE_SYSCONF_OPEN_MAX] (getdtablesize): Define as macro - using sysconf. - -Fri Jan 27 04:42:09 1995 Roland McGrath - - * remake.c (update_file_1): When !MUST_MAKE, don't set - FILE->update_status to zero before calling notice_finished_file. - (notice_finished_file): Touch only when FILE->update_status is zero. - (remake_file): Set FILE->update_status to zero after not calling - execute_file_command and deciding to touch instead. - -Thu Jan 26 01:29:32 1995 Roland McGrath - - * main.c (debug_signal_handler): New function; toggles debug_flag. - (main): Handle SIGUSR1 with that. - -Mon Jan 16 15:46:56 1995 Roland McGrath - - * compatMakefile (realclean): Remove Info files. - -Sun Jan 15 08:23:09 1995 Roland McGrath - - * Version 3.72.4. - - * job.c (start_job_command): Save and restore environ around vfork - call. - (search_path): Function #if 0'd out. - (exec_command): Use execvp instead of search_path. - - * expand.c (variable_expand): Rewrote computed variable name and - substitution reference handling to be simpler. First expand the - entire text between the parens if it contains any $s, then examine - the result of that for subtitution references and do no further - expansion while parsing them. - - * job.c (construct_command_argv_internal): Handle " quoting too, - when no backslash, $ or ` characters appear inside the quotes. - - * configure.in (union wait check): If WEXITSTATUS and WTERMSIG are - defined, just use int. - -Tue Jan 10 06:27:27 1995 Roland McGrath - - * default.c (default_variables) [__hpux]: Remove special - definition of ARFLAGS. Existence of the `f' flag is not - consistent across HPUX versions; and one might be using GNU ar - anyway. - - * compatMakefile (clean): Don't remove Info files. - - * compatMakefile (check): Remove gratuitous target declaration. - -Sat Jan 7 11:38:23 1995 Roland McGrath - - * compatMakefile (ETAGS, CTAGS): Don't use -t. - - * arscan.c (ar_name_equal) [cray]: Subtract 1 like [__hpux]. - - * main.c (decode_switches): For --help, print usage to stdout. - -Mon Dec 5 12:42:18 1994 Roland McGrath - - * Version 3.72.3. - - * remake.c (update_file_1): Do set_command_state (FILE, - cs_not_started) only if old state was deps_running. - -Mon Nov 28 14:24:03 1994 Roland McGrath - - * job.c (start_waiting_job): Use set_command_state. - - * build.template (CPPFLAGS): New variable. - (prefix, exec_prefix): Set from @...@. - (compilation loop): Pass $CPPFLAGS to compiler. - - * GNUmakefile (build.sh.in): Make it executable. - - * GNUmakefile (globfiles): Add configure.in, configure. - - * Version 3.72.2. - - * configure.in (AC_OUTPUT): Don't write glob/Makefile. - - * configure.in (AC_CHECK_SYMBOL): Use AC_DEFINE_UNQUOTED. - - * configure.in: Don't check for ranlib. - -Tue Nov 22 22:42:40 1994 Roland McGrath - - * remake.c (notice_finished_file): Only mark also_make's as - updated if really ran cmds. - -Tue Nov 15 06:32:46 1994 Roland McGrath - - * configure.in: Put dnls before random whitespace. - -Sun Nov 13 05:02:25 1994 Roland McGrath - - * compatMakefile (CPPFLAGS): New variable, set from @CPPFLAGS@. - (RANLIB): Variable removed. - (prefix, exec_prefix): Set these from @...@. - (.c.o): Use $(CPPFLAGS). - (glob/libglob.a): Don't pass down variables to sub-make. - glob/Makefile should be configured properly by configure. - (distclean): Remove config.log and config.cache (autoconf stuff). - -Mon Nov 7 13:58:06 1994 Roland McGrath - - * acconfig.h: Add #undef HAVE_UNION_WAIT. - * configure.in: Converted to Autoconf v2. - * dir.c: Test HAVE_DIRENT_H, HAVE_SYS_DIR_H, HAVE_NDIR_H instead - of DIRENT, SYSDIR, NDIR. - * build.sh.in (prefix, exec_prefix): Set these from @...@. - (CPPFLAGS): New variable, set from @CPPFLAGS@. - (compiling loop): Pass $CPPFLAGS before $CFLAGS. - * install.sh: File renamed to install-sh. - - * main.c (define_makeflags): When no flags, set WORDS to zero. - -Sun Nov 6 18:34:01 1994 Roland McGrath - - * Version 3.72.1. - - * main.c (define_makeflags): Terminate properly when FLAGSTRING is - empty. - -Fri Nov 4 16:02:51 1994 Roland McGrath - - * Version 3.72. - -Tue Nov 1 01:18:10 1994 Roland McGrath - - * Version 3.71.5. - - * job.c (start_job_command): When ARGV is nil, only set - update_state and call notice_finished_file if job_next_command - returns zero. - - * job.c (start_job_command): Call notice_finished_file for empty - command line. - -Thu Oct 27 02:02:45 1994 Roland McGrath - - * file.c (snap_deps): Set COMMANDS_SILENT for .SILENT, not - COMMANDS_NOERROR. - -Wed Oct 26 02:14:10 1994 Roland McGrath - - * Version 3.71.4. - -Tue Oct 25 22:49:24 1994 Roland McGrath - - * file.c (snap_deps): Set command_flags bits in all :: entries. - -Mon Oct 24 18:47:50 1994 Roland McGrath - - * make.h (posix_pedantic): Declare it. - * main.c (main): Move checks .IGNORE, .SILENT, .POSIX to - snap_deps. - * file.c (snap_deps): Check .IGNORE, .SILENT, .POSIX here instead - of in main. If .IGNORE has deps, OR COMMANDS_NOERROR into their - command_flags and don't set -i. Likewise .SILENT. - * job.c (start_job_command): In FLAGS initialization, OR in - CHILD->file->command_flags. - * file.h (struct file): New member `command_flags'. - -Sun Oct 16 01:01:51 1994 Roland McGrath - - * main.c (switches): Bump flag values for --no-print-directory and - --warn-undefined-variables, so neither is 1 (which indicates a - nonoption argument). - -Sat Oct 15 23:39:48 1994 Roland McGrath - - * main.c (main): Add missing code in .IGNORE test. - -Mon Oct 10 04:09:03 1994 Roland McGrath - - * variable.c (define_automatic_variables): Define +D and +F. - -Sat Oct 1 04:07:48 1994 Roland McGrath - - * main.c (main): Define hidden automatic variable with command - vars, and MAKEOVERRIDES to a reference to that. - (define_makeflags): If posix_pedantic, write a reference to that - instead. - -Thu Sep 29 00:14:26 1994 Roland McGrath - - * main.c (posix_pedantic): New variable. - (main): Set posix_pedantic if .POSIX is a target. - Fix .IGNORE and .SILENT checks to require is_target. - - * commands.c (set_file_variables): Define new automatic variable - $+, like $^ but before calling uniquize_deps. - - * job.c (reap_children): Call delete_child_targets for non-signal - error if .DELETE_ON_ERROR is a target. - -Tue Sep 27 01:57:14 1994 Roland McGrath - - * Version 3.71.3. - -Mon Sep 26 18:16:55 1994 Roland McGrath - - * job.c (reap_children): Don't change C->file->command_state when - dying. Test it only after calling start_job_command for a new - command line. When no more cmds, just set C->file->update_status. - (start_job_command): When the last line is empty or under -n, set - C->file->update_status. - (start_waiting_job): Grok cs_not_started after start_job_command - as success. - (new_job): Set C->file->update_status when there are no cmds. - (job_next_command): When out of lines, don't set - CHILD->file->update_status or CHILD->file->command_state. - - * main.c (quote_as_word): Renamed from shell_quote. Take new arg; - if nonzero, also double $s. - (main): Define MAKEOVERRIDES from command_variables here. - (define_makeflags): Don't use command_variables here; instead write a - reference $(MAKEOVERRIDES) in MAKEFLAGS. Make vars recursive. - - * dir.c [__MSDOS__]: Fixed typo. - - * vpath.c (selective_vpath_search): Reset EXISTS when stat fails. - -Sat Sep 10 03:01:35 1994 Roland McGrath - - * remake.c: Include and use assert instead of printfs - and abort. - - * main.c (decode_switches): Loop until optind hits ARGC, not just - until getopt_long returns EOF. Initialize C to zero before loop; - in loop if C is EOF, set optarg from ARGV[optind++], else call - getopt_long. - (decode_env_switches): Use variable_expand instead of - allocated_variable_expand. Allocate a fresh buffer to copy split - words into; scan characters by hand to break words and - debackslashify. - (shell_quote): New function. - (define_makeflags): Allocate doubled space for switch args, and command - variable names and values; use shell_quote to quote those things. - -Fri Sep 9 01:37:47 1994 Roland McGrath - - * Version 3.71.2. - - * acconfig.h: Add HAVE_SYS_SIGLIST and HAVE__SYS_SIGLIST. - - * main.c (decode_switches): The non-option return from getopt is - 1, not 0. - (command_variables): New type and variable. - (decode_switches, decode_env_switches): After making a variable - definition, record the struct variable pointer in the - command_variables chain. - (define_makeflags): If ALL, write variable definitions for - command_variables. - - * main.c (other_args): Variable removed. - (goals, lastgoal): New static variables (moved from auto in main). - (main): Don't process OTHER_ARGS at all. - Don't set variable MAKEOVERRIDES at all; define MAKE to just - $(MAKE_COMMAND). - (init_switches): Prepend a - {return in order} instead of a + - {require order}. - (decode_switches): Don't set OTHER_ARGS at all. - Grok '\0' return from getopt_long as non-option argument; try - variable definition and (if !ENV) enter goal targets here. - (decode_env_switches): Use allocated_variable_expand to store value. - Use find_next_token to simplify word-splitting loop. Don't - prepend a dash to uninterpreted value. Instead, if split into - only one word, try variable definition and failing that prepend a - dash to the word and pass it to decode_switches as a single arg. - -Wed Sep 7 03:02:46 1994 Roland McGrath - - * remake.c (notice_finished_file): Only recheck modtimes if - FILE->command_state was cs_running on entry (meaning the commands - actually just ran). - (update_file_1): Whenever we set FILE->update_status, call - notice_finished_file instead of just set_command_state. - * job.c (start_job_command): Whenever we set - CHILD->file->update_status, call notice_finished_file instead of - just set_command_state. - -Tue Sep 6 19:13:54 1994 Roland McGrath - - * default.c: Add missing ". - - * job.c: Changed all assignments of command_state members to calls - to set_command_state. - * remake.c: Likewise. - * file.c (set_command_state): New function. - * file.h: Declare set_command_state. - - * main.c (init_switches): Put a + first in options. - -Mon Jul 25 18:07:46 1994 Roland McGrath - - Merge MSDOS/GO32 port from DJ Delorie . - * vpath.c: Changed all uses of ':' to PATH_SEPARATOR_CHAR. - * main.c (directory_before_chdir): New variable, moved out of main - (was local). - (main) [__MSDOS__]: Look for \ or : to delimit last component of - PROGRAM. Don't frob ARGV[0] before setting MAKE_COMMAND variable. - (die): Change back to `directory_before_chdir' before dying. - * make.h (PATH_SEPARATOR_CHAR): New macro; differing defns for - [__MSDOS__] and not. - * job.c [__MSDOS__]: Include . - [__MSDOS__] (dos_pid, dos_status, dos_bname, dos_bename, - dos_batch_file): New variables. - (reap_children) [__MSDOS__]: Don't call wait; just examine those vars. - (unblock_sigs) [__MSDOS__]: Do nothing. - (start_job_command) [__MSDOS__]: Use spawnvpe instead of vfork & exec. - (load_too_high) [__MSDOS__]: Always return true. - (search_path) [__MSDOS__]: Check for : or / in FILE to punt. - Use PATH_SEPARATOR_CHAR instead of ':'. - (construct_command_argv_internal) [__MSDOS__]: Wholly different - values for sh_chars and sh_cmds. Wholly new code to handle shell - scripts. - * function.c (expand_function: `shell') [__MSDOS__]: Wholly new - implementation. - * dir.c [__MSDOS__] (dosify): New function. - (dir_contents_file_exists_p) [__MSDOS__]: Call it on FILENAME and - process the result instead of FILENAME itself. - (file_impossible_p) [__MSDOS__]: Likewise. - * default.c [__MSDOS__]: Define GCC_IS_NATIVE. - (default_suffix_rules) [__MSDOS__]: Use `y_tab.c' instead of `y.tab.c'. - (default_variables) [GCC_IS_NATIVE]: Set CC and CXX to `gcc', YACC to - `bison -y', and LEX to `flex'. - * configure.bat, configh.dos: New files. - * commands.c (fatal_error_signal) [__MSDOS__]: Just remove - intermediates and exit. - - * commands.c (set_file_variables): Add parens in length - computation in .SUFFIXES dep loop to quiet compiler warning. From - Jim Meyering. - - * read.c (read_makefile): Free FILENAME if we allocated it. From - Jim Meyering. - -Mon Jul 4 17:47:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * misc.c (safe_stat): New function, EINTR-safe wrapper around stat. - * vpath.c (selective_vpath_search): Use safe_stat in place of stat. - * read.c (construct_include_path): Use safe_stat in place of stat. - * job.c (search_path): Use safe_stat in place of stat. - * dir.c (find_directory): Use safe_stat in place of stat. - * commands.c (delete_target): Use safe_stat in place of stat. - * arscan.c (ar_member_touch) [EINTR]: Do EINTR looping around fstat. - * remake.c (name_mtime): Use safe_stat in place of stat. - (touch_file) [EINTR]: Do EINTR looping around fstat. - -Fri Jun 24 05:40:24 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Check for a shell command first, and - then strip leading tabs before further checking if it's not a - shell command line. - - * make.h [__arm]: Undefine POSIX. - [!__GNU_LIBRARY__ && !POSIX && !_POSIX_VERSION]: Don't declare system - functions that return int. - - * job.c (construct_command_argv_internal): After swallowing a - backslash-newline combination, if INSTRING is set goto string_char - (new label) for normal INSTRING handling code. - -Sat Jun 4 01:11:20 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * configure.in: Don't check for sys_siglist and _sys_siglist with - AC_HAVE_FUNCS. Instead use two AC_COMPILE_CHECKs. - -Mon May 23 18:20:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.71.1 released. - - * make.h [!__GNU_LIBRARY__ && !POSIX]: Also test #ifndef - _POSIX_VERSION for these declarations. - - * misc.c [GETLOADAVG_PRIVILEGED] [POSIX]: Remove bogus #ifndefs - around #undefs of HAVE_SETREUID and HAVE_SETREGID. - -Sat May 21 16:26:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.71 released. - - * misc.c [GETLOADAVG_PRIVILEGED] [POSIX]: Don't test [HAVE_SETUID] - and [HAVE_SETGID]. Every system has those, and configure doesn't - check for them. - - * make.h [_POSIX_VERSION]: Don't #define POSIX #ifdef ultrix. - - * compatMakefile (loadavg): Depend on and use loadavg.c instead of - getloadavg.c. - (loadavg.c): Link or copy it from getloadavg.c. - (distclean): Remove loadavg.c. - -Mon May 16 22:59:04 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.70.4. - - * misc.c [GETLOADAVG_PRIVILEGED] [! POSIX]: Undefine HAVE_SETEUID - and HAVE_SETEGID. - - * default.c (default_terminal_rules): In SCCS rules, put - $(SCCS_OUTPUT_OPTION) before $<. On some systems -G is grokked - only before the file name. - * configure.in (SCCS_GET_MINUS_G check): Put -G flag before file name. - -Tue May 10 16:27:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Swallow - backslash-newline combinations inside '' strings too. - -Thu May 5 04:15:10 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (do_define): Call collapse_continuations on each line - before all else. - -Mon Apr 25 19:32:02 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Notice newline inside - '' string when RESTP is non-null. - -Fri Apr 22 17:33:30 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.70.3. - - * remake.c (update_goal_chain): Reset FILE to G->file after the - double-colon loop so it is never null for following code. - - * read.c (read_makefile): Fix `override define' parsing to skip - whitespace after `define' properly. - - * compatMakefile (srcdir): Define as @srcdir@; don't reference - $(VPATH). - (glob/Makefile): New target. - -Thu Apr 21 16:16:55 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.70.2. - - * misc.c (remove_comments): Use find_char_unquote. - * make.h (find_char_unquote): Declare it. - * read.c (find_char_unquote): New function, generalized from - find_percent. - (find_percent, find_semicolon, parse_file_seq): Use that. - -Wed Apr 20 18:42:39 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * implicit.c (pattern_search): Always allocate new storage for - FILE->stem. It is not safe to store STEM's address because it - might be auto storage. - - * configure.in: Check for seteuid and setegid. - * misc.c [HAVE_SETEUID]: Declare seteuid. - [HAVE_SETEGID]: Declare setegid. - (make_access, user_access) [HAVE_SETEUID]: Use seteuid. - [HAVE_SETEGID]: Use setegid. - - * remake.c (update_goal_chain): Set STATUS to FILE->update_status, - to preserve whether it's 2 for error or 1 for -q trigger. When - STATUS gets nonzero and -q is set, always stop immediately. - * main.c (main, decode_switches): Die with 2 for errors. - (main): Accept 2 return from update_goal_chain and die with that. - * misc.c (fatal, makefile_fatal): Die with 2; 1 is reserved for -q - answer. - * job.c (reap_children): Die with 2 for error. - (start_job_command): Set update_status to 2 for error. Set it to - 1 when we would run a command and question_flag is set. - - * read.c (read_makefile): Don't mark makefiles as precious. Just - like other targets, they can be left inconsistent and in need of - remaking by aborted commands. - - * read.c (read_makefile): Write no error msg for -include file. - -Tue Apr 5 05:22:19 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * commands.c (fatal_error_signal): Don't unblock signals. - - * file.h (struct file): Change member `double_colon' from flag to - `struct file *'. - * read.c (record_files): Set double_colon pointer instead of flag. - * main.c (main): When disqualifying makefiles for updating, use - double_colon pointer to find all entries for a file. - * file.c (enter_file): If there is already a double-colon entry - for the file, set NEW->double_colon to that pointer. - (file_hash_enter): Use FILE->double_colon to find all entries to - set name. - * remake.c (update_goal_chain): Do inner loop on double-colon entries. - (update_file): Use FILE->double_colon pointer to find all entries. - (f_mtime): Likewise. - (notice_finished_file): Propagate mtime change to all entries. - - * variable.c (try_variable_definition): Return after abort. - -Fri Apr 1 18:44:15 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Remove unused variable. - (parse_file_seq): When removing an elt that is just `)', properly - fix up the previous elt's next pointer. - -Mon Mar 28 18:31:49 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) - - * configure.in: Do AC_SET_MAKE. - * GNUmakefile (Makefile.in): Edit MAKE assignment into @SET_MAKE@. - -Fri Mar 4 00:02:32 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * function.c (subst_expand): If BY_WORD or SUFFIX_ONLY is set and - the search string is the empty string, find a match at the end of - each word (using end_of_token in place of sindex). - - * misc.c (end_of_token): Don't treat backslashes specially; you - can no longer escape blanks with backslashes in export, unexport, - and vpath. This was never documented anyway. - -Thu Mar 3 23:53:46 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Variable name for `define' is not just - first token; use whole rest of line and strip trailing blanks. - -Wed Feb 16 16:03:45 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.70.1. - - * read.c (read_makefile): Add -d msg stating args. - - * read.c (read_makefile): Use isspace to skip over leading - whitespace, and explicitly avoid skipping over tabs. Don't want - to skip just spaces though; formfeeds et al should be skipped. - - * default.c (default_variables) [__hpux]: Add f in ARFLAGS. - - * arscan.c (ar_name_equal) [__hpux]: Subtract 2 instead of 1 from - sizeof ar_name for max length to compare. - - * misc.c [GETLOADAVG_PRIVILEGED] [POSIX]: Undefine HAVE_SETREUID - #ifdef HAVE_SETUID; likewise HAVE_SETREGID and HAVE_SETGID. - - * main.c (main): Call user_access after setting `program', in case - it needs to use it in an error message. - - * read.c (read_makefile): Ignore an empty line starting with a tab. - -Thu Feb 10 21:45:31 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in (AC_SYS_SIGLIST_DECLARED): Use this instead of - AC_COMPILE_CHECK that is now its contents. - -Fri Feb 4 16:28:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.h: #undef strerror after #include . - [! ANSI_STRING]: Declare strerror. - -Thu Feb 3 02:21:22 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * misc.c (strerror): #undef any macro before function definition. - -Mon Jan 31 19:07:23 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * variable.c (try_variable_definition): Calculate BEG before loop - to strip blanks by decrementing END. Don't decr END to before BEG. - - * read.c (read_makefile): Skip over leading space characters, but - not tabs, after removing continuations and comments (it used to - use isspace). - -Tue Jan 25 16:45:05 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * variable.c (define_automatic_variables): In $(@D) et al, use - patsubst to remove trailing slash. - - * commands.c (delete_target): New function, broken out of - delete_child_targets. Check for archive members and give special msg. - (delete_child_targets): Use delete_target. - -Mon Jan 17 17:03:22 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * default.c (default_suffix_rules): Use $(TEXI2DVI_FLAGS) in - texi2dvi rules. Use $(MAKEINFO_FLAGS) in makeinfo rules. - -Tue Jan 11 19:29:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * GNUmakefile (tarfiles): Omit make-doc. - (make-$(version).tar): Include make.info*. - -Fri Jan 7 16:27:00 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (configure, config.h.in): Comment out rules. - -Thu Jan 6 18:08:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (binprefix, manprefix): New variables. - (instname): Variable removed. - (install): Use $({bin,man}prefix)make in place of $(instname). - File targets likewised renamed. - -Mon Jan 3 17:50:25 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.70 released. - -Thu Dec 23 14:46:54 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.69.3. - - * read.c (parse_file_seq): Inside multi-word archive ref - translation loop, check NEW1==0 at end and break out of the loop. - - * GNUmakefile (make-$(version).tar): Distribute install.sh. - * install.sh: New file. - - * configure.in (SCCS_GET_MINUS_G check): Put redirection for admin - cmds outside subshell parens, to avoid "command not found" msgs - from the shell. - -Wed Dec 22 17:00:43 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in (SCCS_GET_MINUS_G check): Put -G flag last in get cmd. - Redirect output & error from get to /dev/null. - Fix reversed sense of test. - -Fri Dec 17 15:31:36 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in (SCCS_GET_MINUS_G check): Use parens instead of - braces inside if condition command; some shells lose. - -Thu Dec 16 15:10:23 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.69.2. - - * arscan.c [M_UNIX]: Move #undef M_XENIX for PORTAR stuff. - (PORTAR) [M_XENIX]: Define to 0 instead of 1. - - * main.c (define_makeflags): Only export MAKEFLAGS if !ALL. - -Wed Dec 15 17:47:48 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (main): Cast result of pointer arith to unsigned int - before passing to define_variable for envars. Matters when - sizeof(unsigned)!=sizeof(ptrdiff_t). - -Tue Dec 14 14:21:16 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in: Add new check for SCCS_GET_MINUS_G. - * config.h.in: Add #undef SCCS_GET_MINUS_G. - * default.c (default_terminal_rules): Use `$(SCCS_OUTPUT_OPTION)' in - place of `-G $@' in SCCS commands. - (default_variables) [SCCS_GET_MINUS_G]: Define SCCS_OUTPUT_OPTION - to "-G$@". - - * configure.in (AC_OUTPUT): Put touch stamp-config in second arg - (so it goes in config.status), rather than afterward. - - * ar.c (ar_member_date): Don't call enter_file on the archive file - if it doesn't exist (by file_exists_p). - - * compatMakefile ($(infodir)/make.info): Replace `$$d/foo.info' - with `$$dir/make.info' in install-info invocation (oops). - - * vpath.c (construct_vpath_list): Only set LASTPATH set PATH when - we do not unlink and free PATH. - - * file.c (print_file_data_base): Fix inverted calculation for - average files per hash bucket. - - * read.c (readline): When we see a NUL, give only a warning and - synthesize a newline to terminate the building line (used to - fatal). Move fgets call into the loop condition, and after the - loop test ferror (used to test !feof in the loop). - -Fri Dec 3 16:40:31 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in: Check for strerror in AC_HAVE_FUNCS. - -Thu Dec 2 15:37:50 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - Differentiate different flavors of missing makefile error msgs, - removing gratuitous `fopen: ' and giving caller for included makefiles. - * misc.c [! HAVE_STRERROR]: Define our own strerror here. - (perror_with_name, pfatal_with_name): Use strerror instead of - replicating its functionality. - * read.c (read_makefile): Return int instead of void. - (read_all_makefiles, read_makefile): Change callers to notice zero - return and give error msg. - -Thu Nov 11 11:47:36 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.69.1. - - * default.c: Put `-G $@' before $< in SCCS cmds. - -Wed Nov 10 06:06:14 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): After trying a variable defn, notice if - the line begins with a tab, and diagnose an error. - -Sun Nov 7 08:07:37 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.69. - -Wed Nov 3 06:54:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.10. - - * implicit.c (try_implicit_rule): Look for a normal rule before an - archive rule. - -Fri Oct 29 16:45:28 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * function.c (expand_function: `sort'): Double NWORDS when it - overflows, instead of adding five. - - * compatMakefile (clean): Remove loadavg. - -Wed Oct 27 17:58:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.9. - - * file.h (NEW_MTIME): Define new macro. - * main.c (main): Set time of NEW_FILES to NEW_MTIME, not to - current time returned from system. Removed variable NOW. - * remake.c (notice_finished_file): Use NEW_MTIME in place of - current time here too. - -Tue Oct 26 19:45:35 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.8. - - * remake.c (update_file_1): Don't clear MUST_MAKE when FILE has no - cmds and !DEPS_CHANGED unless also !NOEXIST. - -Mon Oct 25 15:25:21 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (parse_file_seq): When converting multi-word archive - refs, ignore a word beginning with a '('. - -Fri Oct 22 02:53:38 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in: Check for sys/timeb.h. - * make.h [HAVE_SYS_TIMEB_H]: Test this before including it. - -Thu Oct 21 16:48:17 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.7. - - * rule.c (convert_suffix_rule): New local TARGPERCENT. Set it to - TARGNAME+1 for "(%.o)", to TARGNAME for "%.?". Use it in place of - TARGNAME to initialize PERCENTS[0]. - -Mon Oct 18 06:49:35 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in: Use AC_HAVE_HEADERS(unistd.h) instead of AC_UNISTD_H. - Remove AC_USG; it is no longer used. - - * file.c (print_file): New function, broken out of - print_file_data_base. - (print_file_data_base): Call it. - * rule.c (print_rule): New function, broken out of - print_rule_data_base. - (print_rule_data_base): Call it. - -Thu Oct 14 14:54:03 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * default.c (install_default_suffix_rules): New function, broken - out of install_default_implicit_rules. - (install_default_implicit_rules): Move suffix rule code there. - * make.h: Declare install_default_suffix_rules. - * main.c (main): Call install_default_suffix_rules before reading - makefiles. Move convert_to_pattern call before - install_default_implicit_rules. - - * job.h (struct child): Make `pid' member type `pid_t' instead of - `int'. - - * compatMakefile (RANLIB): New variable, set by configure. - (glob/libglob.a): Pass RANLIB value down to submake. - - Fixes for SCO 3.2 "devsys 4.2" from pss@tfn.com (Peter Salvitti). - * make.h: Include before for SCO lossage. - * job.c [! getdtablesize] [! HAVE_GETDTABLESIZE]: If NOFILE is not - defined but NOFILES_MAX is, define it to be that. - -Mon Oct 11 19:47:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * GNUmakefile (make-$(version).tar): Depend on acconfig.h, so it - is distributed. - -Sun Oct 3 15:15:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * default.c (default_terminal_rules): Add `-G $@' to SCCS get cmds. - -Tue Sep 28 14:18:20 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Add ^ to SH_CHARS; it - is another symbol for | in some shells. - * main.c (main): Add it to CMD_DEFS quoting list as well. - -Mon Sep 20 18:05:24 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Remove '=' from - SH_CHARS. Only punt on '=' if it is unquoted in a word before the - first word without an unquoted '='. - - * main.c (define_makeflags): Set v_export for MAKEFLAGS. - -Fri Sep 17 00:37:18 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * remake.c (update_file_1): Use .DEFAULT cmds for phony targets. - - * make.h [_AIX && _POSIX_SOURCE]: Define POSIX. - - * commands.c (delete_child_targets): Don't delete phony files. - - * job.c (start_job_command): Set COMMANDS_RECURSE in FLAGS if we - see a `+' at the beginning of the command line. - -Thu Sep 9 17:57:14 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.6. - -Wed Sep 8 20:14:21 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (define_makeflags): Define MAKEFLAGS with o_file, not o_env. - -Mon Aug 30 12:31:58 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * expand.c (variable_expand): Fatal on an unterminated reference. - -Thu Aug 19 16:27:53 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.5. - - * variable.c (define_automatic_variables): Define new o_default - variable `MAKE_VERSION' from version_string and remote_description. - - * make.h (version_string, remote_description): Declare these here. - * main.c: Don't declare version_string. - (print_version): Don't declare remote_description. - -Wed Aug 18 15:01:24 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Free space pointed to by CONDITIONALS - before restoring the old pointer. - -Mon Aug 16 17:33:36 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile ($(objs)): Depend on config.h. - - * GNUmakefile (build.sh.in): Depend on compatMakefile. - - * configure.in: Touch stamp-config after AC_OUTPUT. - -Fri Aug 13 16:04:22 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.4. - -Thu Aug 12 17:18:57 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.h: Include instead of "config.h". - -Wed Aug 11 02:35:25 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (main): Make all variables interned from ENVP be v_export. - * variable.c (try_variable_definition): In v_default case, don't - check for an o_file variable that `getenv' finds. - - * job.c (reap_children): New local variable ANY_LOCAL; set it - while setting ANY_REMOTE. If !ANY_LOCAL, don't wait for local kids. - - * main.c (main): Don't call decode_env_switches on MFLAGS. DOC THIS. - - * function.c (expand_function): #if 0 out freeing of ENVP since it - is environ. - -Mon Aug 9 17:37:20 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.3. - - * remote-stub.c (remote_status): Set errno to ECHILD before return. - * job.c (reap_children): Scan the chain for remote children and - never call remote_status if there are none. - - * function.c (expand_function: `shell'): #if 0 out calling - target_environment; just set ENVP to environ instead. - - * job.c (reap_children): Check for negative return from - remote_status and fatal for it. - When blocking local child wait returns 0, then try a blocking call - to remote_status. - -Tue Aug 3 00:19:00 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (clean): Delete make.info* and make.dvi here. - (distclean): Not here. - - * dep.h (RM_*): Use #defines instead of enum to avoid lossage from - compilers that don't like enum values used as ints. - -Mon Aug 2 16:46:34 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (loadavg): Add $(LOADLIBES). - -Sun Aug 1 16:01:15 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.2. - - * compatMakefile (loadavg, check-loadavg): New targets. - (check): Depend on check-loadavg. - - * compatMakefile (glob/libglob.a): Depend on config.h. - - * misc.c (log_access): Write to stderr instead of stdout. - -Fri Jul 30 00:07:02 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68.1. - -Thu Jul 29 23:26:40 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in (SYS_SIGLIST_DECLARED): In test program include - #ifdef HAVE_UNISTD_H. - - * compatMakefile (.PHONY): Put after `all' et al. - - * configure.in: Add AC_IRIX_SUN. - -Wed Jul 28 17:41:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.68. - -Mon Jul 26 14:36:49 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.8. - -Sun Jul 25 22:09:08 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.7. - - * compatMakefile ($(infodir)/make.info): Don't use $(instname). - Run install-info script if present. - -Fri Jul 23 16:03:50 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.h [STAT_MACROS_BROKEN]: Test this instead of [uts]. - - * configure.in: Add AC_STAT_MACROS_BROKEN. - -Wed Jul 14 18:48:11 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.6. - - * read.c (read_makefile): Recognize directive `-include', like - `include' but sets RM_DONTCARE flag. - - * variable.c (target_environment): If FILE is nil, use - current_variable_set_list in place of FILE->variables. - * function.c (expand_function: `shell'): Get an environment for - the child from target_environment instead of using environ. - - * dep.h: Declare read_all_makefiles here. - (RM_*): Define new enum constants. - * read.c (read_makefile): Second arg is FLAGS instead of TYPE. - Treat it as a bit mask containing RM_*. - (read_all_makefiles): For default makefiles, set D->changed to - RM_DONTCARE instead of 1. - * main.c: Don't declare read_all_makefiles here. - (main): Check `changed' member of read_makefiles elts for RM_* - flags instead of specific integer values. - -Mon Jul 12 22:42:17 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.h [sequent && i386]: #undef POSIX. From trost@cse.ogi.edu. - -Thu Jul 8 19:51:23 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * vpath.c (construct_vpath_list): If ELEM is zero 0, free PATTERN - as well as VPATH. - (build_vpath_lists): Empty `vpaths' around construct_vpath_list - call for $(VPATH). Expand $(strip $(VPATH)), not just $(VPATH). - - * rule.c (convert_suffix_rule): Use alloca instead of xmalloc for - PERCENTS, whose storage is not consumed by create_pattern_rule. - - * make.h [__mips && _SYSTYPE_SVR3]: #undef POSIX. - -Wed Jun 30 18:11:40 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.5. - - * rule.c (max_pattern_targets): New variable. - (count_implicit_rule_limits): Compute its value. - * rule.h: Declare it. - * implicit.c (pattern_search): Make TRYRULES max_target_patterns - times bigger. Move adding new TRYRULES elt inside the inner - targets loop, so each matching target gets its own elt in MATCHES - and CHECKED_LASTSLASH. - - * file.c (remove_intermediates): If SIG!=0 say `intermediate file' - instead of just `file' in error msg. - -Fri Jun 25 14:55:15 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv): Turn off - --warn-undefined-variables around expansion of SHELL and IFS. - * read.c (tilde_expand): Likewise for HOME. - (read_all_makefiles): Likewise for MAKEFILES. - * vpath.c (build_vpath_lists): Likewise for VPATH. - - * main.c (warn_undefined_variables_flag): New flag variable. - (switches): Add --warn-undefined-variables. - * make.h (warn_undefined_variables_flag): Declare it. - * expand.c (warn_undefined): New function. - (reference_variable): Call it if the variable is undefined. - (variable_expand): In substitution ref, call warn_undefined if the - variable is undefined. - - * default.c (default_pattern_rules): Add `%.c: %.w %.ch' and - `%.tex: %.w %.ch' rules. - (default_suffix_rules: .w.c, .w.tex): Pass three args: $< - $@. - (default_suffixes): Add `.ch'. - -Mon Jun 21 17:55:39 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * default.c (default_suffixes): Replace `.cweb' with `.w'. - (default_suffix_rules): Rename `.cweb.c' and `.cweb.tex' to `.w.c' - and `.w.tex'. - -Fri Jun 11 14:42:09 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile ($(bindir)/$(instname)): Add missing backslash. - -Thu Jun 10 18:14:08 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.4. - - * read.c (multi_glob): Don't free OLD and OLD->name in the - FOUND!=0 fork. Use new block-local variable F instead of - clobbering OLD. - - * ar.c (glob_pattern_p): New function, snarfed from glob/glob.c. - (ar_glob): Call it; return nil immediately if MEMBER_PATTERN - contains no metacharacters. - -Wed Jun 9 16:25:35 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * ar.c (ar_glob{_match,_alphacompare}): New function. - - * dep.h [! NO_ARCHIVES]: Declare it. - * read.c (multi_glob) [! NO_ARCHIVES]: Use it on archive member elts. - - * read.c (read_makefile): Pass flag (1) to parse_file_seq, not to - multi_glob (which doesn't take a 3rd arg). - * rule.c (install_pattern_rule): Likewise. - * default.c (set_default_suffixes): Here too. - * function.c (string_glob): Don't pass gratuitous arg to multi_glob. - - * read.c (parse_file_seq) [! NO_ARCHIVES]: Add post-processing - loop to translate archive refs "lib(a b)" into "lib(a) lib(b)". - -Mon Jun 7 19:26:51 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (installdirs): Actually pass directory names. - ($(bindir)/$(instname)): Test chgrp&&chmod exit status with `if'; - if it fails, echo a warning msg, but don't make the rule fail. - - * read.c (tilde_expand): New function, broken out of tilde_expand. - (multi_glob): Call it. - (construct_include_path): Expand ~ in directory names. - * dep.h: Declare tilde_expand. - * main.c (enter_command_line_file): Expand ~ at the start of NAME. - (main): Expand ~ in -C args. - * read.c (read_makefile): Expand ~ in FILENAME unless TYPE==2. - -Fri Jun 4 13:34:47 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (decode_env_switches): Use xmalloc instead of alloca for ARGS. - - * main.c (main): Put result of alloca in temporary variable with - simple assignment, to make SGI compiler happy. - -Thu Jun 3 20:15:46 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.3. - - * main.c (main): Before re-execing, remove intermediate files, and - print the data base under -p. Sexier debugging message. - - * implicit.c (pattern_search): Allocate an extra copy of the name - of a winning intermediate file when putting it in FOUND_FILES. - -Wed Jun 2 16:38:08 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Pass flag (1) to parse_file_seq, not to - multi_glob (which doesn't take a 3rd arg). - - * dir.c (dir_contents_file_exists_p): When reading dirents, ignore - chars within D_NAMLEN that are NULs. - - * main.c (decode_switches): Don't savestring ARGV[0] to put it - into `other_args'. - For string switch, don't savestring `optarg'. - (main): Don't free elts of makefiles->list that are "-". - Use alloca'd rather than savestring'd storage for elts of - makefiles->list that are temporary file names. - * read.c (read_all_makefiles): Don't free *MAKEFILES. - * file.c (enter_file): Don't strip `./'s. - * main.c (enter_command_line_file): New function. - (main): Use it in place of enter_file for command-line goals from - other_files, and for old_files and new_files. - -Mon May 31 18:41:40 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.2. - - * compatMakefile (.SUFFIXES): Add .info. - ($(infodir)/$(instname).info): Find make.info* in cwd if there, - else in $srcdir. Use basename to remove dir name from installed name. - -Thu May 27 17:35:02 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * implicit.c (pattern_search): When interning FOUND_FILES, try - lookup_file first; if found, free the storage for our copy of the name. - -Wed May 26 14:31:20 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67.1. - - * main.c (decode_switches): In usage msg, write `--switch=ARG' or - `--switch[=OPTARG]' rather than `--switch ARG' or `--switch [ARG]'. - -Mon May 24 16:17:31 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * rule.c (convert_suffix_rule): New function. - (convert_to_pattern): Use it instead of doing all the work here - several times. - For target suffix `.a', generate both the archive magic rule and - the normal rule. - - * compatMakefile (distclean): Remove stamp-config. - -Sat May 22 16:15:18 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.67. - - * file.c (remove_intermediates): Don't write extra space after `rm'. - - * main.c (struct command_switch.type): Remove `usage_and_exit'. - (print_usage_flag): New variable. - (switches: --help): Make type `flag', to set print_usage_flag. - (init_switches): Remove `usage_and_exit' case. - (decode_switches): Likewise. - (decode_switches): Print usage if print_usage_flag is set. - When printing usage, die with status of BAD. - (main): Die with 0 if print_version_flag. - -Fri May 21 16:09:28 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.66. - -Wed May 19 21:30:44 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (installdirs): New target. - (install): Depend on it. - -Sun May 16 20:15:07 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.65.2. - -Fri May 14 16:40:09 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * vpath.c (construct_vpath_list): In removal loop for DIRPATH==0, - set LASTPATH to PATH, not NEXT. - - * dir.c (read_dirstream): Break out of loop after incrementing - DS->buckets such that it reaches DIRFILE_BUCKETS; avoid trying to - dereference DS->contents->files[DIRFILE_BUCKETS]. - - * read.c (read_makefile): Clear no_targets after reading a - targetful rule line. - - * main.c (main): If print_version_flag is set, exit after printing - the version. - (switches): Change --version docstring to say it exits. - - * make.h [butterfly]: #undef POSIX. - -Wed May 12 15:20:21 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.65.1. - - * arscan.c (ar_scan) [! AIAMAG]: Don't declare LONG_NAME. - [AIAMAG]: Pass TRUNCATE flag arg to (*FUNCTION), always zero. - - * function.c (handle_function): Use fatal instead of - makefile_fatal when reading_filename is nil. - - * configure.in: Add AC_GETGROUPS_T. - * job.c (search_path): Use GETGROUPS_T in place of gid_t. - -Sun May 9 15:41:25 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.65. - -Fri May 7 18:34:56 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * function.c (handle_function): Fatal for unmatched paren. - -Thu May 6 16:13:41 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.64.3. - - * commands.c (handling_fatal_signal): New variable. - (fatal_error_signal): Set it. - * job.c (reap_children): Avoid nonreentrant operations if that is set. - * make.h: Declare handling_fatal_signal. - - * expand.c (reference_variable): New function, snippet of code - broken out of simple-reference case of variable_expand. - (variable_expand): Use it for simple refs. - (variable_expand): When checking for a computed variable name, - notice a colon that comes before the final CLOSEPAREN. Expand - only up to the colon, and then replace the pending text with a - copy containing the expanded name and fall through to subst ref - handling. - (variable_expand): Don't bother expanding the name if a colon - appears before the first $. - (expand_argument): Use alloca instead of savestring. - (variable_expand): For subst ref, expand both sides of = before - passing to [pat]subst_expand. Use find_percent instead of lindex - to check the lhs for a %. - -Wed May 5 14:45:52 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.64.2. - -Mon May 3 17:00:32 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * arscan.c (ar_name_equal) [AIAMAG]: Abort if TRUNCATED is nonzero. - - * read.c (read_makefile): Pass extra arg of 1 to parse_file_seq, - not to multi_glob. - -Thu Apr 29 19:47:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.64.1. - - * arscan.c (ar_scan): New local flag var LONG_NAME. Set it when - we read the member name in any of the fashions that allow it to be - arbitrarily long. Pass its negation to FUNCTION. - (describe_member): Take TRUNCATED from ar_scan and print it. - (ar_name_equal): Take new arg TRUNCATED; if nonzero, compare only - the first sizeof (struct ar_hdr.ar_name) chars. - (ar_member_pos): Take TRUNCATED from ar_scan, pass to ar_name_equal. - * ar.c (ar_member_date_1): Likewise. - -Wed Apr 28 21:18:22 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (reap_children): Before calling start_job_command to start - the next command line, reset C->remote by calling start_remote_job_p. - -Mon Apr 26 15:56:15 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * arscan.c (ar_scan): New local var NAMEMAP. - In loop, rename NAME to NAMEBUF; new var NAME is a pointer; new - flag IS_NAMEMAP. When extracting the member name, always put a - null at its end first. If the name is "//" or "/ARFILENAMES", set - IS_NAMEMAP. If we have already read in NAMEMAP, and NAME looks - like " /N", get full name from NAMEMAP+N. - Else if NAME looks like "#1/N", read N chars from the - elt data to be the full name. At end of loop, if IS_NAMEMAP, read - the elt's data into alloca'd NAMEMAP. - (ar_name_equal): #if 0 truncating code. - - * make.h: Don't declare vfork at all. It returns int anyway, - unless declared it; and we conflicted with some systems. - - * main.c (define_makeflags): If FLAGSTRING[1] is '-', define - MAKEFLAGS to all of FLAGSTRING, not &FLAGSTRING[1]. Don't want to - define it to something like "-no-print-directory". - Use %g format instead of %f for floating-valued things. - -Thu Apr 22 18:40:58 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * GNUmakefile (Makefile.in): Use a substitution ref on nolib-deps - to change remote-%.dep to remote-stub.dep. - -Wed Apr 21 15:17:54 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.64. - -Fri Apr 16 14:22:22 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (install): Remove - prefix from chgrp+chmod. - - * Version 3.63.8. - -Thu Apr 15 18:24:07 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * acconfig.h: New file; contains "#undef SCCS_GET" for autoheader. - * configure.in: If /usr/sccs/get exists, define SCCS_GET to that, - else to "get". - * default.c (default_variables): Set GET to macro SCCS_GET. - - * read.c (parse_file_seq): Take extra arg STRIP; strip `./' only - if nonzero. I hope this is the last time this argument is added - or removed. - (read_makefile): Pass it 1 when parsing include file names. - Pass it 1 when parsing target file names. - Pass it 1 when parsing static pattern target pattern names. - * rule.c (install_pattern_rule): Pass it 1 when parsing rule deps. - * default.c (set_default_suffixes): Pass it 1 when parsing - default_suffixes. - * function.c (string_glob): Pass it 0 here. - -Wed Apr 14 11:32:05 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * misc.c (log_access): New function. - ({init,user,make,child}_access): Call it. - (child_access): Abort if !access_inited. - - * main.c (switches: --no-print-directory): Use 1 instead of -1 for - single-letter option. - (init_switches, decode_switches, define_makeflags): An option with - no single-letter version is no longer indicated by a value of -1; - instead a value that is !isalnum. - (init_switches): Don't put such switches into the string, only - into the long_option table. - - * make.h [!NSIG] [!_NSIG]: #define NSIG 32. - - * job.c [HAVE_WAITPID]: Remove #undef HAVE_UNION_WAIT. AIX's - bsdcc defined WIF* to use union wait. - - * main.c (struct command_switch): Change member `c' to type int. - (switches): Make const. - (decode_switches): Use `const struct command_switch *'. - (define_makeflags): Likewise. - - * default.c (default_suffix_rules): Add `-o $@' to makeinfo rules. - -Mon Apr 12 12:30:04 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.63.7. - - * configure.in (AC_HAVE_HEADERS): Check for string.h and memory.h. - Removed AC_MEMORY_H. - * make.h [USG, NeXT]: Don't test these. - [HAVE_STRING_H]: Test this to include string.h and define ANSI_STRING. - [HAVE_MEMORY_H]: Test this instead of NEED_MEMORY_H. - [! ANSI_STRING]: Put decls of bcopy et al here. - [sparc]: Don't test this for alloca.h; HAVE_ALLOCA_H is sufficient. - [HAVE_SIGSETMASK]: Test this rather than USG. - [__GNU_LIBRARY__ || POSIX]: Don't #include again. - * main.c (main): Handle SIGCHLD if defined, and SIGCLD if defined. - It doesn't hurt to do both if they are both defined, and testing - USG is useless. - * dir.c: Rationalize directory header conditionals. - * arscan.c [HAVE_FCNTL_H]: Test this rather than USG || POSIX. - - * default.c (default_suffixes): Add `.txinfo'. - (default_suffix_rules): Add `.txinfo.info' and `.txinfo.dvi' rules. - - * variable.c (try_variable_definition): Replace RECURSIVE flag - with enum FLAVOR, which can be simple, recursive, or append. - Recognize += as append flavor. Set new variable VALUE in a switch - on FLAVOR. For append flavor, prepend the variable's old value. - If the variable was previously defined recursive, set FLAVOR to - recursive; if it was defined simple, expand the new value before - appending it to the old value. Pass RECURSIVE flag to - define_variable iff FLAVOR == recursive. - - * variable.c (try_variable_definition): Use alloca and bcopy for - NAME, instead of savestring. Might as well use stack storage - since we free it immediately anyway. - -Thu Apr 8 18:04:43 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (start_waiting_jobs): Move decl of JOB outside of loop. - - * main.c (define_makeflags): Rename `struct flag' member `switch' - to `cs', which is not a reserved word. - -Wed Apr 7 15:30:51 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (new_job): Call start_waiting_jobs first thing. - (start_waiting_job): Changed return type from void to int. - Return 0 when putting the child on the waiting_jobs chain. - (start_waiting_jobs): Don't check load and job_slots here. - Always take a job off the chain and call start_waiting_job on it; - give up and return when start_waiting_job returns zero. - - * main.c (define_makeflags: struct flag): Change member `char c' to - `struct command_switch *switch'. - (ADD_FLAG): Set that to CS instead of CS->c. - If CS->c is -1, increment FLAGSLEN for the long name. - When writing out FLAGS, handle FLAGS->switch->c == -1 and write - the long name instead. - - * compatMakefile (stamp-config): New target of old config.h rule. - Touch stamp-config after running config.status. - (config.h): Just depend on stamp-config, and have empty commands. - -Mon Apr 5 20:14:02 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c [HAVE_WAITPID]: #undef HAVE_UNION_WAIT. - - * configure.in (AC_HAVE_FUNCS): Check for psignal. - -Fri Apr 2 17:15:46 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (long_option_aliases): Remove "new"; it is already an - unambiguous prefix of "new-file". - -Sun Mar 28 16:57:17 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.63.6. - -Wed Mar 24 14:26:19 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * vpath.c (selective_vpath_search): When adding the - name-within-directory at the end of NAME, and we don't add a - slash, don't copy FILENAME in one char too far into NAME. - - * variable.c (define_automatic_variables): Find default_shell's - length with strlen, not numerology. - -Wed Mar 17 20:02:27 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (define_makeflags): Add the elts of a string option in - reverse order, so they come out right when reversed again. - -Fri Mar 12 15:38:45 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (make.info): Use `-o make.info'. - -Thu Mar 11 14:13:00 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (REMOTE): Set to @REMOTE@; change comments to - reflect new use. - (objs): Replace remote.o with remote-$(REMOTE).o. - (srcs): Replace remote.c with remote-$(REMOTE).c. - (remote.o): Rule removed. - - * configure.in (REMOTE): Subst this in Makefile et al; default "stub". - Use AC_WITH to grok --with-customs arg to set REMOTE=cstms. - * GNUmakefile (build.sh.in): Filter out remote-% from objs list. - * build.template (REMOTE): New var; set to @REMOTE@. - (objs): Add remote-${REMOTE}.o. - -Wed Mar 10 15:12:24 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.63.5. - - * implicit.c (pattern_search): Fix "dependent"->"dependency" in - "Rejecting impossible" -d msg. - - * file.c (file_hash_enter): New local vars {OLD,NEW}BUCKET. Store - mod'd values there; never mod {OLD,NEW}HASH. - -Mon Mar 8 13:32:48 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * remake.c [eta10]: Include instead of . - - * compatMakefile (VPATH): Set this to @srcdir@. - (srcdir): Set this to $(VPATH). - - * main.c (main): New local var DIRECTORY_BEFORE_CHDIR. Save in it - a copy of CURRENT_DIRECTORY after the first getcwd. Use it - instead of CURRENT_DIRECTORY when chdir'ing back before re-execing. - - * remake.c (notice_finished_file): Pass missing SEARCH arg to f_mtime. - - * read.c (read_makefile): Remove extraneous arg to parse_file_seq. - -Mon Feb 22 14:19:38 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile ($(infodir)/$(instname).info): Use , instead of / - as the sed delimiter char. - -Sun Feb 21 14:11:04 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.63.4. - - * rule.h (struct rule): Removed `subdir' member. - * rule.c (new_pattern_rule): No need to clear it. - (count_implicit_rule_limits): Set the `changed' flag in each dep - that refers to a nonexistent directory. No longer set rule-global - `subdir' flag with that information. - (print_rule_data_base): Don't record info on `subdir' flags. - - * implicit.c (pattern_search): Check the DEP->changed flag rather - than the (now gone) RULE->subdir flag. Also test CHECK_LASTSLASH; - if it is set, the file might exist even though the DEP->changed - flag is set. - - * rule.c (count_implicit_rule_limits): Pass "", not ".", as file - name arg to dir_file_exists_p to check for existence of directory. - - * implicit.c (pattern_search): Inside dep-finding loop, set - CHECK_LASTSLASH from the value recorded in CHECKED_LASTSLASH[I], - rather than computing it anew. - - * commands.c (set_file_variables): Must alloca space for PERCENT - and copy it, to avoid leaving the trailing `)' in the value. - - * misc.c (remove_comments): Fixed backslash-checking loop - condition to allow it to look at the first char on the line. - P2 >= LINE, not P2 > LINE. - - * compatMakefile ($(bindir)/$(instname)): Before moving $@.new to - $@, rm $@.old and mv $@ to $@.old. - - * variable.c (try_variable_definition): Take new args FILENAME and - LINENO. Fatal if the variable name is empty. - * read.c (read_makefile): Change callers. - * main.c (main): Likewise. - - * compatMakefile (group): Define to @KMEM_GROUP@, autoconf magic - that configure will replace with the group owning /dev/kmem. - -Mon Feb 8 14:26:43 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * vpath.c (vpath_search): Take second arg MTIME_PTR, pass thru to - selective_vpath_search. - (selective_vpath_search): Take second arg MTIME_PTR. - If the dir cache thinks a file exists, stat it to make sure, and - put the modtime in *MTIME_PTR. - * remake.c (library_search): Take second arg MTIME_PTR. - When we find a match, record its mtime there. - Pass MTIME_PTR through to vpath_search to do same. - (f_mtime): Pass &MTIME as new 2nd arg to {vpath,library}_search; - store it in FILE->last_mtime if set nonzero. - * implicit.c (pattern_search): Pass nil 2nd arg to vpath_search. - - * compatMakefile (remote.o): Prepend `$(srcdir)/' to `remote-*.c', - so globbing looks somewhere it will find things. - - * compatMakefile ($(infodir)/$(instname).info): Install `make.info*' - not `$(srcdir)/make.info*'; no need to use basename. - -Fri Feb 5 12:52:43 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.63.3. - - * compatMakefile (install): Add missing ;\s. - - Make -, @, and + prefixes on a pre-expanded command line affect - all lines in the expansion, not just the first. - * commands.h (struct commands): Replace `lines_recurse' member - with `lines_flags'. - (COMMANDS_{RECURSE,SILENT,NOERROR}): New macros, bits to set in - that flag byte. - * commands.c (chop_commands): Set `lines_flags' instead of - `lines_recurse'. Record not only + but also @ and - prefixes. - * remake.c (notice_finished_file): Check the COMMANDS_RECURSE bit - in FILE->cmds->lines_flags, rather than FILE->cmds->lines_recurse. - * job.c (start_job_command): Replaced RECURSIVE and NOPRINT local - var with FLAGS; initialize it to the appropriate `lines_flags' byte. - Set CHILD->noerror if the COMMANDS_NOERROR bit is set in FLAGS. - Set the COMMANDS_SILENT bit in FLAGS for a @ prefix. - - * remake.c (update_goal_chain): Set G->file to its prev after - checking for G being finished, since that check needs to examine - G->file. - - * configure.in (union wait check) [HAVE_WAITPID]: Try using - waitpid with a `union wait' STATUS arg. If waitpid and union wait - don't work together, we should not use union wait. - - * Version 3.63.2. - - * remake.c (update_goal_chain): When G->file->updated, move - G->file to its prev. We aren't finished until G->file is nil. - -Thu Feb 4 12:53:04 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (starting_directory): New global variable. - (main): Set it to cwd after doing -Cs. - (log_working_directory): Use it, rather than computing each time. - * make.h: Declare it. - - * compatMakefile (SHELL): Define to /bin/sh for losing Unix makes. - - * main.c (decode_env_switches): Allocate (1 + LEN + 1) words for - ARGV, rather than LEN words plus one byte. - -Wed Feb 3 18:13:52 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile ($(bindir)/$(instname)): Put - before - install_setgid command line, so its failure won't be an error. - (infodir): New variable. - (install): Depend on $(infodir)/$(instname).info. - ($(infodir)/$(instname).info): New target. - - * read.c (read_makefile): If FILENAMES is nil when we see a line - starting with a tab, don't treat it as a command. Just fall - through, rather than giving an error. - - * read.c (read_makefile): If the NO_TARGETS flag is set when we see a - command line, don't clear it before continuing. We want - subsequent command lines to be ignored as well. - - * job.c (new_job): Before expanding each command line, collapse - backslash-newline combinations that are inside var or fn references. - -Mon Feb 1 16:00:13 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (exec_prefix): Default to $(prefix), not /usr/local. - - * compatMakefile (make.info): Pass -I$(srcdir) to makeinfo. - - * job.c [POSIX] (unblock_sigs): Made global. - [!POSIX] (unblock_sigs): Move defns to job.h. - * job.h [POSIX] (unblock_sigs): Declare. - -Sun Jan 31 19:11:05 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * read.c (read_makefile): In vpath parsing, after finding the - pattern token, take entire rest of line as the search path, not - just the next token. - - * compatMakefile (remote.o): Depend on remote-*.c. - -Thu Jan 28 16:40:29 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * commands.c (set_file_variables): Don't define any F or D versions. - * variable.c (define_automatic_variables): Define them here as - recursively-expanded variables that use the dir and notdir funcs. - - * variable.c (target_environment): In v_default case, don't export - o_default or o_automatic variables. - - * configure.in (union wait check): Remove ` and ' inside C code; - they confuse the shell script. - -Mon Jan 25 13:10:42 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.63.1. - - * vpath.c (construct_vpath_list): When skipping further processing - of an elt that is ".", don't also skip the code that pushes P past - the next separator. - - * compatMakefile (distclean): Don't remove make-*. - - * configure.in (HAVE_UNION_WAIT): Try to use WEXITSTATUS if it's - defined. If one cannot use WEXITSTATUS with a `union wait' - argument, we don't want to believe the system has `union wait' at all. - - * remake.c (update_file): Do nothing to print "up to date" msgs. - (update_goal_chain): Do it here instead. - Use the `changed' flag of each goal's `struct dep' to keep track - of whether files_remade (now commands_started) changed around a - call to update_file for that goal. - When a goal is finished, and its file's update_status is zero (i.e., - success or nothing done), test the `changed' flag and give an "up - to date" msg iff it is clear. - * make.h (files_remade): Renamed to commands_started. - * remake.c: Changed defn. - (update_goal_chain): Changed uses. - * job.c (start_job_command): Increment commands_started here. - (reap_children): Not here. - - * remake.c (update_goal_chain): Don't do anything with files' - `prev' members. update_file now completely handles this. - - * variable.c (target_environment): Don't expand recursive - variables if they came from the environment. - - * main.c (define_makeflags): For flags with omitted optional args, - store {"", 0} with ADD_FLAG. When constructing FLAGSTRING, a flag - so stored cannot have more flags appended to the same word. - -Fri Jan 22 14:46:16 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * variable.c (print_variable_set): In vars/bucket calculation, - don't spuriously multiply by 100. - - * Version 3.63. - - * job.c [!HAVE_UNION_WAIT] (WTERMSIG, WCOREDUMP, WEXITSTATUS): - Don't define if already defined. - - * remake.c (update_file): Don't keep track of the command_state before - calling update_file_1. Remove local variable COMMANDS_FINISHED, - and don't test it to decide to print the "is up to date" msg. - Testing for files_remade having changed should always be sufficient. - The old method lost when we are called in the goal chain run on a - makefile, because the makefile's command_state is already - `cs_finished' from the makefile chain run. - - * misc.c [HAVE_SETRE[GU]ID]: Test these to decl setre[gu]id. - - * configure.in: Rewrote wait checking. - Use AC_HAVE_HEADERS to check for . - Use AC_HAVE_FUNCS to check for waitpid and wait3. - Use a compile check to test just for `union wait'. - * job.c: Rewrote conditionals accordingly. - [HAVE_WAITPID]: Test this only to define WAIT_NOHANG. - [HAVE_WAIT3]: Likewise. - [HAVE_UNION_WAIT]: Test this to define WAIT_T and W*. - - * configure.in: Set CFLAGS and LDFLAGS before all checks. - - * dir.c: Add static forward decls of {open,read}_dirstream. - -Thu Jan 21 17:18:00 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.31. - - * job.c [NGROUPS_MAX && NGROUPS_MAX==0]: #undef NGROUPS_MAX. - - * compatMakefile (CFLAGS, LDFLAGS): Set to @CFLAGS@/@LDFLAGS@. - * build.template (CFLAGS, LDFLAGS): Same here. - * configure.in: AC_SUBST(CFLAGS) and LDFLAGS. - Set them to -g if not defined in the environment. - - * remake.c (library_search): Use LIBNAME consistently, setting it - only once, to be the passed name sans `-l'. - Pass new var FILE to be modified by vpath_search. - -Mon Jan 18 14:53:54 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.30. - - * job.c (start_waiting_jobs): Return when job_slots_used is equal to - job_slots. - - * configure.in: Add AC_CONST for the sake of getopt. - - * read.c (read_makefile): Continue after parsing `override' - directive, rather than falling through to lossage. - Check for EOL or blank after "override define". - - * compatMakefile (.c.o, remote.o): Put $(CFLAGS) after other switches. - -Fri Jan 15 12:52:52 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.29. - - * main.c (define_makeflags): After writing everything into - FLAGSTRING, only back up two chars if [-1] is a dash, meaning we - just wrote " -". Always terminate the string at *P. - - * remake.c (library_search): When constructing names in std dirs, - use &(*LIB)[2] for the stem, not LIBNAME (which points at the - buffer we are writing into!). - -Thu Jan 14 13:50:06 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Set IN_IGNORED_DEFINE for "override - define" when IGNORING is true. - - * compatMakefile (distclean): Remove config.status and build.sh. - -Wed Jan 13 16:01:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.28. - - * misc.c (xmalloc, xrealloc): Cast result of malloc/realloc to - (char *). - - * arscan.c (ar_scan) [AIAMAG]: Cast read arg to (char *). - - * variable.c (define_automatic_variables): Override SHELL value for - origin o_env_override as well as o_env. - - * GNUmakefile (build.sh.in): Don't replace %globobjs%. Instead, - add the names of the glob objects (w/subdir) to %objs%. - * build.template (globobjs): Removed. - Take basename of $objs before linking. - -Tue Jan 12 12:31:06 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.27. - - * configure.in (AC_OUTPUT): Also edit build.sh. - * build.template: New file. - * GNUmakefile (build.sh.in): New rule to create it from build.template. - (make-$(version).tar.Z): Depend on build.sh.in. - - * main.c (die): Call print_data_base if -p. - (main): Don't call it here. - - * compatMakefile (defines): Add @DEFS@. configure should turn this - into -DHAVE_CONFIG_H. - -Mon Jan 11 14:39:23 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.26. - - * misc.c (init_access): Surround with #ifdef GETLOADAVG_PRIVILEGED. - ({make,user,child}_access) [! GETLOADAVG_PRIVILEGED]: Make no-op. - * compatMakefile (install_setgid): New var, set by configure. - (install): Install setgid $(group) only if $(install_setgid) is true. - -Fri Jan 8 15:31:55 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (load_too_high): If getloadavg fails with errno==0, give a - message saying that load limits are not supported. - - * vpath.c (construct_vpath_list): Rewrote path deletion code to - not try to use PATH's next link after freeing PATH. - - * main.c (define_makeflags): Rewritten; now handles string-valued - option, and has no arbitrary limits. - (switches): Set `toenv' flag for -I and -v. - - * main.c (decode_env_switches): Cast return value of alloca to char *. - - * misc.c (child_access) [HAVE_SETREUID, HAVE_SETREGID]: Use - setre[gu]id in place of set[gu]id. - -Wed Jan 6 15:06:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (main): Define MAKEOVERRIDES, MAKE, and MAKE_COMMAND with - origin o_default. - - * make.h [POSIX]: Don't test this to use ANSI_STRING. - Testing STDC_HEADERS should be sufficient. - - * job.h: Declare start_waiting_jobs. - - * read.c (read_makefile): Add missing parens in if stmt that find - conditional directives. - - * main.c (main): Declare init_dir. - * implicit.c (pattern_search): Always use two % specs in a - DEBUGP2, and always pass two non-nil args. - Cast field width args to int. - Add missing parens in !RULE->subdir if stmt. - * function.c (expand_function, patsubst_expand): Add parens around - assignments inside `while' stmts. - * commands.c (print_commands): Cast field width args to int. - - * read.c (do_define): Cast return value of alloca to (char *). - - * main.c (init_switches): New function, broken out of decode_switches. - (decode_switches): Take new arg ENV. If set, ignore non-option - args; print no error msgs; ignore options with clear `env' flags. - (decode_env_switches): Rewritten to chop envar value into words - and pass them to decode_switches. - (switches): Set `env' flag for -I and -v. - - * dir.c (init_dir): Cast free to __glob_closedir_hook's type. - -Tue Jan 5 14:52:15 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.25. - - * job.c [HAVE_SYS_WAIT || !USG]: Don't #include and - . interacts badly with , and - we don't need these anyway. - - * configure.in (AC_HAVE_FUNCS): Check for setre[gu]id. - * misc.c ({user,make}_access): Test #ifndef HAVE_SETRE[GU]ID, not - #ifdef POSIX || USG. SunOS 4.1 is supposedly POSIX.1 compliant, - but its set[gu]id functions aren't; its setre[gu]id functions work. - - * misc.c ({user,make,child}_access): Give name of caller in error msgs. - - * job.c (load_too_high): Say "cannot enforce load limit" in error msg. - - * configure.in: Call AC_PROG_CC. - * compatMakefile (CC): Define to @CC@ (autoconf magic). - - * compatMakefile: Add .NOEXPORT magic target. - -Mon Jan 4 17:00:03 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (print_version): Updated copyright to include 93. - -Thu Dec 31 12:26:15 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * make.h [_AIX]: Don't declare alloca. - -Tue Dec 29 13:45:13 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.24. - - * compatMakefile (objs): Add signame.o. - (srcs): Add signame.[ch]. - - * compatMakefile (srcs): Add config.h.in. - (remote.o): Add -I. before -I$(srcdir). - -Mon Dec 28 15:51:26 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.23. - - * read.c (readline): Fatal when LEN==0, indicating a line starting - with a NUL. - (readline): Take new arg LINENO, for use in error msg. - (read_makefile, do_define): Pass it. - - * compatMakefile (glob/libglob.a): Pass -DHAVE_CONFIG_H in CPPFLAGS. - (.c.o): Add -I. before -I$(srcdir). - -Wed Dec 23 12:12:04 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Accept and ignore a rule with no targets. - - * compatMakefile (ALLOCA_SRC): New variable. - (srcs): Include its value. - - * read.c (struct conditional): Renamed member `max_ignoring' to - `allocated'; added new member `seen_else'. - (conditional_line): Initialize seen_else flag when starting an `if...'; - set it when we see an `else'; fatal if set when we see `else'. - (read_makefile): Fatal "missing `endif'" if there are any pending - conditionals, not just if we are still ignoring. - -Tue Dec 22 15:36:28 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (manext): Set to 1, not l. - ($(mandir)/$(instname).$(manext)): Use $(srcdir) for make.man in cmds. - - * file.c (file_hash_enter): Don't call uniquize_deps here. - * read.c (record_files): Likewise. - * implicit.c (pattern_search): Likewise. - * commands.c (set_file_variables): Call it only here. - - * default.c (default_variables) [__convex__]: FC=fc. - - * variable.c (target_environment): Expand the values of recursively - expanded variables when putting them into the environment. - * expand.c (recursively_expand): Made global. - * make.h (recursively_expand): Declare it. - - * remake.c (check_dep): Set FILE->command_state to cs_deps_running - when a dep's command_state is cs_running or cs_deps_running. - - * read.c (read_makefile): Changed error msg for spurious cmds to - not say "first target". - -Sun Dec 20 17:56:09 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * configure.in: Do AC_CONFIG_HEADER right after AC_INIT. - * make.h (HAVE_CONFIG_H): #include "config.h", then #define this. - * compatMakefile (config.h, configure, config.h.in): New rules. - (defines): Removed @DEFS@. - -Thu Dec 17 16:11:40 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (realclean): Just depend on distclean; no cmds. - (distclean): Do what realclean did before; also remove Makefile and - config.h; don't remove configure. - (info, dvi): New targets; depend on make.{info,dvi}. - (doc): Removed target. - (MAKEINFO, TEXI2DVI): New vars. - (make.info, make.dvi): Use them instead of explicit cmds. - -Wed Dec 16 16:25:24 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * configure.in: Added fcntl.h to AC_HAVE_HEADERS. getloadavg cares. - -Wed Dec 9 15:21:01 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (long_option_aliases): Add --new-file alias for -W. - - * default.c (default_variables): Change all C++ to CXX and C++FLAGS - to CXXFLAGS. - - * read.c (do_define): Expand the variable name before using it. - - * main.c (main): Define variable "MAKE_COMMAND" to argv[0]; - define "MAKE=$(MAKE_COMMAND) $(MAKEOVERRIDES)" always. - - * remake.c (library_search): Search for libNAME.a in cwd; look in - vpath before looking in standard dirs, not after. - Changed order of std dirs to: /lib, /usr/lib, ${prefix}/lib. - -Mon Nov 23 14:57:34 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * default.c (default_pattern_rules, default_terminal_rules): Added - brackets around initializers. - - * variable.c (try_variable_definition): Don't check for LINE[0]=='\t'. - (try_variable_definition): Expand the name before defining the var. - - * job.c (init_siglist): Removed function. - Removed decl of `sys_siglist'. - * make.h [! HAVE_SYS_SIGLIST]: #include "signame.h". - [HAVE_SYS_SIGLIST && !SYS_SIGLIST_DECLARED]: Declare sys_siglist - only under these conditions. - * main.c (main): Don't declare init_siglist. - (main) [! HAVE_SYS_SIGLIST]: Call signame_init instead of init_siglist. - -Wed Nov 18 14:52:51 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (record_files): Don't try to append to FIRSTDEPS if it's - nil; instead just set it to MOREDEPS. - -Mon Nov 16 17:49:17 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * vpath.c (construct_vpath_list): Initialize P to DIRPATH before - loop that sets MAXELEM. - -Fri Nov 13 18:23:18 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.22. - -Thu Nov 12 15:45:31 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (start_job_command): Under -n, increment files_remade after - processing (i.e., printing) all command lines. - -Tue Nov 10 15:33:53 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * read.c (record_files): Append new deps if this rule has no - commands; prepend them to existing deps if this rule has no commands. - - * dir.c (open_dirstream): Return nil if DIR->contents->files is nil. - - * read.c (parse_file_seq): Removed last arg STRIP. Always strip `./'s. - (read_makefile): Changed callers. - * function.c (string_glob): Likewise. - * rule.c (install_pattern_rule): Likewise. - -Mon Nov 9 17:50:16 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * remake.c (files_remade): Made global. - (notice_finished_file): Don't increment files_remade here; this - function gets called in many situations where no remaking was in - fact done. - * job.c (reap_children): Do it here instead, when we know that - actual commands have been run for the file. - * make.h (files_remade): Declare it. - -Thu Nov 5 18:26:10 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * vpath.c (construct_vpath_list): Allow blanks as well as colons to - separate elts in the search path. - - * read.c (read_makefile): Don't fatal on extra tokens in `vpath'. - The search path can contain spaces now. - -Tue Nov 3 20:44:32 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (check): New target; no-op. - - * file.c (file_hash_enter): Mod OLDHASH by FILE_BUCKETS after - testing for OLDHASH==0 but before using the value. - (rename_file): Don't mod OLDHASH by FILE_BUCKETS before passing it - to file_hash_enter. - - * file.c (rename_file): Notice when OLDFILE->cmds came from - default.c, and don't try to print ->filename in that case. - -Sun Oct 25 01:48:23 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * remake.c (update_file): Don't process F->also_make here. - (notice_finished_file): Don't process FILE->also_make if no attempt - to update FILE was actually made. - Fixed to call f_mtime directly to refresh their modtimes. - -Sat Oct 24 22:08:59 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (find_percent): Don't increment P again after skipping - an escaped %. - - * expand.c (variable_expand): In call to patsubst_expand, don't - find `%'s ourselves; let that function do it. - - * read.c (read_makefile: record_waiting_files): Don't call - record_files if FILENAMES is nil. - (read_makefile): All alternatives in the parsing, except for rule - lines, fall through to the end of the loop. At the end of the - loop, do record_waiting_files so we notice later spurious cmds. - -Fri Oct 23 15:57:37 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * variable.c (define_automatic_variables): Free old value of SHELL - before replacing it. - -Thu Oct 15 18:57:56 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (.c.o): Add -I$(srcdir)/glob to flags. - - * dir.c (open_dirstream): Cast return value to __ptr_t. - - * default.c (default_variables: "GET") [_IBMR2]: Use USG defn. - - * make.h (MAXPATHLEN): Moved out of #ifndef POSIX. - (GET_PATH_MAX): Moved from #ifdef POSIX to #ifdef PATH_MAX #else. - Define as (get_path_max ()). - [! PATH_MAX] (NEED_GET_PATH_MAX): Define. - [! PATH_MAX] (get_path_max): Declare fn. - * misc.c [NEED_GET_PATH_MAX] (get_path_max): New function. - -Mon Oct 12 13:34:45 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.21. - - * job.c (sys_siglist): Only declare #ifndef SYS_SIGLIST_DECLARED. - * make.h [! HAVE_SYS_SIGLIST && HAVE__SYS_SIGLIST]: #define - SYS_SIGLIST_DECLARED. - - * dir.c (file_impossible): When initializing DIR->contents, set - DIR->contents->dirstream to nil. - - * compatMakefile (GLOB): Define new variable. - (objs): Use it, rather than glob/libglob.a explicitly. - - * read.c (parse_file_seq): When stripping "./", handle cases like - ".///foo" and "./////". - * file.c (lookup_file, enter_file): Likewise. - -Sun Oct 11 17:00:35 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * dir.c (struct dirstream, {open,read}_dirstream): New - data type and functions to read a directory sequentially. - (init_dir): New function to hook it into glob. - * main.c (main): Call init_dir. - - * compatMakefile (objs): Added glob/libglob.a. - * configure.in: Remove code to test for glob. - -Fri Oct 9 12:08:30 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (record_files): Generalized test for NAME pointing - somewhere into F->name. - - * variable.c (define_variable_in_set): Free old value when replacing. - - * read.c (do_define): Free the linebuffer before returning. - (record_files): When clearing .SUFFIXES deps, free their data. - (multi_glob): Free OLD and its data when replacing it with results - of glob run. - - * commands.c (set_file_variables): Use alloca in place of xmalloc - for temp space for $^, $?, et al. - - * dir.c (struct directory): New member `contents' replaces `files' - and `dirstream'. - (struct directory_contents): New type. - (directories_contents): New hash table. - (dir_struct_file_exists_p): Take a struct directory_contents. - (dir_file_exists_p): Pass it the `contents' member of the dir found. - (dir_struct_file_exists_p): Renamed to dir_contents_file_exists_p; - made static. Return 0 if DIR is nil (meaning it couldn't be stat'd). - (dir_file_exists_p, find_directory): Change all callers. - (file_impossible): Use DIR->contents, initializing it if nil. - (print_dir_data_base): Use DIR->contents, and print out device and - inode numbers with each directory. - - * Changes for performance win from John Gilmore : - * dir.c (DIRECTORY_BUCKETS): Increase to 199. - (DIRFILE_BUCKETS): Decrease to 107. - (find_directory): Allocate and zero a multiple of - sizeof (struct dirfile *), not of sizeof (struct dirfile). - (dir_struct_file_exists_p): New function, nearly all code from - dir_file_exists_p. - (dir_file_exists_p): Just call find_directory+dir_struct_file_exists_p. - * vpath.c (selective_vpath_search): Remove redundant - dir_file_exists_p call. - - * configure.in: Comment out glob check; always use our code. - -Fri Oct 2 19:41:20 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * make.h [! HAVE_SYS_SIGLIST && HAVE__SYS_SIGLIST]: #define - HAVE_SYS_SIGLIST; after doing #define sys_siglist _sys_siglist, we - do have it. - -Wed Sep 30 19:21:01 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (main): Don't do -w automatically if -s. - -Tue Sep 29 21:07:55 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (printed_version): Move variable inside print_version. - (print_version): Return immediately if printed_version is set. - (die): Don't test printed_version here. - (decode_switches): Under -v, do print_version before giving usage. - (DESCRIPTION_COLUMN): New macro. - (decode_switches): Use it when printing the usage message. - Leave at least two spaces between options and their descriptions. - -Fri Sep 25 13:12:42 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.20. - -Wed Sep 16 16:15:22 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * read.c (read_makefile): Save errno value from trying to open - FILENAME, and restore it before erring; otherwise we get the errno - value from the last elt of the search path. - -Tue Sep 15 15:12:47 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (long_option_aliases): Add --stop for -S. - - * read.c (word1eq): Do strncmp before dereferencing someplace that - may be out in space. - -Wed Sep 9 15:50:41 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * remake.c (notice_finished_file): If all the command lines were - recursive, don't do the touching. - - * job.c (start_job_command): Don't check for + here. - * commands.c (chop_commands): Do it here instead. - - * default.c (default_terminal_rules): Prepend + to cmds for RCS. - -Wed Sep 2 17:53:08 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (objs): Include $(ALLOCA). - - * make.h [CRAY]: Move #define signal bsdsignal to before #includes. - -Thu Aug 27 17:45:43 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * read.c (default_include_directories): Add INCLUDEDIR first. - * compatMakefile (includedir): Define. - (defines): Add -D for INCLUDEDIR="$(includedir)". - - * read.c (read_makefile): Grok multiple files in `include'; - globbing too. - - * remake.c (library_search): New function. - (library_file_mtime): Remove function. - (f_mtime): Use library_search instead of library_file_mtime. - * compatMakefile (libdir): Define. - (defines): Add -D for LIBDIR="$(libdir)". - * make.texinfo (Libraries/Search): Document change. - - * file.c (rename_file): Fix file_hash_enter call with missing arg. - -Wed Aug 26 17:10:46 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.19. - - * main.c (main): Set command_state to cs_finished for temp files - made for stdin makefiles. - - * main.c (decode_switches): Don't tell getopt to return non-option - args in order. - Ignore an argument of `-'. - -Thu Aug 20 13:36:04 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * job.c (start_job_command): If (touch_flag && !RECURSIVE), ignore - the command line and go to the next. - (notice_finished_file): Under -t, touch FILE. - * remake.c (remake_file): Don't touch it here. - -Wed Aug 19 16:06:09 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * function.c (pattern_matches): Use temporary for strlen (WORD) - instead of two function calls. - - * compatMakefile (LOAD_AVG): Remove variable and comments. - -Tue Aug 18 14:58:58 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * make.texinfo (Running): Node renamed to `make Invocation'. - -Fri Aug 14 12:27:10 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * arscan.c (ar_name_equal): Don't compare [MAX-3..MAX] if - NAMELEN != MEMLEN. - -Thu Aug 13 17:50:09 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.18. - - * main.c: Don't #include ; make.h already does. - -Mon Aug 10 17:03:01 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * implicit.c (pattern_search): Fixed copying of suffix when building - also_make elts. - - * function.c (expand_function: `shell'): Make sure BUFFER is - null-terminated before replacing newlines. - - * compatMakefile (mandir): Use man$(manext), not always manl. - -Sun Aug 2 01:42:50 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * rule.c (new_pattern_rule): Not static. - * rule.h: Declare it. - - * file.c (file_hash_enter): New function, most code from rename_file. - (rename_file): Call it. - * file.h (file_hash_enter): Declare it. - - * dep.h: Doc fix. - -Thu Jul 30 15:40:48 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (decode_switches): Handle usage_and_exit when building - long options vector. - - * default.c (default_terminal_rules): Make RCS rules use $(CHECKOUT,v). - (default_variables): Define CHECKOUT,v (hairy). - - * make.h [!HAVE_SYS_SIGLIST && HAVE__SYS_SIGLIST]: #define - sys_siglist to _sys_siglist. - -Sun Jul 26 16:56:32 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * NEWS: Add header and tail copyright info like Emacs NEWS. - - * make.h [ANSI_STRING]: Don't #define index, rindex, bcmp, bzero, - bcopy if already #define'd. - [STDC_HEADERS] (qsort, abort, exit): Declare here. - [! __GNU_LIBRARY__ && !POSIX]: Not here. - - * make.h [_AIX]: #pragma alloca first thing. - - * job.c (start_waiting_job): Set the command_state to cs_running - when we queue a job on waiting_jobs. - -Fri Jul 24 02:16:28 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * variable.c (define_automatic_variables): Use "" instead of nil - for empty value. - -Thu Jul 23 22:31:18 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.17. - - * main.c (struct command_switch.type): Add alternative usage_and_exit. - (command_switches): Add -h/--help. - -Thu Jul 16 14:27:50 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * GNUmakefile (make-$(version).tar.Z): Include NEWS, not CHANGES. - * README.template: Mention NEWS. - * CHANGES: Renamed to NEWS. - - * main.c [! STDC_HEADERS] [sun]: Don't declare exit. - -Tue Jul 14 18:48:41 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (main): Set -o files' command_states to cs_finished. - - * rule.c (count_implicit_rule_limits): Decrement num_pattern_rules - when tossing a rule. - - * main.c (main): Use alloca only in simple local var assignment, - for braindead SGI compiler. - - * rule.c (print_rule_data_base): Barf if num_pattern_rules is - inconsistent with the number computed when listing them. - -Mon Jul 13 17:51:53 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * commands.c (set_file_variables): For $? and $^ elts that are archive - member refs, use member name only. - -Fri Jul 10 00:05:04 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * variable.h (struct variable.export): Add new alternative v_ifset. - * variable.c (target_environment): Check for it. - (define_automatic_variables): Set it for MAKEFILES. - -Thu Jul 9 21:24:28 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (objs): Remove getloadavg.o; $(extras) gets it. - (remote.o): Use $(srcdir)/remote.c, not $remote.c<. - (distclean, mostlyclean): New targets. - -Tue Jul 7 19:12:49 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.16. - - * compatMakefile (config.status): Remove rule. - - * job.c (start_waiting_job): Free C after using C->file, not before. - -Sat Jul 4 20:51:49 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * commands.c, job.c, main.c, make.h, remote-cstms.c: Use #ifdef - HAVE_* instead of #ifndef *_MISSING. - * configure.in: Use AC_HAVE_FUNCS instead of AC_MISSING_FUNCS (gone). - -Thu Jul 2 18:47:52 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * main.c (main): makelevel>0 or -C implies -w. - -Tue Jun 30 20:50:17 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * file.c, job.c, function.c: Don't #include . - make.h: Do it here instead. - * arscan.c (ar_member_touch): Don't declare errno. - -Thu Jun 25 17:06:55 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * GNUmakefile (make-$(version).tar.Z): Depend on INSTALL, configure.in. - - * remake.c (update_file): If commands or deps are running after - update_file_1 returns, break out of the :: rule (->prev) loop and - just return. - - * job.c (job_next_command): New function; code from start_job. - (start_job_command): Renamed from start_job. Call job_next_command - and recurse for empty command lines and -n. - (start_waiting_job): Call start_job_command, not start_job. - (new_job): Call job_next_command to prime the child structure, and - then call start_waiting_job. - (reap_children): Use job_next_command and start_job_command. - (start_waiting_job): Call start_remote_job_p here, and store its - result in C->remote. If zero, check the load average and - maybe put C on waiting_jobs. - (start_job_command): Test CHILD->remote rather than calling - start_remote_job_p. Don't do load avg checking at all here. - - * main.c (main): Don't handle SIGILL, SIGIOT, SIGEMT, SIGBUS, - SIGSEGV, SIGFPE or SIGTRAP. - - * compatMakefile (glob/libglob.a): Don't pass srcdir to sub-make. - configure will set it in glob/Makefile. - -Wed Jun 24 19:40:34 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * dir.c [DIRENT] (direct): Don't define to dirent. - [! DIRENT] (direct): Define to dirent. - (dir_file_exists_p): Use struct dirent instead of struct direct. - - * make.h (getcwd): No space between macro and ( for args! - - * job.c (start_job): Don't put the job on waiting_jobs if - job_slots_used==0. - - * make.texinfo (Missing): Shortened title. - -Tue Jun 23 18:42:21 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * file.c (remove_intermediates): Print "rm" commands under -n. - -Mon Jun 22 16:20:02 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.15. - -Fri Jun 19 16:20:26 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * arscan.c [M_UNIX]: #undef M_XENIX. - -Wed Jun 17 17:59:28 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * default.c (default_terminal_rules): Put @ prefix on RCS cmds. - -Tue Jun 16 19:24:17 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile (getloadavg.o): Removed special rule. - (CFLAGS): Don't include $(defines). - (.c.o): Define suffix rule. - (glob/libglob.a): Pass CPPFLAGS=$(defines) to submake. - (GETOPT_SRC, srcs, tagsrcs): Prefix files with $(srcdir)/. - - * arscan.c (ar_name_equal): Moved local vars inside #if'd block. - - * make.h (max): Removed. - * expand.c (variable_buffer_output): Don't use it. - - * compatMakefile (INSTALL): Define. - (Makefile): New rule to make from Makefile.in. - (srcdir): Define. - (VPATH): Define. - (getloadavg.o, remote.o): Use autoconf $foo< hack. - - * commands.c (fatal_error_signal): Removed return. - -Mon Jun 15 17:42:51 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.14. - - * make.texinfo (Summary): New node. - (Special Targets): Mention .EXPORT_ALL_VARIABLES here. - - * variable.c (max): Moved to make.h. - - * compatMakefile (objs, srcs): Added ar & arscan. - - * job.c (start_waiting_job): New function, 2nd half of new_job. - (new_job): Call it. - (start_waiting_jobs): New function. - * remake.c (update_goal_chain): Call start_waiting_jobs at the top - of the main loop. - * compatMakefile (objs, srcs): Removed load, added getloadavg. - -Fri Jun 12 19:33:16 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * job.c (load_too_high): New function. Uses getloadavg. - (waiting_jobs): New variable. - (start_job): Don't call wait_to_start_job. Instead, if - load_too_high returns nonzero, add the child to the - `waiting_jobs' chain and return without starting the job. - -Thu Jun 11 00:05:28 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * expand.c (variable_buffer_output): Made global again. - * variable.h: And declare it. - - * arscan.c (PORTAR): Define for all systems if PORT5AR is not defined. - (AR_NAMELEN, AR_TRAILING_SLASH): Removed. - (ar_scan): Don't use it. Don't #ifdef AR_TRAILING_SLASH; just look - for a slash in the archive at run time. - (ar_name_equal): Rewrote .o hacking to not use AR_NAMELEN, and to - cope with trailing-slash and non-trailing-slash archives. - - * main.c (main) [! SETVBUF_REVERSED]: Test this instead of USGr3 et al. - [SETVBUF_REVERSED]: Always allocate a buffer ourselves. - - * load.c (load_average) [sgi]: Use sysmp call. - - * compatMakefile (INSTALL_DATA, INSTALL_PROGRAM): Define. - ($(bindir)/$(instname), $(mandir)/make.$(manext)): Use them. - - * make.h [HAVE_VFORK_H]: #include . - (vfork, VFORK_NAME): Don't define. - * job.c (start_job): Use "vfork" in place of VFORK_NAME. - - * make.h [HAVE_LIMITS_H, HAVE_SYS_PARAM_H]: If #define'd, #include - the each file. Rearranged PATH_MAX hacking. - * job.c: Rearranged NGROUPS_MAX hacking. - - * remake.c (fstat, time): Don't declare. - - * compatMakefile (defines): Value is @DEFS@. - (LOADLIBES): Value is @LIBS@. - (extras): Value is @LIBOBJS@. - (ARCHIVES, ARCHIVES_SRC, ALLOCASRC): Removed. - * arscan.c, ar.c: Surround body with #ifndef NO_ARCHIVES. - - * misc.c [! HAVE_UNISTD_H]: Test instead of !POSIX to decl get*id. - - * make.h [GETCWD_MISSING]: Test instead of !USG && !POSIX et al. - (getcwd): Just declare if present. If not, declare as a macro - using getwd, and declare getwd. - [PATH_MAX] (GET_PATH_MAX): #define to PATH_MAX. - * main.c (main, log_working_directory): Use getcwd instead of getwd. - - * main.c (main) [SETLINEBUF_MISSING]: Test this instead of USG. - - * make.h (SIGHANDLER, SIGNAL): Removed. - (RETSIGTYPE): Define if not #define'd. - * main.c (main): Use signal in place of SIGNAL. - - * main.c [SYS_SIGLIST_MISSING]: Test instead of USG. - - * job.c (search_path) [GETGROUPS_MISSING]: Test instead of USG. - [HAVE_UNISTD_H]: Test instead of POSIX to not decl getgroups. - - * main.c [! HAVE_UNISTD_H]: Test instead of !POSIX to decl chdir. - [! STDC_HEADERS]: Test instead of !POSIX to decl exit & atof. - - * job.c (child_handler), commands.c (fatal_error_signal): Return - RETSIGTYPE instead of int. - * main.c (main): Declare fatal_error_signal and child_handler here - to return RETSIGTYPE; removed top-level decl of former. - - * commands.c (fatal_error_signal), job.c (unblock_sigs, start_job), - main.c [SIGSETMASK_MISSING]: Test this instead of USG. - -Wed Jun 10 22:06:13 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * job.c [HAVE_WAITPID]: Test this instead of USG. - [! HAVE_UNISTD_H]: Test this instead of !POSIX to declare misc fns. - (GID_T): Don't #define. - (search_path): Use gid_t instead of GID_T. - [GETDTABLESIZE_MISSING, SYS_SIGLIST_MISSING, DUP2_MISSING]: Test - these individually instead of USG for all. - * make.h (ctime): Don't declare. #include time.h instead. - [HAVE_UNISTD_H]: #include and #define POSIX #ifdef - _POSIX_VERSION. - * dir.c [__GNU_LIBRARY__] (D_NAMLEN): Define to use d_namlen member. - * make.h [NEED_MEMORY_H]: Only include memory.h #ifdef this. - - * arscan.c: Removed #ifdef mess about string.h et al. - Just #include make.h instead. - * make.h (fstat, atol): Declare. - - * commands.c (fatal_error_signal): Don't use sigmask to check for - propagated signals; use ||s instead. - (PROPAGATED_SIGNAL_MASK): Removed. - (fatal_error_signal) [POSIX]: Use sigprocmask in place of sigsetmask. - - * variable.c (variable_buffer, variable_buffer_length, - initialize_variable_output, variable_output): Moved to expand.c; - made all static. - (struct output_state, save_variable_output, - restore_variable_output): Removed. - * expand.c (initialize_variable_output): Put a NUL at the beginning - of the new buffer after allocating it. - (allocated_variable_expand_for_file): Don't use - {save,restore}_variable_output. Do it by hand instead, keeping - state on the stack instead of malloc'ing it. - (allocated_variable_expand): Removed. - * variable.h (allocated_variable_expand): Define here as macro. - (variable_buffer_output, initialize_variable_output, - save_variable_output, restore_variable_output): Removed decls. - - * read.c (conditional_line): For an if cmd, if any elt of the - conditionals stack is ignoring, just push a new level that ignores - and return 1; don't evaluate the condition. - -Thu Jun 4 21:01:20 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (main): Put #ifdef's around frobbing SIGSYS and SIGBUS. - - * job.c (getdtablesize): Don't declare or #define if already #define'd. - -Wed Jun 3 23:42:36 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * file.c (snap_deps): If `.EXPORT_ALL_VARIABLES' is a target, set - export_all_variables. - * make.texinfo (Variables/Recursion): Document .EXPORT_ALL_VARIABLES. - -Tue Jun 2 21:08:35 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.13. - - * commands.c (set_file_variables): Calculate length for ^D and ?D - individually, making sure to give them at least enough space for "./". - - * make.h [CRAY]: #define signal to bsdsignal. - - * default.c (default_variables) [CRAY]: Define PC, SEGLDR, - CF77PPFLAGS, CF77PP, CFT, CF, and FC. - - * arscan.c (AR_HDR_SIZE): Define to sizeof (struct ar_hdr), if it - wasn't defined by . - -Thu May 28 00:56:53 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.12. - -Tue May 26 01:26:30 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * rule.c (new_pattern_rule): Initialize LASTRULE to nil, not - pattern_rules. - -Mon May 25 19:02:15 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (decode_switches): Initialize all the long_option elt members. - -Thu May 21 16:34:24 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * make.texinfo (Text Functions): Correct filter-out description. - -Tue May 19 20:50:01 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * compatMakefile (realclean): Don't remove backup files. - - * main.c (decode_switches): Allocate ARGC+1 elts in `other_args'. - -Sun May 17 16:38:48 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * Version 3.62.11. - -Thu May 14 16:42:33 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * job.c (reap_children): Don't die if wait returns EINTR. - -Wed May 13 18:28:25 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * job.c (reap_children): Always run the next command for a - successful target. If we are going to die, we don't want to leave - the target partially made. - -Tue May 12 00:39:19 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): After loop, if we only - have one word, check it for being a shell command. - - * main.c (decode_switches): Allocate ARGC slots in other_args to - begin with, so we never need to worry about growing it. - If we get a non-option arg and POSIXLY_CORRECT is in the - environment, break out of the loop. After the loop, add all remaining - args to other_args list. - - * main.c (decode_switches): For positive_int and floating switches - when optarg is nil, use next arg if it looks right (start with a - digit, or maybe decimal point for floating). - - * variable.c (define_automatic_variables): Always set SHELL to - default if it comes from the environment. Set its export bit. - * make.texinfo (Environment): Document change. - -Mon May 11 00:32:46 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * Version 3.62.10. - - * compatMakefile (tags, TAGS): Use vars for cmds. - (ETAGS, CTAGS): Define. - - * main.c (decode_switches): If a switches elt has a nil long_name, - make the long option name elt be "". - Fixed loop to not ignore all the options. - - * make.texinfo (Option Summary): Added long options. - - * main.c (switches): Changed -m's description to "-b". - (decode_switches): When printing the usage message, don't print - switches whose descriptions start with -. - When constructing the list of names for switch -C, search the - switches vector for switches whose descriptions are "-C". - - * main.c (switches): Call -S --no-keep-going, not --dont-keep-going. - Call -I --include-dir, not --include-path. - (long_option_aliases): Added --new == -W, --assume-new == -W, - --assume-old == -o, --max-load == -l, --dry-run == -n, --recon == -n, - --makefile == -f. - - * main.c (switches): Removed bogus "silent" elt. - (long_option_aliases): Define new var. - (decode_switches): Add long_option_aliases onto the end of the long - options vector created for getopt_long. - Look through long_option_aliases for extra names to list - in usage message. - -Sat May 9 00:21:05 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (log_working_directory): Fixed to properly not print the - leaving message when we haven't printed the entering message. - -Fri May 8 21:55:35 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * main.c (struct command_switch): Added elts `long_name', - `description', and `argdesc'. - (switches): Added initializers for new members. - (decode_switches): Rewritten to use getopt_long. - * compatMakefile (GETOPT, GETOPT_SRC): Define. - (objs, srcs): Include them. - - * job.c (child_died): Renamed to dead_children; made static. - (child_handler): Increment dead_children instead of setting child_died. - (reap_children): Decrement dead_children instead of clearing - child_died. The point of all this is to avoid printing "waiting - for unfinished jobs" when we don't actually need to block. - This happened when multiple SIGCHLDs before reap_children was called. - - * job.c (reap_children): If ERR is set, so we don't call start_job - on the child being reaped, instead set its command_state to - cs_finished. - (reap_children, child_handler, new_job): I added several - debugging printf's while fixing this. I left them in if (debug_flag) - because they may be useful for debugging this stuff again. - -Wed May 6 22:02:37 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * read.c (read_makefile): v_export is not 1. - -Mon May 4 17:27:37 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.9. - - * variable.c (export_all_variables): New variable. - (target_environment): Export variables whose `export' member is - v_default if export_all_variables is set and their names are benign. - * variable.h: Declare export_all_variables. - * read.c (read_makefile): If export or unexport is given with no - args, set or clear export_all_variables, respectively. - - * variable.c (target_environment): Exclude MAKELEVEL in the loop, - so it isn't duplicated when we add it at the end. - -Sun May 3 17:44:48 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.8. - - * variable.h (struct variable): Added new member `export'. - * variable.c (define_variable_in_set): Initialize it to v_default. - (target_environment): Don't check for .NOEXPORT. - Export variables whose `export' member is v_default and that would - have been exported under .NOEXPORT, and variables whose `export' - member is v_export. - (try_variable_definition): Return the variable defined. - * variable.h (try_variable_definition): Changed decl. - * read.c (read_makefile): Recognize `export' and `unexport' directives. - -Fri May 1 11:39:38 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * main.c (main) [POSIX]: Reversed args to sigaddset. - -Thu Apr 30 17:33:32 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * job.c [POSIX || !USG] (unblock_sigs): New fn. - (start_job): Block signals before forking. - (new_job): Unblock signals after putting the new child on the chain. - * main.c (main) [POSIX]: Use sigset_t fatal_signal_set instead of - int fatal_signal_mask. - - * load.c [sgi] (LDAV_CVT): Define. - -Wed Apr 29 17:15:59 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * Version 3.62.7. - - * load.c (load_average) [sgi]: Clear the high bit of the address - from the symbol table before looking it up in kmem. - - * misc.c (fatal, makefile_fatal): Put *** in fatal error messages. - (remake_file): No longer needed in message here. - - * main.c (die): Call reap_children with BLOCK==1. - -Tue Apr 28 20:44:35 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * rule.c (freerule): Don't set LASTRULE->next if LASTRULE is nil. - -Sun Apr 26 15:09:51 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * rule.c (count_implicit_rule_limits): Initialize LASTRULE to nil, - not to head of chain. Extract next ptr before we might do - freerule, and use that for next iteration. - (freerule): Still do next ptr frobbing if LASTRULE is nil. - -Tue Apr 21 03:16:29 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * job.c (child_error): Removed extra %s from error msg format. - - * Version 3.62.6. - - * job.c (reap_children): Don't start later commands in a sequence - if ERR is nonzero. - - * job.c (new_job): Always call reap_children with BLOCK==0 first thing. - - * job.c (reap_children): New function; work that used to be done in - child_handler. - (child_died): New global var. - (child_handler): Now just sets child_died. - (wait_for_children): Removed. - (unknown_children_possible, block_signals, unblock_signals, - push_signals_blocked_p, pop_signals_blocked_p): Removed. - (child_execute_job): Removed call to unblock_signals. - (new_job): Removed calls to push_signals_blocked_p and - pop_signals_blocked_p. - * job.h: Declare reap_children, not wait_for_children. - * commands.c (fatal_error_signal), job.c (new_job), - load.c [LDAV_BASED] (wait_to_start_job), main.c (die), - remake.c (update_goal_chain), function.c (expand_function: `shell'): - Changed wait_for_children calls to reap_children. - Some needed to be loops to wait for all children to die. - * commands.c (fatal_error_signal), main.c (main, - log_working_directory), function.c (expand_function): Removed calls - to push_signals_blocked_p and pop_signals_blocked_p. - * job.h: Removed decls. - - * job.h: Added copyright notice. - -Wed Apr 15 02:02:40 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (child_error): No *** for ignored error. - -Tue Apr 14 18:31:21 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * implicit.c (DEBUGP2): Use do ... while (0) instead of if ... else to - avoid compiler warnings. - - * read.c (parse_file_seq): Don't remove ./ when it is followed by a - blank. - -Mon Apr 13 21:56:15 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.h (DEBUGPR): Use do ... while (0) instead of if ... else to - avoid compiler warnings. - - * remake.c (notice_finished_file): Run file_mtime on the also_make - files, so vpath_search can happen. - - * GNUmakefile (tests): Use perl test suite from csa@sw.stratus.com. - (alpha-files): Include test suite tar file. - -Fri Apr 3 00:50:13 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * Version 3.62.5. - -Wed Apr 1 05:31:18 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * remake.c (update_file, update_file_1): Do check_renamed on elts - of dep chains when traversing them. Something unrelated might have - renamed one of the files the dep chain points to. - - * file.c (rename_file): If FILE has been renamed, follow its - `renamed' ptr, so we get to the final real FILE. Using the renamed - ones loses because they are not in the hash table, so the removal - code loops infinitely. - - * read.c (read_all_makefiles): Clobber null terminator into - MAKEFILES expansion, so string passed to read_makefile is properly - terminated. - -Mon Mar 30 20:18:02 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * commands.c (set_file_variables): $* for archive member with - explicit cmds is stem of member, not of whole `lib(member)'. - -Thu Mar 26 15:24:38 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * Version 3.62.4. - -Tue Mar 24 05:20:51 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * rule.c (new_pattern_rule): Rules are identical only if all their - targets match (regardless of order). - -Wed Mar 11 13:49:54 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) - - * remake.c (remake_file): Changed error "no way to make" to "no - rule to make". Fiat Hugh. - - * make.texinfo (Last Resort): Describe %:: rules and new .DEFAULT - behavior. - - * remake.c (update_file_1): Only use .DEFAULT cmds if FILE is not a - target. - -Tue Mar 10 18:13:13 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * remote-stub.c, remote-cstms.c (start_remote_job): Take new arg, - environment to pass to child. - * job.c (start_job): Pass it. - -Mon Mar 9 19:00:11 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * file.c (enter_file): Also strip ./s here, to get command-line - target names. - - * remote-cstms.c: Add comment telling people to leave me alone. - - * compatMakefile (manpage install): Remove target before copying. - -Tue Mar 3 18:43:21 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.texinfo (Missing): Renamed to "Incompatibilities and ...". - Added paragraph describing $? incompatibility with Unix and POSIX.2. - -Sun Mar 1 15:50:54 1992 Roland McGrath (roland@nutrimat.gnu.ai.mit.edu) - - * function.c (expand_function: `shell'): Don't declare fork or pipe. - Use vfork instead of fork. - -Tue Feb 25 22:05:32 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * make.texinfo (Chained Rules): Clarify .PRECIOUS to save - intermediate files. - - * load.c [sun] (LDAV_CVT): Define to divide by FSCALE. - -Sun Feb 16 02:05:16 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * Version 3.62.3. - -Sat Feb 15 17:12:20 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * compatMakefile (makeinfo): Use emacs batch-texinfo-format fn. - -Fri Feb 14 00:11:55 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * read.c (read_makefile): Correctly handle define & endef in ifdefs. - - * read.c (record_files): Pass arg for %s in error msg. - - * main.c (main) [__IBMR2, POSIX]: Use correct (a la USGr3) setvbuf - call. - -Wed Feb 12 12:07:39 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * make.texinfo (Libraries/Search): Say it does /usr/local/lib too. - -Sun Feb 9 23:06:24 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * read.c (read_makefile): Check for extraneous `endef' when ignoring. - -Thu Feb 6 16:15:48 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * Version 3.62.2. - -Tue Feb 4 20:04:46 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Correctly ignore - whitespace after backslash-NL. - -Fri Jan 31 18:30:05 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * compatMakefile: Ignore errors from chgrp and chmod when installing. - -Wed Jan 29 18:13:30 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * main.c (main): When setting MAKELEVEL in the env to re-exec, - allocate space so as not to clobber past the end of the old string. - - * make.h [HAVE_ALLOCA_H]: Include - * compatMakefile (defines): Document HAVE_ALLOCA_H. - -Mon Jan 20 13:40:05 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * make.h [VFORK_MISSING]: Use fork instead. - * compatMakefile (defines): Document same. - - * job.c (construct_command_argv_internal): Don't create an empty - arg if backslash-NL is at beginning of word. - -Sun Jan 19 16:26:53 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * main.c [DGUX]: Call setvbuf as for USGr3. - - * job.c (construct_command_argv_internal): Notice correctly that - backslash-NL is the end of the arg (because it is replaced with a - space). - -Thu Jan 16 18:42:38 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): If SHELL is nil, set it - to default_shell before proceeding. - - * make.h [sgi]: No alloca.h, after all. - -Wed Jan 15 12:30:04 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * read.c (multi_glob): Cons up the chain of the results of glob - from back to front, so it comes out in forward order. - - * job.c (construct_command_argv_internal): Don't eat char following - backslash-NL. - -Mon Jan 13 19:16:56 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * Version 3.62.1. - - * default.c (default_variables) [ultrix]: GET=get, like USG. - - * job.c (construct_command_argv_internal): Remove tabs following - backslash-NL combos in the input line, so they don't show up when - that line is printed. - - * read.c (read_makefile): Don't collapse_continuations the line on - input; do it on the copy we do remove_comments on. - For rule lines, collapse_continuations the line after chopping - ";cmds" off the end, so we don't eat conts in the cmds. - Give error for ";cmds" with no rule. - * job.c (construct_command_argv_internal): Eat backslash-NL combos - when constructing the line to recurse on for slow, too. - -Sat Jan 11 02:20:27 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - - * file.c (enter_file): Don't strip leading `./'s. - * read.c (parse_file_seq): Take new arg STRIP; if nonzero, do it here. - * default.c (set_default_suffixes), function.c (string_glob), - read.c (read_makefile), rule.c (install_pattern_rule): Change callers. - - * default.c (default_variables) [_IBMR2]: FC=xlf - - * job.c (construct_command_argv_internal): Turn backslash-NL and - following whitespace into a single space, rather than just eating - the backslash. - - * make.texinfo (Copying): @include gpl.texinfo, rather than - duplicating its contents. - -Fri Nov 8 20:06:03 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Make sure not to bother - processing an empty line. - - * Version 3.62.0. - - * job.c (construct_command_argv_internal): Always recurse for slow; - simple case didn't handle finding newlines. - -Tue Nov 5 18:51:10 1991 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) - - * job.c (construct_command_argv_internal): Set RESTP properly when - slow; don't \ify past a newline. - -Fri Nov 1 19:34:28 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu) - - * make.h [sgi]: #include . - - -See ChangeLog.1 for earlier changes. +See ChangeLog.2 for earlier changes. diff --git a/ChangeLog.2 b/ChangeLog.2 new file mode 100644 index 0000000..d30cfa4 --- /dev/null +++ b/ChangeLog.2 @@ -0,0 +1,6648 @@ +2000-06-23 Paul D. Smith + + * main.c (main): Replace EXIT_SUCCESS, EXIT_FAILURE, and + EXIT_TROUBLE with MAKE_SUCCESS, MAKE_FAILURE, and MAKE_TROUBLE. + * make.h: Define these macros. + + * Version 3.79.1 released. + + * configure.in: Add a new option, --disable-nsec-timestamps, to + avoid using sub-second timestamps on systems that support it. It + can lead to problems, e.g. if your makefile relies on "cp -p". + * README.template: Document the issue with "cp -p". + + * config.guess, config.sub: Updated. + +2000-06-22 Paul D. Smith + + * job.c (start_job_command): Increment commands_started before the + special check for ":" (empty command) to avoid spurious "is up to + date" messages. Also move the test for question_flag after we + expand arguments, and only stop if the expansion provided an + actual command to run, not just whitespace. This fixes PR/1780. + +2000-06-21 Paul D. Smith + + * read.c (read_makefile): If we find a semicolon in the target + definition, remember where it was. If the line turns out to be a + target-specific variable, add back the semicolon and everything + after it. Fixes PR/1709. + +2000-06-19 Paul D. Smith + + * config.h-vms.template: #define uintmax_t for this system. + * config.ami.template: Ditto. + * config.h.W32.template: Ditto. + + * configure.in: We don't use select(2) anymore, so don't bother + checking for it. + * acconfig.h: Ditto. + * acinclude.m4: Ditto. + + * file.c (all_secondary): New static global; if 1 it means + .SECONDARY with no prerequisites was seen in the makefile. + (snap_deps): Set it appropriately. + (remove_intermediates): Check it. + (num_intermediates): Remove this global, it's not used anywhere. + (considered): Move this to remake.c and make it static. + + * NEWS: Document the change to .SECONDARY. + * make.texinfo (Special Targets): Document the change to .SECONDARY. + + * implicit.c (pattern_search): Remove the increment of + num_intermediates; it's not used. + * filedef.h: Remove num_intermediates and considered. + + * function.c (handle_function): If the last argument was empty, we + were pretending it didn't exist rather than providing an empty + value. Keep looking until we're past the end, not just at the end. + + * implicit.c (pattern_search): Multi-target implicit rules weren't + expanding the "also made" targets correctly if the pattern didn't + contain a slash but the target did; in that case the directory + part wasn't being added back to the stem on the "also made" + targets. Reported by Seth M LaForge , with + a patch. + +2000-06-17 Eli Zaretskii + + * Makefile.DOS.template (DESTDIR, bindir, datadir, libdir) + (infodir, mandir, includedir): Support installation under a + non-default DESTDIR. + + * remake.c (f_mtime): Fix the spelling of __MSDOS__. + + * configh.DOS.template (HAVE_FDOPEN, HAVE_MKSTEMP): Define. + +2000-06-14 Paul D. Smith + + * acinclude.m4 (pds_WITH_GETTEXT): rewrite fp_WITH_GETTEXT and + rename it to avoid confusion. This version is very specific: it + won't accept any gettext that isn't GNU. If the user doesn't + explicitly ask for the included gettext, we look to see if the + system gettext is GNU (testing both the actual libintl library, + and the libintl.h header file). Only if the system gettext is + really GNU gettext will we allow it to be used. + (pds_CHECK_SYSTEM_GETTEXT): A helper function. + +2000-06-13 Paul D. Smith + + * gettext.h: If we have libintl.h, use that instead of any of the + contents of gettext.h. We won't check for libintl.h unless we're + using the system gettext. + + * function.c (func_word): Clarify error message. + +2000-06-10 Paul Eggert + + Support nanosecond resolution on hosts with 64-bit time_t and + uintmax_t (e.g. 64-bit Sparc Solaris), by splitting + FILE_TIMESTAMP into a 30-bit part for nanoseconds, with the + rest for seconds, if FILE_TIMESTAMP is at least 64 bits wide. + + * make.h: Always define FILE_TIMESTAMP to be uintmax_t, for + simplicity. + + * filedef.h (FILE_TIMESTAMP_HI_RES, FILE_TIMESTAMP_LO_BITS) + (UNKNOWN_MTIME, NONEXISTENT_MTIME, OLD_MTIME) + (ORDINARY_MTIME_MIN, ORDINARY_MTIME_MAX): New macros. + (FILE_TIMESTAMP_STAT_MODTIME): Now takes fname arg. All uses changed. + (FILE_TIMESTAMP_DIV, FILE_TIMESTAMP_MOD) + (FILE_TIMESTAMP_FROM_S_AND_NS): Remove. + (FILE_TIMESTAMP_S, FILE_TIMESTAMP_NS): Use shifts instead of + multiplication and division. Offset the timestamps by + ORDINARY_MTIME_MIN. + (file_timestamp_cons): New decl. + (NEW_MTIME): Now just the maximal timestamp value, as we no longer use + -1 to refer to nonexistent files. + + * file.c (snap_deps, print_file): Use NONEXISTENT_MTIME, + UNKNOWN_MTIME, and OLD_MTIME instead of magic constants. + * filedef.h (file_mtime_1): Likewise. + * main.c (main): Likewise. + * remake.c (update_file_1, notice_finished_file, check_dep) + (f_mtime, name_mtime, library_search): Likewise. + * vpath.c (selective_vpath_search): Likewise. + + * remake.c (f_mtime): Do not assume that (time_t) -1 equals + NONEXISTENT_MTIME. When futzing with time stamps, adjust by + multiples of 2**30, not 10**9. Do not calculate timestamp + adjustments on DOS unless they are needed. + + * commands.c (delete_target): Do not assume that + FILE_TIMESTAMP_S yields -1 for a nonexistent file, as that is + no longer true with the new representation. + + * file.c (file_timestamp_cons): New function, replacing + FILE_TIMESTAMP_FROM_S_AND_NS. All uses changed. + (file_timestamp_now): Use FILE_TIMESTAMP_HI_RES instead of 1 < + FILE_TIMESTAMPS_PER_S to determine whether we're using hi-res + timestamps. + (print_file): Print OLD_MTIME values as "very old" instead of + as a timestamp. + +2000-05-31 Paul Eggert + + * remake.c (name_mtime): Check for stat failures. Retry if EINTR. + +2000-05-24 Paul D. Smith + + * main.c (decode_switches): The "positive_int" switch uses atoi() + which succeeds for any input, and doesn't notice if extra, + non-digit text is after the number. This causes make to mis-parse + command lines like "make -j 5foo" as "make -j5" (ignoring "foo" + completely) instead of "make -j0 5foo" (where "5foo" is a + target). Fix this by checking the value by hand. We could use + strtol() if we were sure of having it; this is the only + questionable use of atoi() I found so we'll just stick with that. + Fixes PR/1716. + + * i18n/ja.po, i18n/nl.po, i18n/pt_BR.po: New translation files. + * configure.in (ALL_LINGUAS): Added pt_BR. + +2000-05-22 Paul Eggert + + * remake.c (f_mtime): Fix bug when handling future odd + timestamps in the WINDOWS32 case. Do not bother initializing + static var to zero. Simplify code that works around WINDOWS32 + and __MSDOS__ time skew brain damage. + +2000-05-22 Paul Eggert + + * job.c: Don't include time.h, as make.h already does this. + +2000-05-22 Paul Eggert + + * configure.in (AC_CHECK_HEADERS): Add sys/time.h. + (AC_HEADER_TIME): Add. + (clock_gettime): Prefer -lrt to -lposix4, for Solaris 7. + (gettimeofday): Add check for standard version of gettimeofday. + This merges changes written by Paul D. Smith. + + * file.c (file_timestamp_now): Use gettimeofday if available + and if clock_gettime does not work. Don't bother with + high-resolution clocks if file timestamps have only one-second + resolution. + + * make.h : Include, conditionally on the usual + TIME_WITH_SYS_TIME and HAVE_SYS_TIME_H macros. This is needed + for gettimeofday. + +2000-05-20 Paul D. Smith + + * read.c (read_makefile): We weren't keeping makefile names around + unless there was a rule defined in them; but now we need to keep + them for variables as well. Forget trying to be fancy: just keep + every makefile name we successfully open. + + * remote-cstms.c (start_remote_job_p): Change DB_EXTRA (?) to DB_JOBS. + +2000-05-17 Paul Eggert + + * commands.c (chop_commands): Ensure ctype macro args are nonnegative. + * expand.c (variable_expand_string): Likewise. + * function.c (subst_expand, lookup_function, msdos_openpipe): + Likewise. + * job.c (vms_redirect, start_job_command, new_job, child_execute_job, + construct_command_argv_internal, construct_command_argv): Likewise. + * main.c (decode_env_switches, quote_for_env): Likewise. + * misc.c (collapse_continuations, end_of_token, end_of_token_w32, + next_token): Likewise. + * read.c (read_makefile, do_define, conditional_line, + find_char_unquote,get_next_mword): Likewise. + * variable.c (try_variable_definition): Likewise. + * vpath.c (construct_vpath_list): Likewise. + * w32/pathstuff.c (convert_vpath_to_windows32): Likewise. + +2000-05-10 Eli Zaretskii + + * main.c (main) [__MSDOS__]: Add SIGFPE to signals we block when + running child programs, to prevent Make from dying on Windows 9X + when the child triggers an FP exception. + +2000-05-08 Paul D. Smith + + * dir.c (find_directory) [WINDOWS32]: If we strip a trailing "\" + from the directory name, remember to add it back. The argument + might really be inside a longer string (e.g. %Path%) and if you + don't restore the "\" it'll be truncated permanently. Fixes PR/1722. + Reported by + +2000-05-02 Paul D. Smith + + * job.c (construct_command_argv_internal) [WINDOWS32]: Added "rd" + and "rmdir" to the list of command.com commands. + Reported by Elod Horvath + +2000-04-24 Paul D. Smith + + * i18n/ja.po: New translation file from the Japanese language team. + +2000-04-18 Paul D. Smith + + * remake.c (f_mtime): If ar_member_date() returns -1 (the member + doesn't exist), then return (FILE_TIMESTAMP)-1 rather than + returning the timestamp calculated from the value -1. Fixes PR/1696. + Reported by Gilles Bourhis . + +2000-04-17 Paul D. Smith + + * config.h.W32.template: Add LOCALEDIR macro resolving to "". + * w32/subproc/sub_proc.c (process_begin): Remove reference to + debug_flag; change it to a DB() call. Fixes PR/1700. + Reported by Jim Smith + +2000-04-17 Bruno Haible + + * arscan.c [BeOS]: Add replacement for nonexistent from GNU + binutils. + +2000-04-11 Paul D. Smith + + * function.c (expand_builtin_function): If no arguments were + provided, just quit early rather than changing each function to + test for this. + (function_table[]): Change the min # of arguments to 0 for all + those functions for which it makes sense (currently everything + that used to take a minimum of 1 argument, except $(call ...)). + Fixes PR/1689. + +2000-04-09 Eli Zaretskii + + * README.DOS: Add instructions to install a binary distro. + Mention latest versions of Windows. + +2000-04-07 Eli Zaretskii + + * main.c (main): Rename TMP_TEMPLATE into DEFAULT_TMPDIR, and use + it for the directory of the temporary file. If P_tmpdir is + defined, use it in preference to "/tmp/". Try $TMPDIR, $TEMP, and + $TMP in the environment before defaulting to DEFAULT_TMPDIR. + (print_version): Add year 2000 to the Copyright line. + +2000-04-04 Paul D. Smith + + * Version 3.79 released. + + * make.texinfo: Update documentation with new features for 3.79. + + * function.c (func_wordlist): Don't re-order arguments to + wordlist. + +2000-04-03 Paul D. Smith + + * remake.c (f_mtime): Archive member timestamps are stored as + time_t, without nanoseconds. But, f_mtime() wants to return + nanosecond info on those systems that support it. So, convert the + return value of ar_member_date() into a FILE_TIMESTAMP, using 0 as + the nanoseconds. + +2000-03-28 Paul D. Smith + + * Version 3.78.92 released. + + * build.template: Updates for gettext support; some bugs fixed. + +2000-03-27 Paul D. Smith + + * config.guess, config.sub: Updated from config CVS archive at + :pserver:anoncvs@subversions.gnu.org:/home/cvs as of today. + + * read.c (record_files): Check if expanding a static pattern + rule's prerequisite pattern leaves an empty string as the + prerequisite, and issue an error if so. Fixes PR/1670. + (read_makefile): Store the starting linenumber for a rule in + TGTS_STARTED. + (record_waiting_files): Use the TGTS_STARTED value for the file + location passed to record_file() instead of the current + linenumber, so error messages list the line where the target was + defined instead of the line after the end of the rule definition. + + * remake.c (start_updating, finish_updating, is_updating): Fix + PR/1671; circular dependencies in double-colon rules are not + diagnosed. These macros set the updating flag in the root + double-colon file instead of the current one, if it's part of a + double-colon list. This solution provided by Tim Magill + ; I just changed the macro names :). + (update_file_1): Call them. + (check_dep): Call them. + + The change to not automatically evaluate the $(call ...) + function's arguments breaks recursive use of call. Although using + $(if ...) and $(foreach ...) in $(call ...) macros is important, + the error conditions generated are simply to obscure for me to + feel comfortable with. If a method is devised to get both + working, we'll revisit. For now, remove this change. + + * function.c (function_table): Turn on the expand bit for func_call. + (func_call): Don't expand arguments for builtin functions; that + will have already been done. + +2000-03-26 Paul D. Smith + + * file.c (remove_intermediates): Never remove targets explicitly + requested on the command-line by checking the cmd_target flag. + Fixed PR/1669. + +2000-03-23 Paul Eggert + + * filedef.h (FILE_TIMESTAMP_STAT_MODTIME): Use st_mtime instead of + st_mtim.tv_sec; the latter doesn't work on Unixware. + +2000-03-18 Paul D. Smith + + * file.c (file_hash_enter): If we're trying to change a file into + itself, just return. We used to assert this wasn't true, but + someone came up with a weird case involving archives. After + playing with it for a while I decided it was OK to ignore it. + + * default.c: Define COFLAGS to empty to avoid spurious warnings. + + * filedef.h: Change #if ST_MTIM_NSEC to #ifdef; this is a macro + containing the name of the nsec field, not true/false. + * make.h: Ditto. + Reported by Marco Franzen . + +2000-03-08 Tim Magill + + * remake.c (update_file): Return the exit status of the pruned + file when pruning, not just 0. Fixes PR/1634. + +2000-02-24 Paul D. Smith + + * configure.in: Close a minor potential security hole; if you're + reading makefiles from stdin (who does that?) you could run into a + race condition with the temp file using mktemp() or tmpnam(). Add + a check for mkstemp() and fdopen(). + * main.c (open_tmpfile): New function to open a temporary file. + If we have mkstemp() (and fdopen()), use that. If not use + mktemp() or tmpnam(). If we have fdopen(), use open() to open the + file O_CREAT|O_EXCL. If not, fall back to normal fopen() (insecure). + (main): Call it. + * job.c (child_execute_job) [VMS]: Call it. + + * variable.c (lookup_variable): If we find a variable which is + being expanded, then note it but keep looking through the rest of + the set list to see if we can find one that isn't. If we do, + return that. If we don't, return the original. Fix for PR/1610. + + While implementing this I realized that it also solves PR/1380 in + a much more elegant way. I don't know what I was smoking before. + So, remove the hackage surrounding the original fix for that (see + below). Change this function back to lookup_variable and remove + the extra setlist argument. + * variable.h (recursively_expand_setlist): Remove the macro, + rename the prototype, and remove the extra setlist argument. + (lookup_variable): Ditto. + * expand.c (recursively_expand): Rename and remove the extra + setlist argument. + (reference_variable): Use lookup_variable() again. + (allocated_variable_append): Remove the extra setlist argument. + +2000-02-21 Paul D. Smith + + * README.template: A few updates. + + * i18n/de.po: New version from the German translation team. + +2000-02-09 Paul D. Smith + + * Version 3.78.91 released. + +2000-02-07 Paul D. Smith + + * read.c (read_makefile): Reset *p2 to ':', not *colonp. If any + filenames contained backslashes the resulting output (without + backslashes) will be shorter, so setting *colonp doesn't change + the right character. Fix for PR/1586. + + For += target-specific variables we need to remember which + variable set we found the variable in, so we can start looking + from there in the next iteration (otherwise we might see it again + in recursively_expand and fail!). This is turning into a hack; if + it gets any worse we'll have to rethink this entire algorithm... + implementing expansion of these references separately from the + "normal" expansion, say, instead of using the same codepath. + Actually, it's already "worse enough" :-/. + Fix for PR/1380. + + * variable.h (recursively_expand_setlist): Rename + recursively_expand to add a struct variable_set_list argument, and + make a macro for recursively_expand. + (lookup_variable_setlist): Rename lookup_variable to add a struct + variable_set_list argument, and make a macro for lookup_variable. + + * expand.c (recursively_expand_setlist): Take an extra struct + variable_set_list argument and pass it to allocated_variable_append(). + (reference_variable): Use lookup_variable_setlist() and pass the + returned variable_set_list to recursively_expand_setlist. + (allocated_variable_append): Take an extra setlist argument and + use this as the starting place when searching for the appended + expansion. If it's null, use current_variable_set_list as before. + + * variable.c (lookup_variable_setlist): If the LISTP argument is + not nil, set it to the list containing the variable we found. + +2000-02-04 Paul D. Smith + + * variable.c (print_variable): Write out filename/linenumber + information for the variable definition if present. + (define_variable_in_set): Store filename information if provided. + (define_variable, define_variable_for_file): Removed. + (try_variable_definition): Use define_variable_loc() to keep + variable definition location information. + * read.c (read_makefile): Keep variable definition location info. + (do_define): Ditto. + (record_target_var): Ditto. + * variable.h (define_variable_in_set): New fileinfo argument. + (define_variable, define_variable_loc, define_variable_for_file): + Declare new macros. + + Fix PR/1407: + + * filedef.h (struct file): Rename patvar to pat_variables and make + it just a variable_set_list; we need our own copy of the pattern + variable's variable set list here to avoid overwriting the global + one. + * variable.c (initialize_file_variables): Move the instantiation + of the pat_variables pointer here. Only do the search after we're + done reading the makefiles so we don't search too early. If + there's a pat_variables value, set up the variables next ptr. + * expand.c (variable_expand_for_file): Remove the setup of the + pat_variables info; it's done earlier now to ensure the parent's + pattern variables are set up correctly as well. + +2000-02-03 Paul D. Smith + + * job.c (sh_chars_dos) [WINDOWS32]: Add "&" as a shell + metacharacter for the W32 DOS shell. + Reported by Warren Jones . + +2000-02-02 Paul D. Smith + + Fixes for the OpenVMS port from Hartmut Becker + + * config.h-vms [VMS]: Define LOCALEDIR to something; needed for + the expansion of bindtextdomain() even though it's a no-op. + * vmsfunctions.c (strcmpi): Remove duplicate definition of strcmpi(). + (readdir): Use DB() instead of testing debug_flag. + * dir.c (file_impossible) [VMS]: Search "p" not "name". + * job.c [VMS]: Switch from debug_flag to the new DB macro. Add + some i18n _() macros (even though VMS doesn't yet support it). + + * function.c (patsubst_expand): Change "len" to not be unsigned to + avoid type mismatches. + + * main.c (main): Declare signame_init() if we're going to call it. + +2000-01-29 Eli Zaretskii + + * Makefile.DOS.template: Track changes in Makefile.in + (install-recursive, uninstall-recursive): Add missing targets. + (DESTDIR): Define. + (install-binPROGRAMS, uninstall-binPROGRAMS): Use $(DESTDIR). + + * default.c (default_variables) [__MSDOS__]: Define CXX to gpp. + +2000-01-27 Paul D. Smith + + * gettext.c: Some warning cleanups, and a fix for systems which + don't define HAVE_ALLOCA (the workaround code was included + twice). + +2000-01-26 Paul D. Smith + + * Version 3.78.90 released. + +2000-01-25 Paul D. Smith + + Change gettext support to use the simplified version in libit 0.7. + + * getopt.c, make.h: Use gettext.h instead of libintl.h. + * ABOUT-NLS, gettext.h, gettext.c: New files from libit 0.7. + Modified to remove some static declarations which aren't defined. + * acconfig.h: Use new gettext #defines. + * acinclude.m4: Add fp_WITH_GETTEXT; remove AM_GNU_GETTEXT. + * configure.in: Call fp_WITH_GETTEXT instead. + * Makefile.am: New gettext stuff. Also force inclusion of glob + files for systems which have LIBC glob. + + * i18n/Makefile.am, i18n/.cvsignore: New dir for translation files. + * i18n/de.po, i18n/es.po, i18n/fr.po, i18n/ko.po, i18n/nl.po: + * i18n/pl.po, i18n/ru.po: Import translations already done for + earlier versions of GNU make. Thanks for that work!! + + * po/Makefile.in.in, po/POTFILES.in: Removed. + +2000-01-23 Paul D. Smith + + * main.c (decode_debug_flags): If debug_flag is set, enable all + debugging levels. + (debug_flag): Resurrect this flag variable. + (switches): Make -d give the old behavior of turning on all + debugging. Change --debug alone to emit basic debugging and take + optional arguments to expand debugging. + * NEWS: Document the new debugging options. + + * remake.c (no_rule_error): Remove this function. This tries to + fix a real problem--see the description with the introduction of + this function below. However, the cure is worse than the disease + and this approach won't work. + (remake_file): Put the code from no_rule_error back here. + (update_file_1): Remove call to no_rule_error. + + * filedef.h (struct file): Remove mfile_status field. + +2000-01-22 Paul D. Smith + + Integrate GNU gettext support. + + * configure.in: Add AM_GNU_GETTEXT. + * Makefile.am: Add options for setting LOCALEDIR, -Iintl, etc. + * acinclude.m4: Add gettext autoconf macros. + * acconfig.h: Add new gettext #defines. + * make.h: Include libintl.h. Make sure _() and N_() macros are + declared. Make gettext() an empty macro is NLS is disabled. + * main.c (struct command_switch switches[]): Can't initialize + static data with _() (gettext calls), so use N_() there then use + gettext() directly when printing the strings. + * remake.c (no_rule_error): The string constants can't be static + when initializing _() macros. + * file.c (print_file): Reformat a few strings to work better for + translation. + * po/POTFILES.in, po/Makefile.in.in: New files. Take + Makefile.in.in from the latest GNU tar distribution, as that + version works better than the one that comes with gettext. + * NEWS: Mention i18n ability. + +2000-01-21 Paul D. Smith + + Installed patches for the VMS port. + Patches provided by: Hartmut Becker + + * readme.vms, arscan.c, config.h-vms, default.c, dir.c, file.c: + * implicit.c, job.c, make.h, makefile.com, makefile.vms, rule.c: + * variable.c, vmsdir.h, vmsfunctions.c, vmsify.c, glob/glob.c: + * glob/glob.h: Installed patches. See readme.vms for details. + +2000-01-14 Andreas Schwab + + * dir.c (read_dirstream): Initialize d_type if it exists. + +2000-01-11 Paul D. Smith + + Resolve PR/xxxx: don't automatically evaluate the $(call ...) + function's arguments. While we're here, clean up argument passing + protocol to always use simple nul-terminated strings, instead of + sometimes using offset pointers to mark the end of arguments. + This change also fixes PR/1517. + Reported by Damien GIBOU . + + * function.c (struct function_table_entry): Remove the negative + required_args hack; put in explicit min and max # of arguments. + (function_table): Add in the max value. Turn off the expand bit + for func_call. + (expand_builtin_function): Test against minimum_args instead of + the obsolete required_args. + (handle_function): Rewrite this. We don't try to be fancy and + pass one style of arguments to expanded functions and another + style to non-expanded functions: pass pointers to nul-terminated + strings to all functions. + (func_call): Rewrite this. If we are invoking a builtin function + and it's supposed to have its arguments expanded, do that (since + it's not done by handle_function for $(call ...) anymore). For + non-builtins, just add the variables as before but mark them as + recursive so they'll be expanded later, as needed. + (func_if): All arguments are vanilla nul-terminated strings: + remove trickery with "argv[1]-1". + (func_foreach): Ditto. + + * expand.c (expand_argument): If the second arg is NULL, expand + the entire first argument. + + * job.c (new_job): Zero the child struct. This change was just + made to keep some heap checking software happy, not because there + was an actual bug (the important memory was being cleared properly). + +1999-12-15 Paul D. Smith + + * variable.c (print_variable): Print the variable with += if the + append flag is set. + + * implicit.c (pattern_search): Remove the extra check of the + implicit flag added on 8/24/1998. This causes problems and the + reason for the change was better resolved by the change made to + check_deps() on 1998-08-26. This fixes PR/1423. + +1999-12-08 Paul D. Smith + + * dir.c (dir_setup_glob): On 64 bit ReliantUNIX (5.44 and above) + in LFS mode, stat() is actually a macro for stat64(). Assignment + doesn't work in that case. So, stat is a macro, make a local + wrapper function to invoke it. + (local_stat): Wrapper function, if needed. + Reported by Andrej Borsenkow . + +1999-12-02 Paul D. Smith + + * remake.c (update_file): Move the considered test outside the + double-colon loop, _but_ make sure we test the double_colon target + not the "current" target. If we stop early because one + double-colon target is running, mark all the rest considered and + try to start their prerequisites (so they're marked considered). + Fix for PR/1476 suggested by Tim Magill . + +1999-11-22 Rob Tulloh + + * function.c (windows32_openpipe, func_shell): Correct Windows32 + problem where $(shell nosuchfile) would incorrectly exit make. The + fix is to print the error and let make continue. + Reported by David Masterson . + + * w32/subproc/misc.c (arr2envblk): Memory leak fix. + +1999-11-21 Paul D. Smith + + Rework GNU make debugging to provide different levels of output. + + * NEWS: mention it. + * debug.h: New file. Define various debugging levels and macros. + * function.c, implicit.c, job.c, main.c, misc.c, read.c, remake.c + * remote-cstms.c, vmsfunctions.c: Replace all code depending on + debug_flag with invocations of debugging macros. + * make.h: Remove debug_flag and DEBUGPR, add db_level. + +1999-11-18 Paul Eggert + + * acinclude.m4 (AC_SYS_LARGEFILE_FLAGS): Work around a problem + with the QNX 4.25 shell, which doesn't propagate exit status of + failed commands inside shell assignments. + +1999-11-17 Paul D. Smith + + * function.c (func_if): Find the end of the arg list by testing + the next item for NULL; any other test is not correct. + Reported by Graham Reed (PR/1429). + + Fix += when used in a target-specific variable context. + + * variable.h: New bitfield APPEND set if we have a += + target-specific variable. + + * variable.c (try_variable_definition): Add an argument to specify + if we're trying a target-specific variable. If we are and it's an + append style, don't append it, record it as normal recursive, but + set the APPEND flag so it'll be expanded later. + * main.c (handle_non_switch_argument): Use new + try_variable_definition() signature. + * read.c (read_makefile,record_target_var): Ditto. + + * expand.c (allocated_variable_append): New function: like + allocated_variable_expand(), but we expand the same variable name + in the context of the ``next'' variable set, then we append this + expanded value. + (recursively_expand): Invoke it, if the APPEND bit is set. + +1999-11-10 Paul D. Smith + + * file.c (snap_deps): If the .NOTPARALLEL target is defined, turn + off parallel builds for this make only (still allow submakes to be + run in parallel). + * main.c: New variable, ``not_parallel''. + * make.h: Add an extern for it. + * job.c (new_job): Test NOT_PARALLEL as well as JOB_SLOTS. + * NEWS: Add info on .NOTPARALLEL. + * make.texinfo (Special Targets): Document it. + + * configure.in (GLOBDIR): Set to "glob" if we need to build the + glob library. + * Makefile.am (SUBDIRS): Use the GLOBDIR variable instead of + "glob" so we don't try to build glob if we don't need to (if we + have GLIBC glob). Reported by Lars Hecking . + + * main.c (main): Don't put "***" in the clock skew warning + message. Reported by karl@gnu.org. + + * make.h: Remove unneeded signal setup. + + * signame.c: Remove extraneous #includes; some versions of Ultrix + don't protect against multiple inclusions and it causes compile + errors. Reported by Simon Burge . + +1999-10-15 Paul D. Smith + + * main.c (quote_for_env): Rename from quote_as_word(). + + * make.h, *.c: Prefer strchr() and strrchr() in the code + rather than index() and rindex(). Define strchr/strrchr in terms + of index/rindex if the former aren't supported. + + * default.c (CHECKOUT,v): Replace the fancy, complicated + patsubst/filter expression with a simple $(if ...) expression. + + * main.c (print_usage): Add the bug reporting mailing address to + the --help output, as per the GNU coding standards. + Reported by Paul Eggert . + + * README.customs: Installed information on running Customs-ized + GNU make and setuid root, collected by Ted Stern . + + * read.c (read_all_makefiles): PR/1394: Mark the end of the next + token in the MAKEFILES value string _before_ we dup it. + +1999-10-13 Paul D. Smith + + * configure.in (make_cv_sys_gnu_glob): We used to add the -Iglob + flag to CPPFLAGS, but that loses if the user specifies his own + CPPFLAGS; this one gets added _after_ his and if he happens to + have an old or broken glob.h--boom. Instead, put it in GLOBINC + and SUBST it. + + * Makefile.am (INCLUDES): Add @GLOBINC@ to the INCLUDES macro; + these things get on the compile line well before the user's + CPPFLAGS. + +1999-10-12 Paul D. Smith + + * remake.c (notice_finished_file): If we get here and -n is set, + see if all the command lines are marked recursive. If so, then we + ran every command there is, so check the mtime on this file just + like we would normally. If not, we assume the command we didn't + run would updates the target and set mtime of the target to "very new". + + * job.c (start_job_command): Update lines_flags in the file's cmds + structure with any per-line tokens we found (`@', `-', `+'). + +1999-10-08 Paul D. Smith + + * variable.c (initialize_file_variables): Always recurse to + initialize the parent's file variables: the parent might not have + any rules to run so it might not have been initialized before + this--we need this to set up the chain properly for + target-specific variables. + +1999-09-29 Paul Eggert + + * main.c (quote_as_word): Always quote for decode_env_switches + instead of for the shell, so that arguments with strange + characters are are passed to submakes correctly. Remove + double_dollars arg; we always double dollars now. All callers + changed. + (decode_env_switches): Don't run off the end of an environment + variable whose contents ends in a unescaped backslash. + +1999-09-23 Paul D. Smith + + * commands.c, function.c, job.c, read.c: Cast arguments to + ctype.h functions/macros to _unsigned_ char for portability. + + * remake.c, function.c: Compiler warning fixes: the second + argument to find_next_token() should be an _unsigned_ int*. + Reported by Han-Wen Nienhuys . + +1999-09-23 Paul D. Smith + + * Version 3.78.1 released. + + * make.texinfo: Update version/date stamp. + + * main.c (main): Argh. For some reason we were closing _all_ the + jobserver pipes before we re-exec'd due to changed makefiles. + This means that any re-exec got a "jobserver unavailable" error :-/. + I can't believe we didn't notice this before. + +1999-09-22 Paul D. Smith + + * Version 3.78 released. + + * main.c (main): Only fail on multiple --jobserver-fds options if + they aren't all the same. Some makefiles use things like + $(MAKE) $(MFLAGS) which will cause multiple, identical copies of + --jobserver-fds to show up. + +1999-09-16 Paul D. Smith + + * main.c (define_makeflags): Zero out FLAGSTRING to avoid + uninitialized memory reads when checking *p != '-' in the loop. + +1999-09-15 Paul D. Smith + + * Version 3.77.97 released. + + * configure.in (MAKE_HOST): AC_SUBST this so it will go into the + makefile. + * Makefile.am (check-local): Print a success banner if the check + succeeds. + (check-regression): A bit of fine-tuning. + +1999-09-15 Eli Zaretskii + + * README.DOS.template: Document requirements for the test suite. + * Makefile.DOS.template: Updates to allow the test suite to run + from "make check". + + * main.c (main): Handle it if argv[0] isn't an absolute path. + +1999-09-13 Paul D. Smith + + * Version 3.77.96 released. + + * Makefile.am (loadavg): Use CPPFLAGS, etc. to make sure we get + all the right #defines to compile. + (check-regression): Look for the regression test suite in the make + package itself. If we're building remotely, use symlinks to make + a local copy. + (dist-hook): Put the test suite into the tar file. + + * configure.in: Look for perl for the test suite. + +1999-09-10 Paul Eggert + + * acinclude.m4 (AC_SYS_LARGEFILE_FLAGS): If on HP-UX 10.20 or + later, and using GCC, define __STDC_EXT__; this works around a + bug in GCC 2.95.1. + +1999-09-08 Paul D. Smith + + * main.c (print_version): Ugh. GLIBC's configure tries to check + make version strings and is too aggressive with their matching + expressions. I've struck a deal with them to leave the version + output as-is for 3.78, and they'll change their configure checks + so that I can change this back in the future. + +1999-09-07 Eli Zaretskii + + * job.c (construct_command_argv_internal) [__MSDOS__]: Add "echo" + and "unset" to the list of builtin shell commands. + + * configh.DOS.template (MAKE_HOST): Define to "i386-pc-msdosdjgpp" + which is the canonical name of the DJGPP host. + +1999-09-05 Paul D. Smith + + * Version 3.77.95 released. + + * make.texinfo (Make Errors): Document some new jobserver error + messages. + +1999-09-04 Eli Zaretskii + + * make.texinfo (Make Errors): Document the hint about 8 spaces + instead of a TAB. + (Call Function, Quick Reference): Use @code{$(1)}, not @var. + + * main.c (main) [__MSDOS__]: Say "on this platform" instead of "on + MS-DOS", since the MSDOS version could run on Windows. + +1999-09-03 Paul D. Smith + + * remake.c (notice_finished_file): Always set mtime_before_update + if it's not been set, not just if we ran some rules. Otherwise we + may have a situation where a target's prerequisite was rebuilt but + not changed, so this target's rules weren't run, then + update_goal_chain() sees mtime_before_update != last_mtime and + thinks that the top-level target changed when it really didn't. + This can cause an infinite loop when remaking makefiles. + (update_goal_chain): If we get back to the top and we don't know + what the goal's last_mtime was, find it now. We need to know so + we can compare it to mtime_before_update later (this is only + crucial when remaking makefiles--should we only do it then?) + +1999-09-02 Paul D. Smith + + * read.c (read_makefile): If "override" appears as the first + prerequisite, look further to ensure this is really a + target-specific variable definition, and not just some + prerequisite named "override". + +1999-09-01 Paul D. Smith + + * function.c (IS_PATHSEP) [WINDOWS32]: Allow backslash separators + for W32 platforms. + * read.c (record_files) [WINDOWS32]: Allow backslash separators + for W32 platforms. + * implicit.c (pattern_search) [WINDOWS32]: Allow backslash + separators for W32 platforms. + + * configure.in (MAKE_HOST): Define it to be the canonical build + host info, now that we need AC_CANONICAL_HOST anyway (for large + file support). + * version.c (make_host): Define a variable to MAKE_HOST so we're + sure to get it from the local config.h. + * main.c (print_version): Use it in the version information. + * config.ami.template: Add MAKE_HOST. + * configh.dos.template: Ditto. + * config.h.W32.template: Ditto. + * config.h-vms.template: Ditto. + + * main.c (main): Close the jobserver file descriptors if we need + to re-exec ourselves. + Also print more reasonable error if users force -jN for submakes. + This may be common for a while until people use the jobserver + feature. If it happens, we ignore the existing jobserver stuff + and use whatever they specified on the commandline. + (define_makeflags): Fixed a long-standing bug: if a long name + only option comes immediately after a single letter option with no + argument, then the option string is constructed incorrectly. For + example, with -w and --jobserver-fds you get "-w-jobserver-fds..." + instead of "-w --jobserver-fds..."; add in an extra " -". + + * make.texinfo (Phony Targets): Add another example of using + .PHONY with subdirectories/recursive make. + +1999-08-30 Paul D. Smith + + * README.W32.template: Renamed from README.W32 so it's + autogenerated during the dist. A few minor modifications. + + * configure.in: Check for kstat_open before AC_FUNC_GETLOADAVG + since the latter needs to know whether the former exists to give + an accurate result. + +1999-08-26 Rob Tulloh + + * NMakefile [WINDOWS32]: Now more robust. If you change a file + under w32/subproc, the make.exe will be relinked. Also added some + tests to make sure erase commands won't fail when executed in a + pristine build environment. + + * w32/subproc/sub_proc.c [WINDOWS32]: Added support for + HAVE_CYGWIN_SHELL. If you are using the Cygwin B20.1 release, it + is now possible to have have native support for this shell without + having to rely on klutzy BATCH_MODE_ONLY_SHELL. + + * config.h.W32 [WINDOWS32]: Added HAVE_CYGWIN_SHELL macro which + users can define if they want to build make to use this shell. + + * README.W32 [WINDOWS32]: Added informaton about + HAVE_CYGWIN_SHELL. Cleaned up text a bit to make it more current. + +1999-08-26 Paul Eggert + + Support large files in AIX, HP-UX, and IRIX. + + * acinclude.m4 (AC_LFS): Remove. Superseded by AC_SYS_LARGEFILE. + (AC_SYS_LARGEFILE_FLAGS, AC_SYS_LARGEFILE_SPACE_APPEND, + AC_SYS_LARGEFILE_MACRO_VALUE, AC_SYS_LARGEFILE): New macros. + (jm_AC_TYPE_UINTMAX_T): Check for busted compilers that can't + shift or divide unsigned long long. + (AM_PROG_CC_STDC): New macro; a temporary workaround of a bug in + automake 1.4. + + * configure.in (AC_CANONICAL_HOST): Add; required by new + AC_SYS_LARGEFILE. + (AC_SYS_LARGEFILE): Renamed from AC_LFS. + (AM_PROG_CC_STDC): Add. + + * config.guess, config.sub: New files, needed for AC_CANONICAL_HOST. + +1999-08-25 Paul Eggert + + * make.h (CHAR_MAX): New macro. + * main.c (struct command_switch): c is now int, + so that it can store values greater than CHAR_MAX. + (switches): Replace small numbers N with CHAR_MAX+N-1, + to avoid problems with non-ASCII character sets. + (short_option): New macro. + (init_switches, print_usage, define_makeflags): Use it instead of + isalnum. + +1999-08-25 Paul D. Smith + + * Version 3.77.94 released. + + * main.c (main) [__MSDOS__]: If the user uses -j, warn that it's + not supported and reset it. + + * make.h (ISDIGIT): Obtained this from the textutils distribution. + * main.c (decode_switches): Use it. + * function.c (is_numeric): Use it. + + * main.c (struct command_switch): Store the switch char in an + unsigned char to shut up GCC about using it with ctype.h macros. + Besides, it _is_ always unsigned. + +1999-08-24 Paul D. Smith + + * make.texinfo: Change "dependency" to "prerequisite" and + "dependencies" to "prerequisites". Various other cleanups related + to the terminology change. + * file.c: Change debugging and error messages to use + "prerequisite" instead of "dependency". + * implicit.c: Ditto. + * remake.c: Ditto. + * NEWS: Document it. + +1999-08-23 Paul D. Smith + + * remake.c (update_file): Move the considered check into the + double-colon rule loop, so we consider double-colon rules + individually (otherwise after the first is pruned, the rest won't + get run). + + * README.template: Minor changes. + + Remove the debugging features of the jobserver, so it no longer + writes distinct tokens to the pipe. Thus, we don't need to store + the token we get. A side effect of this is to remove a potential + "unavailable token" situation: make-1 invokes make-2 with its + special token and make-3 with a normal token; make-2 completes. + Now we're waiting for make-3 but using 2 tokens; our special token + is idle. In the new version we don't have special tokens per se, + we merely decide if we already have a child or not. If we don't, + we don't need a token. If we do, we have to get one to run the + next child. Similar for putting tokens back: if we're cleaning up + the last child, we don't put a token back. Otherwise, we do. + + * main.c: Add a new, internal flag --jobserver-fds instead of + overloading the meaning of -j. Remove job_slots_str and add the + stringlist jobserver_fds. + (struct command_switch): We don't need the int_string type. + (switches[]): Add a new option for --jobserver-fds and remove + conditions around -j. Make the description for the former 0 so it + doesn't print during "make --help". + (main): Rework jobserver parsing. If we got --jobserver-fds + make sure it's valid. We only get one and job_slots must be 0. + If we're the toplevel make (-jN without --jobserver-fds) create + the pipe and write generic tokens. + Create the stringlist struct for the submakes. + Clean up the stringlist where necessary. + (init_switches): Remove int_string handling. + (print_usage): Don't print internal flags (description ptr is 0). + (decode_switches): Remove int_string handling. + (define_makeflags): Remove int_string handling. + + * job.c: Remove my_job_token flag and all references to the + child->job_token field. + (free_job_token): Remove this and merge it into free_child(). + (reap_children): Rework the "reaped a child" logic slightly. + Don't call defunct free_job_token anymore. Always call + free_child, even if we're dying. + (free_child): If we're not freeing the only child, put a token + back in the pipe. Then, if we're dying, don't bother to free. + (new_job): If we are using the jobserver, loop checking to see if + a) there are no children or b) we get a token from the pipe. + + * job.h (struct child): Remove the job_token field. + +1999-08-20 Paul D. Smith + + * variable.c (try_variable_definition): Allocate for variable + expansion in f_append with a simple variable: if we're looking at + target-specific variables we don't want to trash the buffer. + Noticed by Reiner Beninga . + +1999-08-16 Eli Zaretskii + + * main.c (main) [__MSDOS__]: Mirror any backslashes in argv[0], to + avoid problems in shell commands that use backslashes as escape + characters. + +1999-08-16 Paul D. Smith + + * Version 3.77.93 released. + +1999-08-13 Paul D. Smith + + Another jobserver algorithm change. We conveniently forgot that + the blocking bit is shared by all users of the pipe, it's not a + per-process setting. Since we have many make processes all + sharing the pipe we can't use the blocking bit as a signal handler + flag. Instead, we'll dup the pipe's read FD and have the SIGCHLD + handler close the dup'd FD. This will cause the read() to fail + with EBADF the next time we invoke it, so we know we need to reap + children. We then re-dup and reap. + + * main.c (main): Define the job_rfd variable to hold the dup'd FD. + Actually dup the read side of the pipe. Don't bother setting the + blocking bit on the file descriptor. + * make.h: Declare the job_rfd variable. + * job.c (child_handler): If the dup'd jobserver pipe is open, + close it and assign -1 to job_rfd to notify the main program that + we got a SIGCHLD. + (start_job_command): Close the dup'd FD before exec'ing children. + Since we open and close this thing so often it doesn't seem + worth it to use the close-on-exec bit. + (new_job): Remove code for testing/setting the blocking bit. + Instead of EAGAIN, test for EBADF. If the dup'd FD has been + closed, re-dup it before we reap children. + + * function.c (func_shell): Be a little more accurate about the + length of the error string to allocate. + + * expand.c (variable_expand_for_file): If there's no filenm info + (say, from a builtin command) then reset reading_file to 0. + +1999-08-09 Paul D. Smith + + * maintMakefile: Use g in sed (s///g) to replace >1 variable per + line. + + * Makefile.DOS.template [__MSDOS__]: Fix mostlyclean-aminfo to + remove the right files. + +1999-08-01 Eli Zaretskii + + * function.c (msdos_openpipe) [__MSDOS__]: *Really* return a FILE + ptr. + +1999-08-01 Paul D. Smith + + New jobserver algorithm to avoid a possible hole where we could + miss SIGCHLDs and get into a deadlock. The original algorithm was + suggested by Roland McGrath with a nice refinement by Paul Eggert. + Many thanks as well to Tim Magill and Howard Chu, who also + provided many viable ideas and critiques. We all had a fun week + dreaming up interesting ways to use and abuse UNIX syscalls :). + + Previously we could miss a SIGCHLD if it happened after we reaped + the children but before we re-entered the blocking read. If this + happened to all makes and/or all children, make would never wake + up. + + We avoid this by having the SIGCHLD handler reset the blocking bit + on the jobserver pipe read FD (normally read does block in this + algorithm). Now if the handler is called between the time we reap + and the time we read(), and there are no tokens available, the + read will merely return with EAGAIN instead of blocking. + + * main.c (main): Set the blocking bit explicitly here. + * job.c (child_handler): If we have a jobserver pipe, set the + non-blocking bit for it. + (start_waiting_job): Move the token stuff back to new_job; if we + do it here then we're not controlling the number of remote jobs + started! + (new_job): Move the check for job slots to _after_ we've created a + child structure. If the read returns without getting a token, set + the blocking bit then try to reap_children. + + * make.h (EINTR_SET): Define to test errno if EINTR is available, + or 0 otherwise. Just some code cleanup. + * arscan.c (ar_member_touch): Use it. + * function.c (func_shell): Use it. + * job.c (reap_children): Use it. + * remake.c (touch_file): Use it. + +1999-07-28 Paul D. Smith + + * make.h: Define _() and N_() macros as passthrough to initiate + NLS support. + * : Add _()/N_() around translatable strings. + +1999-07-27 Paul D. Smith + + * read.c: Make sure make.h comes before other headers. + +1999-07-26 Paul D. Smith + + * make.texinfo (Quick Reference): Update with the new features. + +1999-07-25 Eli Zaretskii + + * remake.c [__MSDOS__]: Don't include variables.h, it's already + included. + + * function.c (msdos_openpipe) [__MSDOS__]: Return FILE ptr. + (func_shell) [__MSDOS__]: Fix the argument list. + + * Makefile.DOS.template: Update from Makefile.in. + + * README.DOS.template: Configure command fixed. + + * configh.dos.template: Update to provide definitions for + uintmax_t, fd_set_size_t, and HAVE_SELECT. + +1999-07-24 Paul D. Smith + + * Version 3.77.91 released. + + * configure.in: Changes to the boostrapping code: if build.sh.in + doesn't exist configure spits an error and generates an empty + build.sh file which causes make to be confused. + * maintMakefile: Don't build README early. + +1999-07-23 Paul D. Smith + + * job.c (my_job_token): This variable controls whether we've + handed our personal token to a subprocess or not. Note we could + probably infer this from the value of job_slots_used, but it's + clearer to just keep it separately. Job_slots_used isn't really + relevant when running the job server. + (free_job_token): New function: free a job token. If we don't + have one, no-op. If we have the personal token, reclaim it. If + we have another token, write it back to the pipe. + (reap_children): Call free_job_token. + (free_child): Call free_job_token. + (start_job_command): Remove duplicate test for '+' in the command. + If we don't appear to be running a recursive make, close the + jobserver filedescriptors. + (start_waiting_job): If our personal token is available, use that + instead of going to the server pipe. + (*): Add the token value to many debugging statements, and print + the child target name in addition to the ptr hex value. + Change the default "no token" value from '\0' to '-' so it looks + better in the output. + + * main.c (main): Install the child_handler with sigaction() + instead of signal() if we have it. On SysV systems, signal() uses + SysV semantics which are a pain. But sigaction() always does what + we want. + (main): If we got job server FDs from the environment, test them + to see if they're open. If not, the parent make closed them + because it didn't think we were a submake. Print a warning and + suggestion to use "+" on the submake invocation, and hard-set to + -j1 for this instance of make. + (main): Change the algorithm for assigning slots to be more + robust. Previously make checked to see if it thought a subprocess + was a submake and if so, didn't give it a token. Since make's + don't consume tokens we could spawn many of makes fighting for a + small number of tokens. Plus this is unreliable because submakes + might not be recognized by the parent (see above) then all the + tokens could be used up by unrecognized makes, and no one could + run. Now every make consumes a token from its parent. However, + the make can also use this token to spawn a child. If the make + wants more than one, it goes to the jobserver pipe. Thus there + will never be more than N makes running for -jN, and N*2 processes + (N makes and their N children). Every make can always run at + least one job, and we'll never deadlock. (Note the closing of the + pipe for non-submakes also solves this, but this is still a better + algorithm.) So! Only put N-1 tokens into the pipe, since the + topmost make keeps one for itself. + + * configure.in: Find sigaction. Disable job server support unless + the system provides it, in addition to either waitpid() or + wait3(). + +1999-07-22 Rob Tulloh + + * arscan.c (ar_member_touch) [WINDOWS32]: The ar_date field is a + string on Windows, not a timestamp. + +1999-07-21 Paul D. Smith + + * Version 3.77.90 released. + + * Makefile.am (AUTOMAKE_OPTIONS): Require automake 1.4. + + * function.c: Rearrange so we don't need to predeclare the + function_table array; K&R C compilers don't like that. + + * acinclude.m4 (AC_FUNC_SELECT): Ouch; this requires an ANSI C + compiler! Change to work with K&R compilers as well. + + * configure.in (AC_OUTPUT): Put build.sh back. I don't know how I + thought it would work this way :-/. We'll have to think of + something else. + * Makefile.am: Remove rule to create build.sh. + + * default.c (default_suffix_rules): Rearrange the default command + lines to conform to POSIX rules (put the filename argument $< + _after_ the OUTPUT_OPTION, not before it). + + * various: Changed !strncmp() calls to strneq() macros. + + * misc.c (sindex): Make slightly more efficient. + + * dir.c (file_impossible): Change savestring(X,strlen(X)) to xstrdup(). + * implicit.c (pattern_search): Ditto. + * main.c (enter_command_line_file): Ditto. + (main): Ditto. + * misc.c (copy_dep_chain): Ditto. + * read.c (read_makefile): Ditto. + (parse_file_seq): Ditto. + (tilde_expand): Ditto. + (multi_glob): Ditto. + * rule.c (install_pattern_rule): Ditto. + * variable.c (define_variable_in_set): Ditto. + (define_automatic_variables): Ditto. + * vpath.c (construct_vpath_list): Ditto. + + * misc.c (xrealloc): Some reallocs are non-standard: work around + them in xrealloc by calling malloc if PTR is NULL. + * main.c (main): Call xrealloc() directly instead of testing for + NULL. + + * function.c (func_sort): Don't try to free NULL; some older, + non-standard versions of free() don't like it. + + * configure.in (--enable-dmalloc): Install some support for using + dmalloc (http://www.dmalloc.com/) with make. Use --enable-dmalloc + with configure to enable it. + + * function.c (function_table_entry): Whoops! The function.c + rewrite breaks backward compatibility: all text to a function is + broken into arguments, and extras are ignored. So $(sort a,b,c) + returns "a"! Etc. Ouch. Fix it by making a positive value in + the REQUIRED_ARGS field mean exactly that many arguments to the + function; any "extras" are considered part of the last argument as + before. A negative value means at least that many, but may be + more: in this case all text is broken on commas. + (handle_function): Stop when we've seen REQUIRED_ARGS args, if >0. + (expand_builtin_function): Compare number of args to the absolute + value of REQUIRED_ARGS. + +1999-07-20 Paul D. Smith + + * job.c (start_job_command): Ensure that the state of the target + is cs_running. It might not be if we skipped all the lines due to + -n (for example). + + * commands.c (execute_file_commands): If we discover that the + command script is empty and succeed early, set cs_running so the + modtime of the target is still rechecked. + + * rule.c (freerule): Free the dependency list for the rule. + + * implicit.c (pattern_search): When turning an intermediate file + into a real target, keep the also_make list. + Free the dep->name if we didn't use it during enter_file(). + +1999-07-16 Paul D. Smith + + * read.c (read_makefile): Don't allocate the commands buffer until + we're sure we found a makefile and won't return early (mem leak). + + * job.c (start_job_command): Broken #ifdef test: look for F_SETFD, + not FD_SETFD. Close-on-exec isn't getting set on the bad_stdin + file descriptor and it's leaking :-/. + * getloadavg.c (getloadavg): Ditto. + +1999-07-15 Paul D. Smith + + * read.c (read_makefile): Fix some potential memory stomps parsing + `define' directives where no variable name is given. + + * function.c (func_call): Rename from func_apply. Various code + cleanup and tightening. + (function_table): Add "call" as a valid builtin function. + + * make.texinfo (Call Function): Document it. + + * NEWS: Announce it. + +1999-07-09 Eli Zaretskii + + * variable.c (try_variable_definition) [__MSDOS__, WINDOWS32]: + Treat "override SHELL=" the same as just "SHELL=". + +1999-07-09 Paul D. Smith + + * job.c (start_waiting_job): Don't get a second job token if we + already have one; if we're waiting on the load to go down + start_waiting_job() might get called twice on the same file. + + * filedef.h (struct file): Add new field, mtime_before_update. + When notice_finished_file runs it assigns the cached last_mtime to + this field. + * remake.c (update_goal_chain): Notice that a file wasn't updated + by asking if it changed (g->changed) and comparing the current + cached time (last_mtime) with the previous one, stored in + mtime_before_update. The previous check ("did last_mtime changed + during the run of update_file?") fails for parallel builds because + last_mtime is set during reap_children, before update_file is run. + This causes update_goal_chain to always return -1 (nothing + rebuilt) when running parallel (-jN). This is OK during "normal" + builds since our caller (main) treats these cases identically in + that case, but if when rebuilding makefiles the difference is very + important, as it controls whether we re-exec or not. + * file.c (file_hash_enter): Copy the mtime_before_update field. + (snap_deps): Initialize mtime_before_update to -1. + * main.c (main): Initialize mtime_before_update on old (-o) and + new (-W) files. + +1999-07-08 Paul D. Smith + + * main.c (switches): Define a new switch -R (or + --no-builtin-variables). This option disables the defining of all + the GNU make builtin variables. + (main): If -R was given, force -r as well. + * default.c (define_default_variables): Test the new flag. + * make.h: Declare global flag. + * make.texinfo (Options Summary): Document the new option. + (Implicit Variables): Ditto. + +1999-07-06 Paul D. Smith + + * make.texinfo (Options Summary): Correct examples in + --print-data-base option summary (problem reported by David Morse + ). + + * arscan.c: Add support for archives in Windows (VC++). Frank + Libbrecht provided info on how to do + this. + * NMakefile.template (CFLAGS_any): Remove NO_ARCHIVES from the + compile line. + * build_w32.bat: Ditto. + + * remake.c (no_rule_error): Fix -include/sinclude so it doesn't + give errors if you try to -include the same file twice. + (updating_makefiles): New variable: we need to know this info in + no_rule_error() so we know whether to print an error or not. + (update_file_1): Unconditionally call no_rule_error(), don't try + to play games with the dontcare flag. + +1999-06-14 Paul D. Smith + + * make.texinfo (Remaking Makefiles): Add a description of how to + prevent implicit rule searches for makefiles. + + * make.1: Remove statement that make continues processing when -v + is given. + +1999-06-14 Paul D. Smith + + * read.c (read_makefile): Cast -1 arguments to + variable_expand_string() to long. Alexandre Sauve + reports that without casts, this breaks + on a NEC SUPER-UX SX-4 system (and it's wrong without a cast + anyway). Of course, (a) I'd really love to start using function + prototypes, and (b) there's a whole slew of issues related to int + vs. long and signed vs. unsigned in the length handling of + variable buffers, etc. Gross. Needs a complete mucking-out. + * expand.c (variable_expand): Ditto. + + * acinclude.m4 (AC_FUNC_SELECT): Slight enhancement for AIX 3.2 by + Lars Hecking . + + * read.c (get_next_mword): Allow colons to be escaped in target + names: fix for regression failure. + +1999-04-26 Paul D. Smith + + * main.c (main): Reset read_makefiles to empty after processing so + we get the right error message. + +1999-04-25 Paul D. Smith + + * make.texinfo: Updates to @dircategory and @direntry suggested by + Karl Berry . + +1999-04-23 Eli Zaretskii + + * job.c (start_job_command) [__MSDOS__]: Call unblock_sigs before + turning off dos_command_running, so child's signals produce the + right effect. + + * commands.c (fatal_error_signal) [__MSDOS__]: Use EXIT_FAILURE + instead of 1. + +1999-04-18 Eli Zaretskii + + * configh.dos.template: Update to recognize that version 2.02 of + DJGPP contains sys_siglist stuff. + +1999-04-14 Paul D. Smith + + * make.texinfo (Options/Recursion): Document the job server. + (Parallel): Tweaks. + +1999-04-13 Paul D. Smith + + Implement a new "job server" feature; the implementation was + suggested by Howard Chu . + + * configure.in (job-server): New disable option for job server + support--it's enabled by default. If it works well this will go + away. + + * NEWS: Summarize the new feature. + + * acconfig.h: New definition MAKE_JOBSERVER if job server support + is enabled. + * config.h-vms.template: Undef MAKE_JOBSERVER for this port. + * config.h.W32.template: Ditto. + * config.ami.template: Ditto. + + * main.c (struct command_switch): Add a new type: int_string. + (switches[]) Use int_string for -j if MAKE_JOBSERVER. + (init_switches): Initialize the new int_string switch type. + (print_usage): New function, extracted from decode_switches(). + (decode_switches): Call it. Decode the new int_string switch type. + (define_makeflags): Add new int_string switch data to MAKEFLAGS. + (job_fds[]) Array to contain the pipe file descriptors. + (main): Parse the job_slots_str option results. If necessary, + create the pipe and seed it with tokens. Set the non-blocking bit + for the read fd. Enable the signal handler for SIGCHLD even if we + have a non-hanging wait; it's needed to interrupt the select() in + job.c:start_waiting_job(). + + * make.h: Declare job_fds[]. + + * job.h (struct child): Add job_token field to store the token for + this job (if any). + + * job.c (reap_children): When a child is fully reaped, release the + token back into the pipe. + (free_child): If the child to be freed still has a token, put it + back. + (new_job): Initialize the job_token member. + (start_waiting_job): For local jobs, if we're using the pipe, get + a token before we check the load, etc. We do this by performing a + non-blocking read in a loop. If the read fails, no token is + available. Do a select on the fd to wait for a token. We need to + re-enable the signal handler for SIGCHLD even if we have a + non-hanging waitpid() or wait3(), so that the signal will + interrupt the select() and we can wake up to reap children. + (child_handler): Re-enable the signal handler. The count is still + kept although it's not needed or used unless you don't have + waitpid() or wait3(). + +1999-04-10 Paul D. Smith + + * main.c (main): Reset the considered bit on all the makefiles if + something failed to update; we need to examine them again if they + appear as normal targets in order to get the proper error message. + +1999-04-09 Paul D. Smith + + Performance enhancement from Tim Magill . + + * remake.c (update_file): If you have large numbers of + dependencies and you run in parallel, make can spend considerable + time each pass through the graph looking at branches it has + already seen. Since we only reap_children() when starting a pass, + not in the middle, if a branch has been seen already in that pass + nothing interesting can happen until the next pass. So, we toggle + a bit saying whether we've seen this target in this pass or not. + (update_goal_chain): Initially set the global considered toggle to + 1, since all targets initialize their boolean to 0. At the end of + each pass, toggle the global considered variable. + * filedef.h (struct file): Per-file considered toggle bit. + * file.c: New global toggle variable considered. + +1999-04-05 Paul D. Smith + + * arscan.c (ar_scan): Added support for ARFZMAG (compressed + archives?) for Digital UNIX C++. Information provided by + Patrick E. Krogel . + (ar_member_touch): Ditto. + +1999-04-03 Paul D. Smith + + * remake.c (f_mtime): If: a) we found a file and b) we didn't + create it and c) it's not marked as an implicit target and d) it + is marked as an intermediate target, then it was so marked due to + an .INTERMEDIATE special target, but it already existed in the + directory. In this case, unset the intermediate flag so we won't + delete it when make is done. It feels like it would be cleaner to + put this check in update_file_1() but I worry it'll get missed... + +1999-04-01 Paul D. Smith + + * job.c (construct_command_argv_internal): Use bcopy() to copy + overlapping strings, rather than strcpy(). ISO C says the latter + is undefined. Found this in a bug report from 1996! Ouch! + +1999-03-31 Paul D. Smith + + * read.c (readline): Ignore carriage returns at the end of the + line, to allow Windows-y CRLF line terminators. + +1999-03-30 Paul D. Smith + + * configure.in: Don't put build.sh here, since build.sh.in doesn't + exist initially. This cause autoreconf and automake to fail when + run on a clean CVS checkout. Instead, we create build.sh in the + Makefile (see below). + + * Makefile.am: Remove BUILT_SOURCES; this is no longer relevant. + Put those files directly into EXTRA_DIST so they're distributed. + Create a local build rule to create build.sh. + Create a local maintainer-clean rule to delete all the funky + maintainers files. + + * maintMakefile: Makefile.in depends on README, since automake + fails if it doesn't exist. Also don't remove glob/Makefile.in + here, as it causes problems. + +1999-03-26 Paul D. Smith + + * configure.in: Substitute GLOBLIB if we need the link the + glob/libglob.a library. + * Makefile.am (make_LDADD): Use the subst variable GLOBLIB so we + don't link the local libglob.a at all if we don't need it. + * build.template: Don't compile glob/*.o unless we want globlib. + * maintMakefile (build.sh.in): Substitute the glob/*.o files + separately. + +1999-03-25 Paul D. Smith + + * make.texinfo: Various typos and additions, pointed out by James + G. Sack . + +1999-03-22 Paul D. Smith + + * make.texinfo (Functions): Add a new section documenting the new + $(error ...) and $(warning ...) functions. Also updated copyright + dates. + * NEWS: Updated for the new functions. + * function.c (func_error): Implement the new $(error ...) and + $(warning ...) functions. + (function_table): Insert new functions into the table. + (func_firstword): Don't call find_next_token() with argv[0] + itself, since that function modifies the pointer. + * function.c: Cleanups and slight changes to the new method of + calling functions. + +1999-03-20 Han-Wen Nienhuys + + * function.c: Rewrite to use one C function per make function, + instead of a huge switch statement. Also allows some cleanup of + multi-architecture issues, and a cleaner API which makes things + like func_apply() simple. + + * function.c (func_apply): Initial implementation. Expand either + a builtin function or a make variable in the context of some + arguments, provided as $1, $2, ... $N. + +1999-03-19 Eli Zaretskii +1999-03-19 Rob Tulloh + + * job.c (construct_command_argv_internal): Don't treat _all_ + backslashes as escapes, only those which really escape a special + character. This allows most normal "\" directory separators to be + treated normally. + +1999-03-05 Paul D. Smith + + * configure.in: Check for a system strdup(). + * misc.c (xstrdup): Created. Suggestion by Han-Wen Nienhuys + . + * make.h: Prototype xstrdup(). + * remake.c (library_search): Use it. + * main.c (main): Use it. + (find_and_set_default_shell): Use it. + * job.c (construct_command_argv_internal): Use it. + * dir.c (find_directory): Use it. + + * Makefile.am, configure.in: Use AC_SUBST_FILE to insert the + maintMakefile instead of "include", to avoid automake 1.4 + incompatibility. + +1999-03-04 Paul D. Smith + + * amiga.c, amiga.h, ar.c, arscan.c, commands.c, commands.h, + * default.c, dep.h, dir.c, expand.c, file.c, filedef.h, function.c, + * implicit.c, job.c, job.h, main.c, make.h, misc.c, read.c, remake.c + * remote-cstms.c, remote-stub.c, rule.h, variable.c, variable.h, + * vpath.c, Makefile.ami, NMakefile.template, build.template, + * makefile.vms: Updated FSF address in the copyright notice. + + * variable.c (try_variable_definition): If we see a conditional + variable and we decide to set it, re-type it as recursive so it + will be expanded properly later. + +1999-02-22 Paul D. Smith + + * NEWS: Mention new .LIBPATTERNS feature. + + * make.texinfo (Libraries/Search): Describe the use and + ramifications of the new .LIBPATTERNS variable. + + * remake.c (library_search): Instead of searching only for the + hardcoded expansion "libX.a" for a library reference "-lX", we + obtain a list of patterns from the .LIBPATTERNS variable and + search those in order. + + * default.c: Added a new default variable .LIBPATTERNS. The + default for UNIX is "lib%.so lib%.a". Amiga and DOS values are + also provided. + + * read.c: Remove bogus HAVE_GLOB_H references; always include + vanilla glob.h. + +1999-02-21 Paul D. Smith + + * function.c (expand_function): Set value to 0 to avoid freeing it. + * variable.c (pop_variable_scope): Free the value of the variable. + (try_variable_definition): For simple variables, use + allocated_variable_expand() to avoid stomping on the variable + buffer when we still need it for other things. + + * arscan.c: Modified to support AIX 4.3 big archives. The changes + are based on information provided by Phil Adams + . + +1999-02-19 Paul D. Smith + + * configure.in: Check to see if the GNU glob library is already + installed on the system. If so, _don't_ add -I./glob to the + compile line. Using the system glob code with the local headers + is very bad mojo! + Rewrite SCCS macros to use more autoconf facilities. + + * Makefile.am: Move -Iglob out of INCLUDES; it'll get added to + CPPFLAGS by configure now. + Automake 1.4 introduced its own "include" feature which conflicts + with the maintMakefile stuff. A hack that seems to work is add a + space before the include :-/. + + * build.template: Move -Iglob out of the compile line; it'll get + added to CPPFLAGS by configure now. + +1999-02-16 Glenn D. Wolf + + * arscan.c (ar_scan) [VMS]: Initialized VMS_member_date before + calling lbr$get_index since if the archive is empty, + VMS_get_member_info won't get called at all, and any leftover date + will be used. This bug shows up if any member of any archive is + made, followed by a dependency check on a different, empty + archive. + +1998-12-13 Martin Zinser + + * config.h-vms [VMS]: Set _POSIX_C_SOURCE. Redefine the getopt + functions so we don't use the broken VMS versions. + * makefile.com [VMS]: Allow debugging. + * dir.c (dir_setup_glob) [VMS]: Don't extern stat() on VMS. + +1998-11-30 Paul D. Smith + + * signame.c (init_sig): Check the sizes of signals being set up to + avoid array overwrites (if the system headers have problems). + +1998-11-17 Paul D. Smith + + * read.c (record_files): Clean up some indentation. + +1998-11-08 Han-Wen Nienhuys + + * rule.c (print_rule_data_base): Fix arguments to fatal() call. + +1998-10-13 Paul D. Smith + + * job.c (start_job_command): If the command list resolves to no + chars at all (e.g.: "foo:;$(empty)") then command_ptr is NULL; + quit early. + +1998-10-12 Andreas Schwab + + * rule.c (print_rule_data_base): Ignore num_pattern_rules if it is + zero. + +1998-10-09 Paul D. Smith + + * read.c (read_makefile): Allow non-empty lines to expand to the + empty string after variable, etc., expansion, and be ignored. + +1998-09-21 Paul D. Smith + + * job.c (construct_command_argv_internal): Only add COMMAND.COM + "@echo off" line for non-UNIXy shells. + +1998-09-09 Paul D. Smith + + * w32/subproc/sub_proc.c: Add in missing HAVE_MKS_SHELL tests. + +1998-09-04 Paul D. Smith + + * read.c (read_makefile): If we hit the "missing separator" error, + check for the common case of 8 spaces instead of a TAB and give an + extra comment to help people out. + +1998-08-29 Paul Eggert + + * configure.in (AC_STRUCT_ST_MTIM_NSEC): + Renamed from AC_STRUCT_ST_MTIM. + + * acinclude.m4 (AC_STRUCT_ST_MTIM_NSEC): Likewise. + Port to UnixWare 2.1.2 and pedantic Solaris 2.6. + + * acconfig.h (ST_MTIM_NSEC): + Renamed from HAVE_ST_MTIM, with a new meaning. + + * filedef.h (FILE_TIMESTAMP_FROM_S_AND_NS): + Use new ST_MTIM_NSEC macro. + +1998-08-26 Paul D. Smith + + * remake.c (check_dep): For any intermediate file, not just + secondary ones, try implicit and default rules if no explicit + rules are given. I'm not sure why this was restricted to + secondary rules in the first place. + +1998-08-24 Paul D. Smith + + * make.texinfo (Special Targets): Update documentation for + .INTERMEDIATE: if used with no dependencies, then it does nothing; + old docs said it marked all targets as intermediate, which it + didn't... and which would be silly :). + + * implicit.c (pattern_search): If we find a dependency in our + internal tables, make sure it's not marked intermediate before + accepting it as a found_file[]. + +1998-08-20 Paul D. Smith + + * ar.c (ar_glob): Use existing alpha_compare() with qsort. + (ar_glob_alphacompare): Remove it. + + Modify Paul Eggert's patch so we don't abandon older systems: + + * configure.in: Warn the user if neither waitpid() nor wait3() is + available. + + * job.c (WAIT_NOHANG): Don't syntax error on ancient hosts. + (child_handler, dead_children): Define these if WAIT_NOHANG is not + available. + (reap_children): Only track the dead_children count if no + WAIT_NOHANG. Otherwise, it's a boolean. + + * main.c (main): Add back signal handler if no WAIT_NOHANG is + available; only use default signal handler if it is. + +1998-08-20 Paul Eggert + + Install a more robust signal handling mechanism for systems which + support it. + + * job.c (WAIT_NOHANG): Define to a syntax error if our host + is truly ancient; this should never happen. + (child_handler, dead_children): Remove. + (reap_children): Don't try to keep separate track of how many + dead children we have, as this is too bug-prone. + Just ask the OS instead. + (vmsHandleChildTerm): Fix typo in error message; don't mention + child_handler. + + * main.c (main): Make sure we're not ignoring SIGCHLD/SIGCLD; + do this early, before we could possibly create a subprocess. + Just use the default behavior; don't have our own handler. + +1998-08-18 Eli Zaretskii + + * read.c (read_makefile) [__MSDOS__, WINDOWS32]: Add code to + recognize library archive members when dealing with drive spec + mess. Discovery and initial fix by George Racz . + +1998-08-18 Paul D. Smith + + * configure.in: Check for stdlib.h explicitly (some hosts have it + but don't have STDC_HEADERS). + * make.h: Use HAVE_STDLIB_H. Clean up some #defines. + * config.ami: Re-compute based on new config.h.in contents. + * config.h-vms: Ditto. + * config.h.W32: Ditto. + * configh.dos: Ditto. + + * dir.c (find_directory) [WINDOWS32]: Windows stat() fails if + directory names end with `\' so strip it. + +1998-08-17 Paul D. Smith + + * make.texinfo: Added copyright year to the printed copy. Removed + the price from the manual. Change the top-level reference to + running make to be "Invoking make" instead of "make Invocation", + to comply with GNU doc standards. + + * make.h (__format__, __printf__): Added support for these in + __attribute__ macro. + (message, error, fatal): Use ... prototype form under __STDC__. + Add __format__ attributes for printf-style functions. + + * configure.in (AC_FUNC_VPRINTF): Check for vprintf()/_doprnt(). + + * misc.c (message, error, fatal): Add preprocessor stuff to enable + creation of variable-argument functions with appropriate + prototypes, that works with ANSI, pre-ANSI, varargs.h, stdarg.h, + v*printf(), _doprnt(), or none of the above. Culled from GNU + fileutils and slightly modified. + (makefile_error, makefile_error): Removed (merged into error() and + fatal(), respectively). + * amiga.c: Use them. + * ar.c: Use them. + * arscan.c: Use them. + * commands.c: Use them. + * expand.c: Use them. + * file.c: Use them. + * function.c: Use them. + * job.c: Use them. + * main.c: Use them. + * misc.c: Use them. + * read.c: Use them. + * remake.c: Use them. + * remote-cstms.c: Use them. + * rule.c: Use them. + * variable.c: Use them. + + * make.h (struct floc): New structure to store file location + information. + * commands.h (struct commands): Use it. + * variable.c (try_variable_definition): Use it. + * commands.c: Use it. + * default.c: Use it. + * file.c: Use it. + * function.c: Use it. + * misc.c: Use it. + * read.c: Use it. + * rule.c: Use it. + +1998-08-16 Paul Eggert + + * filedef.h (FILE_TIMESTAMP_PRINT_LEN_BOUND): Add 10, for nanoseconds. + +1998-08-16 Paul Eggert + + * filedef.h (FLOOR_LOG2_SECONDS_PER_YEAR): New macro. + (FILE_TIMESTAMP_PRINT_LEN_BOUND): Tighten bound, and try to + make it easier to understand. + +1998-08-14 Paul D. Smith + + * read.c (read_makefile): We've already unquoted any colon chars + by the time we're done reading the targets, so arrange for + parse_file_seq() on the target list to not do so again. + +1998-08-05 Paul D. Smith + + * configure.in: Added glob/configure.in data. We'll have the glob + code include the regular make config.h, rather than creating its + own. + + * getloadavg.c (main): Change return type to int. + +1998-08-01 Paul Eggert + + * job.c (reap_children): Ignore unknown children. + +1998-07-31 Paul D. Smith + + * make.h, filedef.h, dep.h, rule.h, commands.h, remake.c: + Add prototypes for functions. Some prototypes needed to be moved + in order to get #include order reasonable. + +1998-07-30 Paul D. Smith + + * make.h: Added MIN/MAX. + * filedef.h: Use them; remove FILE_TIMESTAMP_MIN. + +1998-07-30 Paul Eggert + + Add support for sub-second timestamp resolution on hosts that + support it (just Solaris 2.6, so far). + + * acconfig.h (HAVE_ST_MTIM, uintmax_t): New undefs. + * acinclude.m4 (jm_AC_HEADER_INTTYPES_H, AC_STRUCT_ST_MTIM, + jm_AC_TYPE_UINTMAX_T): New defuns. + * commands.c (delete_target): Convert file timestamp to + seconds before comparing to archive timestamp. Extract mod + time from struct stat using FILE_TIMESTAMP_STAT_MODTIME. + * configure.in (C_STRUCT_ST_MTIM, jm_AC_TYPE_UINTMAX_T): Add. + (AC_CHECK_LIB, AC_CHECK_FUNCS): Add clock_gettime. + * file.c (snap_deps): Use FILE_TIMESTAMP, not time_t. + (file_timestamp_now, file_timestamp_sprintf): New functions. + (print_file): Print file timestamps as FILE_TIMESTAMP, not + time_t. + * filedef.h: Include if available and if HAVE_ST_MTIM. + (FILE_TIMESTAMP, FILE_TIMESTAMP_STAT_MODTIME, FILE_TIMESTAMP_MIN, + FILE_TIMESTAMPS_PER_S, FILE_TIMESTAMP_FROM_S_AND_NS, + FILE_TIMESTAMP_DIV, FILE_TIMESTAMP_MOD, FILE_TIMESTAMP_S, + FILE_TIMESTAMP_NS, FILE_TIMESTAMP_PRINT_LEN_BOUND): New macros. + (file_timestamp_now, file_timestamp_sprintf): New decls. + (struct file.last_mtime, f_mtime, file_mtime_1, NEW_MTIME): + time_t -> FILE_TIMESTAMP. + * implicit.c (pattern_search): Likewise. + * vpath.c (vpath_search, selective_vpath_search): Likewise. + * main.c (main): Likewise. + * remake.c (check_dep, name_mtime, library_search, f_mtime): Likewise. + (f_mtime): Use file_timestamp_now instead of `time'. + Print file timestamp with file_timestamp_sprintf. + * vpath.c (selective_vpath_search): Extract file time stamp from + struct stat with FILE_TIMESTAMP_STAT_MODTIME. + +1998-07-28 Paul D. Smith + + * Version 3.77 released. + + * dosbuild.bat: Change to DOS CRLF line terminators. + + * make-stds.texi: Update from latest version. + + * make.texinfo (Options Summary): Clarify that the -r option + affects only rules, not builtin variables. + +1998-07-27 Paul D. Smith + + * make.h: Make __attribute__ resolve to empty for non-GCC _and_ + for GCC pre-2.5.x. + + * misc.c (log_access): Print UID/GID's as unsigned long int for + maximum portability. + + * job.c (reap_children): Print PIDs as long int for maximum + portability. + +1998-07-24 Eli Zaretskii + + * Makefile.DOS (*_INSTALL, *_UNINSTALL): Replace `true' with `:'. + +1998-07-25 Paul D. Smith + + * Version 3.76.94 released. + +1998-07-23 Paul D. Smith + + * config.h.W32.template: Make sure all the #defines of macros here + have a value (e.g., use ``#define HAVE_STRING_H 1'' instead of + just ``#define HAVE_STRING_H''. Keeps the preprocessor happy in + some contexts. + + * make.h: Remove __attribute__((format...)) stuff; using it with + un-prototyped functions causes older GCC's to fail. + + * Version 3.76.93 released. + +1998-07-22 Paul D. Smith + + * file.c (print_file_data_base): Fix average calculation. + +1998-07-20 Paul D. Smith + + * main.c (die): Postpone the chdir() until after + remove_intermediates() so that intermediate targets with relative + pathnames are removed properly. + +1998-07-17 Paul D. Smith + + * filedef.h (struct file): New flag: did we print an error or not? + + * remake.c (no_rule_error): New function to print error messages, + extraced from remake_file(). + + * remake.c (remake_file): Invoke the new error print function. + (update_file_1): Invoke the error print function if we see that we + already tried this target and it failed, but that an error wasn't + printed for it. This can happen if a file is included with + -include or sinclude and couldn't be built, then later is also + the dependency of another target. Without this change, make just + silently stops :-/. + +1998-07-16 Paul D. Smith + + * make.texinfo: Removed "beta" version designator. + Updated ISBN for the next printing. + +1998-07-13 Paul Eggert + + * acinclude.m4: New AC_LFS macro to determine if special compiler + flags are needed to allow access to large files (e.g., Solaris 2.6). + * configure.in: Invoke it. + +1998-07-08 Eli Zaretskii + + * Makefile.DOS: track changes in Makefile.in. + +1998-07-07 Paul D. Smith + + * remote-cstms.c (start_remote_job): Move gethostbyaddr() to the + top so host is initialized early enough. + + * acinclude.m4: New file. Need some special autoconf macros to + check for network libraries (-lsocket, -lnsl, etc.) when + configuring Customs. + + * configure.in (make_try_customs): Invoke new network libs macro. + +1998-07-06 Paul D. Smith + + * Version 3.76.92 released. + + * README.customs: Added to the distribution. + + * configure.in (make_try_customs): Rewrite to require an installed + Customs library, rather than looking at the build directory. + + * Makefile.am (man_MANS): Install make.1. + * make.1: Renamed from make.man. + + * make.texinfo (Bugs): New mailing list address for GNU make bug + reports. + +1998-07-02 Paul D. Smith + + * Version 3.76.91 released. + + * default.c: Added default rule for new-style RCS master file + storage; ``% :: RCS/%''. + Added default rules for DOS-style C++ files with suffix ".cpp". + They use the new LINK.cpp and COMPILE.cpp macros, which are set by + default to be equal to LINK.cc and COMPILE.cc. + +1998-06-19 Eli Zaretskii + + * job.c (start_job_command): Reset execute_by_shell after an empty + command was skipped. + +1998-06-09 Paul D. Smith + + * main.c (main): Keep track of the temporary filename created when + reading a makefile from stdin (-f-) and attempt to remove it + as soon as we know we're not going to re-exec. If we are, add it + to the exec'd make's cmd line with "-o" so the exec'd make doesn't + try to rebuild it. We still have a hole: if make re-execs then + the temporary file will never be removed. To fix this we'd need + a brand new option that meant "really delete this". + * AUTHORS, getopt.c, getopt1.c, getopt.h, main.c (print_version): + Updated mailing addresses. + +1998-06-08 Paul D. Smith + + * main.c (main): Andreas Luik points out that the + check for makefile :: rules with commands but no dependencies + causing a loop terminates incorrectly. + + * maintMakefile: Make a template for README.DOS to update version + numbers. + +1998-05-30 Andreas Schwab + + * remake.c (update_file_1): Don't free the memory for the + dependency structure when dropping a circular dependency. + +1998-05-30 Eli Zaretskii + + * dir.c (file_exists_p, file_impossible_p, file_impossible) + [__MSDOS__, WINDOWS32]: Retain trailing slash in "d:/", and make + dirname of "d:foo" be "d:". + +1998-05-26 Andreas Schwab + + * read.c (read_makefile): Avoid running past EOS when scanning + file name after `include'. + +1998-05-26 Andreas Schwab + + * make.texinfo (Flavors): Correct description of conditional + assignment, which is not equivalent to ifndef. + (Setting): Likewise. + +1998-05-24 Paul D. Smith + + * arscan.c (ar_name_equal): strncmp() might be implemented as a + macro, so don't put preprocessor conditions inside the arguments + list. + +1998-05-23 Eli Zaretskii + + * read.c (read_makefile) [__MSDOS__, WINDOWS32]: Skip colons in + drive specs when parsing targets, target-specific variables and + static pattern rules. A colon can only be part of drive spec if + it is after the first letter in a token. + +1998-05-22 Eli Zaretskii + + * remake.c (f_mtime) [__MSDOS__]: Allow up to 3 sec of skew before + yelling bloody murder. + + * dosbuild.bat: Use -DINCLUDEDIR= and -DLIBDIR= where appropriate. + + * read.c (parse_file_seq): Combine the special file-handling code + for WINDOWS32 and __MSDOS__ into a single snippet. + (get_next_mword) [__MSDOS__, WINDOWS32]: Allow a word to include a + colon as part of a drive spec. + + * job.c (batch_mode_shell) [__MSDOS__]: Declare. + +1998-05-20 Paul D. Smith + + * Version 3.76.90 released. + +1998-05-19 Paul D. Smith + + * make.texinfo (Make Errors): Added a new appendix describing + common errors make might generate and how to resolve them (or at + least more information on what they mean). + + * maintMakefile (NMAKEFILES): Use the new automake 1.3 feature + to create a dependency file to construct Makefile.DOS, SMakefile, + and NMakefile. + (.dep_segment): Generate the dependency fragment file. + +1998-05-14 Paul D. Smith + + * make.man: Minor changes. + +1998-05-13 Paul D. Smith + + * function.c (pattern_matches,expand_function): Change variables + and types named "word" to something else, to avoid compilation + problems on Cray C90 Unicos. + * variable.h: Modify the function prototype. + +1998-05-11 Rob Tulloh + + * job.c (construct_command_argv_internal) [WINDOWS32]: Turn off + echo when using a batch file, and make sure the command ends in a + newline. + +1998-05-03 Paul D. Smith + + * configure.in (make_try_customs): Add some customs flags if the + user configures custom support. + + * job.c, remote-cstms.c: Merge in changes for custom library. + + * remote-stub.c: Add option to stub start_remote_job_p(). + +1998-05-01 Paul D. Smith + + * remake.c (f_mtime): Install VPATH+ handling for archives; use + the hname field instead of the name field, and rehash when + appropriate. + +1998-04-30 Paul D. Smith + + * rule.c (print_rule_data_base): Print out any pattern-specific + variable values into the rules database. + + * variable.c (print_variable_set): Make this variable extern, to + be called by print_rule_data_base() for pattern-specific variables. + + * make.texinfo (Pattern-specific): Document pattern-specific + variables. + +1998-04-29 Paul D. Smith + + * expand.c (variable_expand_for_file): Make static; its only + called internally. Look up this target in the list of + pattern-specific variables and insert the variable set into the + queue to be searched. + + * filedef.h (struct file): Add a new field to hold the + previously-found pattern-specific variable reference. Add a new + flag to remember whether we already searched for this file. + + * rule.h (struct pattern_var): New structure for storing + pattern-specific variable values. Define new function prototypes. + + * rule.c: New variables pattern_vars and last_pattern_var for + storage and handling of pattern-specific variable values. + (create_pattern_var): Create a new pattern-specific variable value + structure. + (lookup_pattern_var): Try to match a target to one of the + pattern-specific variable values. + +1998-04-22 Paul D. Smith + + * make.texinfo (Target-specific): Document target-specific + variables. + +1998-04-21 Paul D. Smith + + * variable.c (define_variable_in_set): Made globally visible. + (lookup_variable_in_set): New function: like lookup_variable but + look only in a specific variable set. + (target_environment): Use lookup_variable_in_set() to get the + correct export rules for a target-specific variable. + (create_new_variable_set): Create a new variable set, and just + return it without installing it anywhere. + (push_new_variable_scope): Reimplement in terms of + create_new_variable_set. + + * read.c (record_target_var): Like record_files, but instead of + files create a target-specific variable value for each of the + listed targets. Invoked from read_makefile() when the target line + turns out to be a target-specific variable assignment. + +1998-04-19 Paul D. Smith + + * read.c (read_makefile): Rewrite the entire target parsing + section to implement target-specific variables. In particular, we + cannot expand the entire line as soon as it's read in, since we + may want to evaluate parts of it with different variable contexts + active. Instead, start expanding from the beginning until we find + the `:' (or `::'), then determine what kind of line this is and + continue appropriately. + + * read.c (get_next_mword): New function to parse a makefile line + by "words", considering an entire variable or function as one + word. Return the type read in, along with its starting position + and length. + (enum make_word_type): The types of words that are recognized by + get_next_mword(). + + * variable.h (struct variable): Add a flag to specify a per-target + variable. + + * expand.c: Make variable_buffer global. We need this during the + new parsing of the makefile. + (variable_expand_string): New function. Like variable_expand(), + but start at a specific point in the buffer, not the beginning. + (variable_expand): Rewrite to simply call variable_expand_string(). + +1998-04-13 Paul D. Smith + + * remake.c (update_goal_chain): Allow the rebuilding makefiles + step to use parallel jobs. Not sure why this was disabled: + hopefully we won't find out :-/. + +1998-04-11 Paul D. Smith + + * main.c (main): Set the CURDIR makefile variable. + * make.texinfo (Recursion): Document it. + +1998-03-17 Paul D. Smith + + * misc.c (makefile_fatal): If FILE is nil, invoke plain fatal(). + * variable.c (try_variable_definition): Use new feature. + +1998-03-10 Paul D. Smith + + * main.c (main): Don't pass included, rebuilt makefiles to + re-exec'd makes with -o. Reopens a possible loop, but it caused + too many problems. + +1998-03-02 Paul D. Smith + + * variable.c (try_variable_definition): Implement ?=. + * make.texinfo (Setting): Document it. + +1998-02-28 Eli Zaretskii + + * job.c (start_job_command): Reset execute_by_shell after an empty + command, like ":", has been seen. + +Tue Oct 07 15:00:00 1997 Phil Brooks + + * make.h [WINDOWS32]: make case sensitivity configurable + * dir.c [WINDOWS32]: make case sensitivity configurable + * README.W32: Document case sensitivity + * config.ami: Share case warping code with Windows + +Mon Oct 6 18:48:45 CDT 1997 Rob Tulloh + + * w32/subproc/sub_proc.c: Added support for MKS toolkit shell + (turn on HAVE_MKS_SHELL). + * read.c [WINDOWS32]: Fixed a problem with multiple target rules + reported by Gilbert Catipon (gcatipon@tibco.com). If multiple + path tokens in a rule did not have drive letters, make would + incorrectly concatenate the 2 tokens together. + * main.c/variable.c [WINDOWS32]: changed SHELL detection code to + follow what MSDOS did. In addition to watching for SHELL variable + updates, make's main will attempt to default the value of SHELL + before and after makefiles are parsed. + * job.c/job.h [WINDOWS32]: The latest changes made to enable use + of the GNUWIN32 shell from make could cause make to fail due to a + concurrency condition between parent and child processes. Make + now creates a batch file per job instead of trying to reuse the + same singleton batch file. + * job.c/job.h/function.c/config.h.W32 [WINDOWS32]: Renamed macro + from HAVE_CYGNUS_GNUWIN32_TOOLS to BATCH_MODE_ONLY_SHELL. Reworked + logic to reduce complexity. WINDOWS32 now uses the unixy_shell + variable to detect Bourne-shell compatible environments. There is + also a batch_mode_shell variable that determines whether not + command lines should be executed via script files. A WINDOWS32 + system with no sh.exe installed would have unixy_shell set to + FALSE and batch_mode_shell set to TRUE. If you have a unixy shell + that does not behave well when invoking things via 'sh -c xxx', + you may want to turn on BATCH_MODE_ONLY_SHELL and see if things + improve. + * NMakefile: Added /D DEBUG to debug build flags so that unhandled + exceptions could be debugged. + +Mon Oct 6 00:04:25 1997 Rob Tulloh + + * main.c [WINDOWS32]: The function define_variable() does not + handle NULL. Test before calling it to set Path. + * main.c [WINDOWS32]: Search Path again after makefiles have been + parsed to detect sh.exe. + * job.c [WINDOWS32]: Added support for Cygnus GNU WIN32 tools. + To use, turn on HAVE_CYGNUS_GNUWIN32_TOOLS in config.h.W32. + * config.h.W32: Added HAVE_CYGNUS_GNUWIN32_TOOLS macro. + +Sun Oct 5 22:43:59 1997 John W. Eaton + + * glob/glob.c (glob_in_dir) [VMS]: Globbing shouldn't be + case-sensitive. + * job.c (child_execute_job) [VMS]: Use a VMS .com file if the + command contains a newline (e.g. from a define/enddef block). + * vmsify.c (vmsify): Return relative pathnames wherever possible. + * vmsify.c (vmsify): An input string like "../.." returns "[--]". + +Wed Oct 1 15:45:09 1997 Rob Tulloh + + * NMakefile: Changed nmake to $(MAKE). + * subproc.bat: Take the make command name from the command + line. If no command name was given, default to nmake. + * job.c [MSDOS, WINDOWS32]: Fix memory stomp: temporary file names + are now always created in heap memory. + * w32/subproc/sub_proc.c: New implementation of make_command_line() + which is more compatible with different Bourne shell implementations. + Deleted the now obsolete fix_command_line() function. + * main.c [WINDOWS32]: Any arbitrary spelling of Path can be + detected. Make will ensure that the special spelling `Path' is + inserted into the environment when the path variable is propagated + within itself and to make's children. + * main.c [WINDOWS32]: Detection of sh.exe was occurring too + soon. The 2nd check for the existence of sh.exe must come after + the call to read_all_makefiles(). + +Fri Sep 26 01:14:18 1997 + + * makefile.com [VMS]: Fixed definition of sys. + * readme.vms: Comments on what's changed lately. + +Fri Sep 26 01:14:18 1997 John W. Eaton + + * read.c (read_all_makefiles): Allow make to find files named + "MAKEFILE" with no extension on VMS. + * file.c (lookup_file): Lowercase filenames on VMS. + +1997-09-29 Paul D. Smith + + * read.c (read_makefile): Reworked target detection again; the old + version had an obscure quirk. + +Fri Sep 19 09:20:49 1997 Paul D. Smith + + * Version 3.76.1 released. + + * Makefile.am: Add loadavg files to clean rules. + + * configure.in (AC_OUTPUT): Remove stamp-config; no longer needed. + * Makefile.ami (distclean): Ditto. + * SMakefile (distclean): Ditto. + + * main.c (main): Arg count should be int, not char! Major braino. + +Tue Sep 16 10:18:22 1997 Paul D. Smith + + * Version 3.76 released. + +Tue Sep 2 10:07:39 1997 Paul D. Smith + + * function.c (expand_function): When processing $(shell...) + translate a CRLF (\r\n) sequence as well as a newline (\n) to a + space. Also remove an ending \r\n sequence. + * make.texinfo (Shell Function): Document it. + +Fri Aug 29 12:59:06 1997 Rob Tulloh + + * w32/pathstuff.c (convert_Path_to_windows32): Fix problem where + paths which contain single character entries like `.' are not + handled correctly. + + * README.W32: Document path handling issues on Windows systems. + +Fri Aug 29 02:01:27 1997 Paul D. Smith + + * Version 3.75.93. + +Thu Aug 28 19:39:06 1997 Rob Tulloh + + * job.c (exec_command) [WINDOWS32]: If exec_command() is invoked + from main() to re-exec make, the call to execvp() would + incorrectly return control to parent shell before the exec'ed + command could run to completion. I believe this is a feature of + the way that execvp() is implemented on top of WINDOWS32 APIs. To + alleviate the problem, use the supplied process launch function in + the sub_proc library and suspend the parent process until the + child process has run. When the child exits, exit the parent make + with the exit code of the child make. + +Thu Aug 28 17:04:47 1997 Paul D. Smith + + * Makefile.DOS.template (distdir): Fix a line that got wrapped in + email. + + * Makefile.am (loadavg): Give the necessary cmdline options when + linking loadavg. + + * configure.in: Check for pstat_getdynamic for getloadvg on HP. + + * job.c (start_job_command) [VMS, _AMIGA]: Don't perform empty + command optimization on these systems; it doesn't make sense. + +Wed Aug 27 17:09:32 1997 Paul D. Smith + + * Version 3.75.92 + +Tue Aug 26 11:59:15 1997 Paul D. Smith + + * main.c (print_version): Add '97 to copyright years. + + * read.c (do_define): Check the length of the array before looking + at a particular offset. + + * job.c (construct_command_argv_internal): Examine the last byte + of the previous arg, not the byte after that. + +Sat Aug 23 1997 Eli Zaretskii + + * Makefile.DOS.template: New file (converted to Makefile.DOS in + the distribution). + + * configure.bat: Rewrite to use Makefile.DOS instead of editing + Makefile.in. Add support for building from outside of the source + directory. Fail if the environment block is too small. + + * configh.dos: Use . + + * README.DOS: Update instructions. + +Fri Aug 22 1997 Eli Zaretskii + + * job.c (start_job_command) [__MSDOS__]: Don't test for "/bin/sh" + literally, use value of unixy_shell instead. + + * filedef.h (NEW_MTIME): Use 1 less than maximum possible value if + time_t is unsigned. + +Sat Aug 16 00:56:15 1997 John W. Eaton + + * vmsify.c (vmsify, case 11): After translating `..' elements, set + nstate to N_OPEN if there are still more elements to process. + (vmsify, case 2): After translating `foo/bar' up to the slash, + set nstate to N_OPEN, not N_DOT. + +Fri Aug 8 15:18:09 1997 John W. Eaton + + * dir.c (vmsstat_dir): Leave name unmodified on exit. + * make.h (PATH_SEPARATOR_CHAR): Set to comma for VMS. + * vpath.c: Fix comments to refer to path separator, not colon. + (selective_vpath_search): Avoid Unixy slash handling for VMS. + +Thu Aug 7 22:24:03 1997 John W. Eaton + + * ar.c [VMS]: Don't declare ar_member_touch. + Delete VMS version of ar_member_date. + Enable non-VMS versions of ar_member_date and ar_member_date_1 for + VMS too. + * arscan.c (VMS_get_member_info): New function. + (ar_scan): Provide version for VMS systems. + (ar_name_equal): Simply compare name and mem on VMS systems. + Don't define ar_member_pos or ar_member_touch on VMS systems. + + * config.h-vms (pid_t, uid_t): Don't define. + + * remake.c: Delete declaration of vms_stat. + (name_mtime): Don't call vms_stat. + (f_mtime) [VMS]: Funky time value manipulation no longer necessary. + + * file.c (print_file): [VMS] Use ctime, not cvt_time. + + * make.h [VMS]: Don't define POSIX. + + * makefile.com (filelist): Include ar and arscan. + Also include them in the link commands. + Don't define NO_ARCHIVES in cc command. + + * makefile.vms (ARCHIVES, ARCHIVES_SRC): Uncomment. + (defines): Delete NO_ARCHIVES from list. + + * remake.c (f_mtime): Only check to see if intermediate file is + out of date if it also exists (i.e., mtime != (time_t) -1). + + * vmsdir.h (u_long, u_short): Skip typedefs if using DEC C. + +Fri Jun 20 23:02:07 1997 Rob Tulloh + + * w32/subproc/sub_proc.c: Get W32 sub_proc to handle shebang + (#!/bin/sh) in script files correctly. + Fixed a couple of memory leaks. + Fixed search order in find_file() (w32/subproc/sub_proc.c) so that + files with extensions are preferred over files without extensions. + Added search for files with .cmd extension too. + * w32/subproc/misc.c (arr2envblk): Fixed memory leak. + +Mon Aug 18 09:41:08 1997 Paul D. Smith + + * Version 3.75.91 + +Fri Aug 15 13:50:54 1997 Paul D. Smith + + * read.c (do_define): Remember to count the newline after the endef. + +Thu Aug 14 23:14:37 1997 Paul D. Smith + + * many: Rewrote builds to use Automake 1.2. + + * AUTHORS: New file. + * maintMakefile: Contains maintainer-only make snippets. + * GNUmakefile: This now only runs the initial auto* tools. + * COPYING,texinfo.tex,mkinstalldirs,install-sh: Removed (obtained + automatically by automake). + * compatMakefile: Removed (not needed anymore). + * README,build.sh.in: Removed (built from templates). + * config.h.in,Makefile.in: Removed (built by tools). + +Wed Aug 13 02:22:08 1997 Paul D. Smith + + * make.texinfo: Updates for DOS/Windows information (Eli Zaretskii) + * README,README.DOS: Ditto. + + * remake.c (update_file_1,f_mtime): Fix GPATH handling. + * vpath.c (gpath_search): Ditto. + + * file.c (rename_file): New function: rehash, but also rename to + the hashname. + * filedef.h: Declare it. + + * variable.c (merge_variable_set_lists): Remove free() of variable + set; since various files can share variable sets we don't want to + free them here. + +Tue Aug 12 10:51:54 1997 Paul D. Smith + + * configure.in: Require autoconf 2.12 + + * make.texinfo: Replace all "cd subdir; $(MAKE)" examples with a + more stylistically correct "cd subdir && $(MAKE)". + + * main.c: Global variable `clock_skew_detected' defined. + (main): Print final warning if it's set. + * make.h: Declare it. + * remake.c (f_mtime): Test and set it. + + * job.c (start_job_command): Add special optimizations for + "do-nothing" rules, containing just the shell no-op ":". This is + useful for timestamp files and can make a real difference if you + have a lot of them (requested by Fergus Henderson ). + + * configure.in,Makefile.in: Rewrote to use the new autoconf + program_transform_name macro. + + * function.c (function_strip): Strip newlines as well as spaces + and TABs. + +Fri Jun 6 23:41:04 1997 Rob Tulloh + + * remake.c (f_mtime): Datestamps on FAT-based files are rounded to + even seconds when stored, so if the date check fails on WINDOWS32 + systems, see if this "off-by-one" error is the problem. + + * General: If your TZ environment variable is not set correctly + then all your timestamps will be off by hours. So, set it! + +Mon Apr 7 02:06:22 1997 Paul D. Smith + + * Version 3.75.1 + + * compatMakefile (objs): Define & use the $(GLOB) variable so + that it's removed correctly from build.sh.in when it's built. + + * configure.in: On Solaris we can use the kstat_*() functions to + get load averages without needing special permissions. Add a + check for -lkstat to see if we have it. + + * getloadavg.c (getloadavg): Use HAVE_LIBKSTAT instead of SUN5 as + the test to enable kstat_open(), etc. processing. + +Fri Apr 4 20:21:18 1997 Eli Zaretskii + + * : Fixes to work in the DJGPP DOS environment. + +Mon Mar 31 02:42:52 1997 Paul D. Smith + + * function.c (expand_function): Added new function $(wordlist). + + * make.texinfo (Filename Functions): Document $(wordlist) function. + + * vpath.c (build_vpath_lists): Construct the GPATH variable + information in the same manner we used to construct VPATH. + (gpath_search): New function to search GPATH. + + * make.h: Declare the new function. + + * remake.c (update_file_1): Call it, and keep VPATH if it's found. + + * make.texinfo (Search Algorithm): Document GPATH variable. + +Sun Mar 30 20:57:16 1997 Paul D. Smith + + * main.c (handle_non_switch_argument): Defined the MAKECMDGOALS + variable to contain the user options passed in on the cmd line. + + * make.texinfo (Goals): Document MAKECMDGOALS variable. + + * remake.c (f_mtime): Print a warning if we detect a clock skew + error, rather than failing. + + * main.c (main): If we rebuild any makefiles and need to re-exec, + add "-o" options for each makefile rebuilt to avoid + infinite looping. + +Fri Mar 28 15:26:05 1997 Paul D. Smith + + * job.c (construct_command_argv_internal): Track whether the last + arg in the cmd string was empty or not (Roland). + (construct_command_argv_internal): If the shell line is empty, + don't do anything (Roland). + + * glob/glob.h,glob/glob.c,glob/fnmatch.c,glob/fnmatch.h: Install + the latest changes from the GLIBC version of glob (Ulrich Drepper). + + * getloadavg.c,make-stds.texi: New version (Roland). + + * (ALL): Changed WIN32 to W32 or WINDOWS32 (RMS). + +Mon Mar 24 15:33:34 1997 Rob Tulloh + + * README.W32: Describe preliminary FAT support. + + * build_w32.bat: Use a variable for the final exe name. + + * dir.c (find_directory): W32: Find the filesystem type. + (dir_contents_file_exists_p): W32: for FAT filesystems, always + rehash since FAT doesn't change directory mtime on change. + + * main.c (handle_runtime_exceptions): W32: Add an + UnhandledExceptionFilter so that when make bombs due to ^C or a + bug, it won't cause a GUI requestor to pop up unless debug is + turned on. + (main): Call it. + +Mon Mar 24 00:57:34 1997 Paul D. Smith + + * configure.in, config.h.in, config.ami, config.h-vms, config.h.w32: + Check for memmove() function. + + * make.h (bcopy): If memmove() available, define bcopy() to use it. + Otherwise just use bcopy(). Don't use memcpy(); it's not guaranteed + to handle overlapping moves. + + * read.c (read_makefile): Fix some uninitialized memory reads + (reported by Purify). + + * job.c (construct_command_argv_internal): Use bcopy() not + strcpy(); strcpy() isn't guaranteed to handle overlapping moves. + + * Makefile.in: Change install-info option ``--infodir'' to + ``--info-dir'' for use with new texinfo. + + * function.c (expand_function): $(basename) and $(suffix) should + only search for suffixes as far back as the last directory (e.g., + only the final filename in the path). + +Sun Mar 23 00:13:05 1997 Paul D. Smith + + * make.texinfo: Add @dircategory/@direntry information. + (Top): Remove previous reference to (dir) (from RMS). + (Static Usage): Add "all:" rule to example. + (Automatic Dependencies): fix .d file creation example. + + * Install VPATH+ patch: + + * filedef.h (struct file): Add in hname field to store the hashed + filename, and a flag to remember if we're using the vpath filename + or not. Renamed a few functions for more clarity. + + * file.c (lookup_file,enter_file,file_hash_enter): Store filenames + in the hash table based on their "hash name". We can change this + while keeping the original target in "name". + (rehash_file): Renamed from "rename_file" to be more accurate. + Changes the hash name, but not the target name. + + * remake.c (update_file_1): Modify -d output for more detailed + VPATH info. If we don't need to rebuild, use the VPATH name. + (f_mtime): Don't search for vpath if we're ignoring it. Call + renamed function rehash_file. Call name_mtime instead of + file_mtime, to avoid infinite recursion since the file wasn't + actually renamed. + + * implicit.c (pattern_search): if we find an implicit file in + VPATH, save the original name not the VPATH name. + + * make.texinfo (Directory Search): Add a section on the new VPATH + functionality. + +Sun Dec 1 18:36:04 1996 Andreas Schwab + + * dir.c (file_exists_p, file_impossible, file_impossible_p): If + dirname is empty replace it by the name of the root directory. + Note that this doesn't work (yet) for W32, Amiga, or VMS. + +Tue Oct 08 13:57:03 1996 Rob Tulloh + + * main.c (main): W32 bug fix for PATH vars. + +Tue Sep 17 1996 Paul Eggert + + * filedef.h (NEW_MTIME): Don't assume that time_t is a signed + 32-bit quantity. + + * make.h: (CHAR_BIT, INTEGER_TYPE_SIGNED, INTEGER_TYPE_MAXIMUM, + INTEGER_TYPE_MINIMUM): New macros. + +Tue Aug 27 01:06:34 1996 Roland McGrath + + * Version 3.75 released. + + * main.c (print_version): Print out bug-reporting address. + +Mon Aug 26 19:55:47 1996 Roland McGrath + + * main.c (print_data_base): Don't declare ctime; headers do it for us + already. + +Sun Jul 28 15:37:09 1996 Rob Tulloh (tulloh@tivoli.com) + + * w32/pathstuff.c: Turned convert_vpath_to_w32() into a + real function. This was done so that VPATH could contain + white space separated pathnames. Please note that directory + paths (in VPATH/vpath context) containing white space are not + supported (just as they are not under Unix). See README.W32 + for suggestions. + + * w32/include/pathstuff.h: Added prototype for the new + function convert_vpath_to_w32. Deleted macro for same. + + * README.W32: Added some notes about why I chose not to try + and support pathnames which contain white space and some + workaround suggestions. + +Thu Jul 25 19:53:31 1996 Roland McGrath + + * GNUmakefile (mkdep-nolib): Use -MM option unconditionally. + + * Version 3.74.7. + + * main.c (define_makeflags): Back up P to point at null terminator + when killing final space and dash before setting MFLAGS. + + From Robert Hoehne : + * dir.c [__MSDOS__ && DJGPP > 1]: Include and defin + `__opendir_flags' initialized to 0. + (dosify) [__MSDOS__ && DJGPP > 1]: Return name unchanged if _USE_LFN. + (find_directory) [__MSDOS__ && DJGPP > 1]: If _USE_LGN, set + __opendir_flags to __OPENDIR_PRESERVE_CASE. + + * vmsfunctions.c (vms_stat): `sys$dassgn (DevChan);' added by kkaempf. + + * GNUmakefile (w32files): Add NMakefile. + + * NMakefile (LDFLAGS_debug): Value fixed by tulloh. + +Sat Jul 20 12:32:10 1996 Klaus Kämpf (kkaempf@progis.de) + + * remake.c (f_mtime) [VMS]: Add missing `if' conditional for future + modtime check. + * config.h-vms, makefile.vms, readme.vms, vmsify.c: Update address. + +Sat Jul 20 05:29:43 1996 Roland McGrath + + * configure.in: Require autoconf 2.10 or later. + +Fri Jul 19 16:57:27 1996 Roland McGrath + + * Version 3.74.6. + + * GNUmakefile (w32files): New variable. + (distfiles): Add it. + * w32: Updated by Rob Tulloh. + + * makefile.vms (LOADLIBES): Fix typo. + +Sun Jul 14 12:59:27 1996 Roland McGrath + + * job.c (construct_command_argv_internal): Fix up #else, #endifs. + + * configh.dos: Define HAVE_DIRENT_H instead of DIRENT. + + * remake.c (f_mtime): Don't compare MTIME to NOW if MTIME == -1. + + * Version 3.74.5. + + * main.c (main): Exit with status 2 when update_goal_chain returns 2. + +Sat Jun 22 14:56:05 1996 Roland McGrath + + * configure.in: Don't check for _sys_siglist. + * make.h [HAVE__SYS_SIGLIST]: Don't test this; just punt if there is + no strsignal or sys_siglist. + + * read.c (conditional_line): Strip ws in `ifeq (a , b)' so it is the + same as `ifeq (a, b)'. + + * job.c (reap_children): Don't call die if handling_fatal_signal. + + * file.c (file_hash_enter): Allow renaming :: to : when latter is + non-target, or : to :: when former is non-target. + + * job.c (start_job_command): Call block_sigs. + (block_sigs): New function, broken out of start_job_command. + (reap_children): Block fatal signals around removing dead child from + chain and adjusting job_slots_used. + * job.h: Declare block_sigs. + + * remote-stub.c (remote_setup, remote_cleanup): New (empty) functions. + * main.c (main): Call remote_setup. + (die): Call remote_cleanup. + + * job.c (reap_children): Quiescent value of shell_function_pid is + zero, not -1. + + * main.c (print_version): Add 96 to copyright years. + +Sat Jun 15 20:30:01 1996 Andreas Schwab + + * read.c (find_char_unquote): Avoid calling strlen on every call + just to throw away the value most of the time. + +Sun Jun 2 12:24:01 1996 Roland McGrath + + * main.c (decode_env_switches): Prepend '-' to ARGV[1] if it contains + no '=', regardless of ARGC. + (define_makeflags): Elide leading '-' from MAKEFLAGS value if first + word is short option, regardless of WORDS. + +Wed May 22 17:24:51 1996 Roland McGrath + + * makefile.vms: Set LOADLIBES. + * makefile.com (link_using_library): Fix typo. + +Wed May 15 17:37:26 1996 Roland McGrath + + * dir.c (print_dir_data_base): Use %ld dev and ino and cast them to + long. + +Wed May 15 10:14:14 CDT 1996 Rob Tulloh + + * dir.c: W32 does not support inode. For now, fully qualified + pathname along with st_mtime will be keys for files. + Fixed problem where vpath can be confused when files + are added to a directory after the directory has already been + read in. The code now attempts to reread the directory if it + discovers that the datestamp on the directory has changed since + it was cached by make. This problem only seems to occur on W32 + right now so it is lumped under port #ifdef WINDOWS32. + + * function.c: W32: call subproc library (CreateProcess()) instead of + fork/exec. + + * job.c: W32: Added the code to do fork/exec/waitpid style processing + on W32 systems via calls to subproc library. + + * main.c: W32: Several things added here. First, there is code + for dealing with PATH and SHELL defaults. Make tries to figure + out if the user has %PATH% set in the environment and sets it to + %Path% if it is not set already. Make also looks to see if sh.exe + is anywhere to be found. Code path through job.c will change + based on existence of a working Bourne shell. The checking for + default shell is done twice: once before makefiles are read in + and again after. Fall back to MSDOS style execution mode if no sh.exe + is found. Also added some debug support that allows user to pause make + with -D switch and attach a debugger. This is especially useful for + debugging recursive calls to make where problems appear only in the + sub-make. + + * make.h: W32: A few macros and header files for W32 support. + + * misc.c: W32: Added a function end_of_token_w32() to assist + in parsing code in read.c. + + * read.c: W32: Fixes similar to MSDOS which allow colon to + appear in filenames. Use of colon in filenames would otherwise + confuse make. + + * remake.c: W32: Added include of io.h to eliminate compiler + warnings. Added some code to default LIBDIR if it is not set + on W32. + + * variable.c: W32: Added support for detecting Path/PATH + and converting them to semicolon separated lists for make's + internal use. New function sync_Path_environment() + which is called in job.c and function.c before creating a new + process. Caller must set Path in environment since we don't + have fork() to do this for us. + + * vpath.c: W32: Added detection for filenames containing + forward or backward slashes. + + * NMakefile: W32: Visual C compatible makefile for use with nmake. + Use this to build GNU make the first time on Windows NT or Windows 95. + + * README.W32: W32: Contains some helpful notes. + + * build_w32.bat: W32: If you don't like nmake, use this the first + time you build GNU make on Windows NT or Windows 95. + + * config.h.W32: W32 version of config.h + + * subproc.bat: W32: A bat file used to build the + subproc library from the top-level NMakefile. Needed because + WIndows 95 (nmake) doesn't allow you to cd in a make rule. + + * w32/include/dirent.h + * w32/compat/dirent.c: W32: opendir, readdir, closedir, etc. + + * w32/include/pathstuff.h: W32: used by files needed functions + defined in pathstuff.c (prototypes). + + * w32/include/sub_proc.h: W32: prototypes for subproc.lib functions. + + * w32/include/w32err.h: W32: prototypes for w32err.c. + + * w32/pathstuff.c: W32: File and Path/Path conversion functions. + + * w32/subproc/build.bat: W32: build script for subproc library + if you don't wish to use nmake. + + * w32/subproc/NMakefile: W32: Visual C compatible makefile for use + with nmake. Used to build subproc library. + + * w32/subproc/misc.c: W32: subproc library support code + * w32/subproc/proc.h: W32: subproc library support code + * w32/subproc/sub_proc.c: W32: subproc library source code + * w32/subproc/w32err.c: W32: subproc library support code + +Mon May 13 14:37:42 1996 Roland McGrath + + * Version 3.74.4. + + * GNUmakefile (vmsfiles): Fix typo. + + * GNUmakefile (amigafiles): Add amiga.h. + +Sun May 12 19:19:43 1996 Aaron Digulla + + * dir.c: New function: amigafy() to fold filenames + Changes HASH() to HASHI() to fold filenames on Amiga. + Stringcompares use strieq() instead of streq() + The current directory on Amiga is "" instead of "." + * file.c: Likewise. + + * amiga.c: New function wildcard_expansion(). Allows to use + Amiga wildcards with $(wildcard ) + + * amiga.h: New file. Prototypes for amiga.c + + * function.c: Use special function wildcard_expansion() for + $(wildcard ) to allow Amiga wildcards + The current directory on Amiga is "" instead of "." + + * job.c: No Pipes on Amiga, too + (load_too_high) Neither on Amiga + ENV variable on Amiga are in a special directory and are not + passed as third argument to main(). + + * job.h: No envp on Amiga + + * make.h: Added HASHI(). This is the same as HASH() but converts + it's second parameter to lowercase on Amiga to fold filenames. + + * main.c: (main), variable.c Changed handling of ENV-vars. Make + stores now the names of the variables only and reads their contents + when they are accessed to reflect that these variables are really + global (ie. they CAN change WHILE make runs !) This handling is + made in lookup_variable() + + * Makefile.ami: renamed file.h to filedep.h + Updated dependencies + + * read.c: "find_semicolon" is declared as static but never defined. + No difference between Makefile and makefile on Amiga; added + SMakefile to *default_makefiles[]. + (read_makefile) SAS/C want's two_colon and pattern_percent be set + before use. + The current directory on Amiga is "" instead of "." + Strange #endif moved. + + * README.Amiga: updated feature list + + * SMakefile: Updated dependencies + + * variable.c: Handling of ENV variable happens inside lookup_variable() + +Sat May 11 17:58:32 1996 Roland McGrath + + * variable.c (try_variable_definition): Count parens in lhs variable + refs to avoid seeing =/:=/+= inside a ref. + +Thu May 9 13:54:49 1996 Roland McGrath + + * commands.c (fatal_error_signal) [SIGQUIT]: Make SIGQUIT check + conditional. + + * main.c (main): Use unsigned for fread return. + + * read.c (parse_file_seq): Use `int' for char arg to avoid widening + conflict issues. + * dep.h: Fix prototype. + + * function.c (expand_function) [_AMIGA]: Fix some typos. + (patsubst_expand): Make len vars unsigned. + + * GNUmakefile (globfiles): Add AmigaDOS support files. + (distfiles): Add $(amigafiles). + (amigafiles): New variable. + +Thu Nov 7 10:18:16 1995 Aaron Digulla + + * Added Amiga support in commands.c, dir.c, function.c, + job.c, main.c, make.h, read.c, remake.c + * commands.c: Amiga has neither SIGHUP nor SIGQUIT + * dir.c: Amiga has filenames with Upper- and Lowercase, + but "FileName" is the same as "filename". Added strieq() + which is use to compare filenames. This is like streq() + on all other systems. Also there is no such thing as + "." under AmigaDOS. + * function.c: On Amiga, the environment is not passed as envp, + there are no pipes and Amiga can't fork. Use my own function + to create a new child. + * job.c: default_shell is "" (The system automatically chooses + a shell for me). Have to use the same workaround as MSDOS for + running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't + known on Amiga. Cloned code to run children from MSDOS. Own + version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga. + * main.c: Force stack to 20000 bytes. Read environment from ENV: + device. On Amiga, exec_command() does return, so I exit() + afterwards. + * make.h: Added strieq() to compare filenames. + * read.c: Amiga needs special extension to have passwd. Only + one include-dir. "Makefile" and "makefile" are the same. + Added "SMakefile". Added special code to handle device names (xxx:) + and "./" in rules. + * remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib" + instead of "lib%s.a". + * main.c, rule.c, variable.c: Avoid floats at all costs. + * vpath.c: Get rid of as many alloca()s as possible. + +Thu May 9 13:20:43 1996 Roland McGrath + + * read.c (read_makefile): Grok `sinclude' as alias for `-include'. + +Wed Mar 20 09:52:27 1996 Roland McGrath + + * GNUmakefile (vmsfiles): New variable. + (distfiles): Include $(vmsfiles). + +Tue Mar 19 20:21:34 1996 Roland McGrath + + Merged VMS port from Klaus Kaempf . + * make.h (PARAMS): New macro. + * config.h-vms: New file. + * makefile.com: New file. + * makefile.vms: New file. + * readme.vms: New file. + * vmsdir.h: New file. + * vmsfunctions.c: New file. + * vmsify.c: New file. + * file.h: Renamed to filedef.h to avoid conflict with VMS system hdr. + * ar.c: Added prototypes and changes for VMS. + * commands.c: Likewise. + * commands.h: Likewise. + * default.c: Likewise. + * dep.h: Likewise. + * dir.c: Likewise. + * expand.c: Likewise. + * file.c: Likewise. + * function.c: Likewise. + * implicit.c: Likewise. + * job.c: Likewise. + * job.h: Likewise. + * main.c: Likewise. + * make.h: Likewise. + * misc.c: Likewise. + * read.c: Likewise. + * remake.c: Likewise. + * remote-stub.c: Likewise. + * rule.c: Likewise. + * rule.h: Likewise. + * variable.c: Likewise. + * variable.h: Likewise. + * vpath.c: Likewise. + * compatMakefile (srcs): Rename file.h to filedef.h. + +Sat Aug 19 23:11:00 1995 Richard Stallman + + * remake.c (check_dep): For a secondary file, try implicit and + default rules if appropriate. + +Wed Aug 2 04:29:42 1995 Richard Stallman + + * remake.c (check_dep): If an intermediate file exists, + do consider its actual date. + +Sun Jul 30 00:49:53 1995 Richard Stallman + + * file.h (struct file): New field `secondary'. + * file.c (snap_deps): Check for .INTERMEDIATE and .SECONDARY. + (remove_intermediates): Don't delete .SECONDARY files. + +Sat Mar 2 16:26:52 1996 Roland McGrath + + * compatMakefile (srcs): Add getopt.h; prepend $(srcdir)/ to getopt*. + +Fri Mar 1 12:04:47 1996 Roland McGrath + + * Version 3.74.3. + + * remake.c (f_mtime): Move future modtime check before FILE is + clobbered by :: loop. + + * dir.c: Use canonical code from autoconf manual for dirent include. + [_D_NAMLEN]: Redefine NAMLEN using this. + (dir_contents_file_exists_p): Use NAMLEN macro. + (read_dirstream) [_DIRENT_HAVE_D_NAMLEN]: Only set d_namlen #if this. + + * compatMakefile (objs): Add missing backslash. + +Wed Feb 28 03:56:20 1996 Roland McGrath + + * default.c (default_terminal_rules): Remove + prefix from RCS cmds. + (default_variables): Put + prefix in $(CHECKOUT,v) value instead. + + * remake.c (f_mtime): Check for future timestamps; give error and mark + file as "failed to update". + +Fri Jan 12 18:09:36 1996 Roland McGrath + + * job.c: Don't declare unblock_sigs; job.h already does. + +Sat Jan 6 16:24:44 1996 Roland McGrath + + * acconfig.h (HAVE_SYSCONF_OPEN_MAX): #undef removed. + + * job.c (NGROUPS_MAX): Don't try to define this macro. + +Fri Dec 22 18:44:44 1995 Roland McGrath + + * compatMakefile (GETOPT, GETOPT_SRC, GLOB): Variables removed. + (objs, srcs): Include their values here instead of references. + +Thu Dec 14 06:21:29 1995 Roland McGrath + + * Version 3.74.2. + + * job.c (reap_children): Call unblock_sigs after start_job_command. + +Thu Dec 14 07:22:03 1995 Roland McGrath + + * dir.c (dir_setup_glob): Don't use lstat; glob never calls it anyway. + Avoid & before function names to silence bogus sunos4 compiler. + + * configure.in: Remove check for `sysconf (_SC_OPEN_MAX)'. + +Tue Dec 12 00:48:42 1995 Roland McGrath + + * Version 3.74.1. + + * dir.c (read_dirstream): Fix braino: fill in the buffer when not + reallocating it! + +Mon Dec 11 22:26:15 1995 Roland McGrath + + * misc.c (collapse_continuations): Fix skipping of trailing \s so + it can never dereference before the beginning of the array. + + * read.c (find_semicolon): Function removed. + (read_makefile): Don't use find_semicolon or remove_comments for + rule lines. Use find_char_unquote directly and handle quoted comments + properly. + + * default.c: Remove all [M_XENIX] code. + + * dir.c [HAVE_D_NAMLEN]: Define this for __GNU_LIBRARY__ > 1. + (D_NAMLEN): Macro removed. + (FAKE_DIR_ENTRY): New macro. + (dir_contents_file_exists_p): Test HAVE_D_NAMLEN instead of using + D_NAMLEN. + (read_dirstream): Return a struct dirent * for new glob interface. + (init_dir): Function removed. + (dir_setup_glob): New function. + * main.c (main): Don't call init_dir. + * read.c (multi_glob): Call dir_setup_glob on our glob_t and use + GLOB_ALTDIRFUNC flag. + + * misc.c (safe_stat): Function removed. + * read.c, commands.c, remake.c, vpath.c: Use plain stat instead of + safe_stat. + +Sat Nov 25 20:35:18 1995 Roland McGrath + + * job.c [HAVE_UNION_WAIT]: Include sys/wait.h. + + * main.c (log_working_directory): Made global. + Print entering msg only once. + * make.h (log_working_directory): Declare it. + * misc.c (message): Take new arg PREFIX. Print "make: " only if + nonzero. Call log_working_directory. + * remake.c: Pass new arg in `message' calls. + * job.c (start_job_command): Pass new arg to `message'; fix + inverted test in that call. + +Tue Nov 21 19:01:12 1995 Roland McGrath + + * job.c (start_job_command): Use `message' to print the command, + and call it with null if the command is silent. + * remake.c (touch_file): Use message instead of printf. + +Tue Oct 10 14:59:30 1995 Roland McGrath + + * main.c (enter_command_line_file): Barf if NAME is "". + +Sat Sep 9 06:33:20 1995 Roland McGrath + + * commands.c (delete_target): Ignore unlink failure if it is ENOENT. + +Thu Aug 17 15:08:57 1995 Roland McGrath + + * configure.in: Don't check for getdtablesize. + * job.c (getdtablesize): Remove decls and macros. + +Thu Aug 10 19:10:03 1995 Roland McGrath + + * main.c (define_makeflags): Omit command line variable + definitions from MFLAGS value. + + * arscan.c (ar_scan) [AIAMAG]: Check for zero MEMBER_OFFSET, + indicating a valid, but empty, archive. + +Mon Aug 7 15:40:03 1995 Roland McGrath + + * dir.c (file_impossible_p): Correctly reset FILENAME to name + within directory before hash search. + + * job.c (child_error): Do nothing if IGNORED under -s. + + * job.c (exec_command): Correctly use ARGV[0] for script name when + running shell directly. + +Tue Aug 1 14:39:14 1995 Roland McGrath + + * job.c (child_execute_job): Close STDIN_FD and STDOUT_FD after + dup'ing from them. Don't try to close all excess descriptors; + getdtablesize might return a huge value. Any open descriptors in + the parent should have FD_CLOEXEC set. + (start_job_command): Set FD_CLOEXEC flag on BAD_STDIN descriptor. + +Tue Jun 20 03:47:15 1995 Roland McGrath + + * read.c (read_all_makefiles): Properly append default makefiles + to the end of the `read_makefiles' chain. + +Fri May 19 16:36:32 1995 Roland McGrath + + * Version 3.74 released. + +Wed May 10 17:43:34 1995 Roland McGrath + + * Version 3.73.3. + +Tue May 9 17:15:23 1995 Roland McGrath + + * compatMakefile ($(infodir)/make.info): Make sure $$dir is set in + install-info cmd. + +Wed May 3 15:56:06 1995 Roland McGrath + + * file.c (print_file): Grok update_status of 1 for -q. + +Thu Apr 27 12:39:35 1995 Roland McGrath + + * Version 3.73.2. + +Wed Apr 26 17:15:57 1995 Roland McGrath + + * file.c (remove_intermediates): Fix inverted test to bail under + -n for signal case. Bail under -q or -t. + Skip files with update_status==-1. + + * job.c (job_next_command): Skip empty lines. + (new_job): Don't test the return of job_next_command. + Just let start_waiting_job handle the case of empty commands. + +Wed Apr 19 03:25:54 1995 Roland McGrath + + * function.c [__MSDOS__]: Include . From DJ Delorie. + + * Version 3.73.1. + +Sat Apr 8 14:53:24 1995 Roland McGrath + + * remake.c (notice_finished_file): Set FILE->update_status to zero + if it's -1. + +Wed Apr 5 00:20:24 1995 Roland McGrath + + * Version 3.73 released. + +Tue Mar 28 13:25:46 1995 Roland McGrath + + * main.c (main): Fixed braino in assert. + + * Version 3.72.13. + +Mon Mar 27 05:29:12 1995 Roland McGrath + + * main.c: Avoid string in assert expression. Some systems are broken. + +Fri Mar 24 00:32:32 1995 Roland McGrath + + * main.c (main): Handle 1 and 2 returns from update_goal_chain + makefile run properly. + + * Version 3.72.12. + + * main.c (handle_non_switch_argument): New function, broken out of + decode_switches. + (decode_switches): Set optind to 0 to reinitialize getopt, not to 1. + When getopt_long returns EOF, break the loop and handle remaining args + with a simple second loop. + + * remake.c (remake_file): Set update_status to 2 instead of 1 for + no rule to make. Mention parent (dependent) in error message. + (update_file_1): Handle FILE->update_status == 2 in -d printout. + * job.c (start_job_command, reap_children): Set update_status to 2 + instead of 1 for failed commands. + +Tue Mar 21 16:23:38 1995 Roland McGrath + + * job.c (search_path): Function removed (was already #if 0'd out). + * configure.in: Remove AC_TYPE_GETGROUPS; nothing needs it any more. + +Fri Mar 17 15:57:40 1995 Roland McGrath + + * configure.bat: Write @CPPFLAGS@ translation. + +Mon Mar 13 00:45:59 1995 Roland McGrath + + * read.c (parse_file_seq): Rearranged `l(a b)' -> `l(a) l(b)' loop + to not skip the elt immediately preceding `l(...'. + +Fri Mar 10 13:56:49 1995 Roland McGrath + + * Version 3.72.11. + + * read.c (find_char_unquote): Make second arg a string of stop + chars instead of a single stop char. Stop when any char in the + string is hit. All callers changed. + (find_semicolon): Pass stop chars "#;" to one find_char_unquote call, + instead of using two calls. If the match is not a ; but a #, + return zero. + * misc.c: Changed find_char_unquote callers here too. + + * Version 3.72.10. + + * read.c (read_makefile, parse_file_seq): Fix typo __MS_DOS__ -> + __MSDOS__. + + * GNUmakefile (globfiles): Add glob/configure.bat. + (distfiles): Add configh.dos, configure.bat. + +Wed Mar 8 13:10:57 1995 Roland McGrath + + Fixes for MS-DOS from DJ Delorie. + * read.c (read_makefile, parse_file_seq) [__MS_DOS__]: Don't see : + as separator in "C:\...". + * configh.dos (STDC_HEADERS): Define only if undefined. + (HAVE_SYS_PARAM_H): Don't define this. + (HAVE_STRERROR): Define this. + * job.c (construct_command_argv_internal) [__MSDOS__]: Fix typos. + + * Version 3.72.9. + + * main.c (decode_switches): Reset optind to 1 instead of 0. + +Tue Mar 7 17:31:06 1995 Roland McGrath + + * main.c (decode_switches): If non-option arg is "-", ignore it. + +Mon Mar 6 23:57:38 1995 Roland McGrath + + * Version 3.72.8. + +Wed Feb 22 21:26:36 1995 Roland McGrath + + * Version 3.72.7. + +Tue Feb 21 22:10:43 1995 Roland McGrath + + * main.c (main): Pass missing arg to tmpnam. + + * configure.in: Check for strsignal. + * job.c (child_error): Use strsignal. + * main.c (main): Don't call signame_init #ifdef HAVE_STRSIGNAL. + + * misc.c (strerror): Fix swapped args in sprintf. + +Mon Feb 13 11:50:08 1995 Roland McGrath + + * configure.in (CFLAGS, LDFLAGS): Don't set these variables. + +Fri Feb 10 18:44:12 1995 Roland McGrath + + * main.c (print_version): Add 95 to copyright years. + + * Version 3.72.6. + + * job.c (start_job_command): Remember to call notice_finished_file + under -n when not recursing. To do this, consolidate that code + under the empty command case and goto there for the -n case. + +Tue Feb 7 13:36:03 1995 Roland McGrath + + * make.h [! STDC_HEADERS]: Don't declare qsort. Sun headers + declare it int. + +Mon Feb 6 17:37:01 1995 Roland McGrath + + * read.c (read_makefile): For bogus line starting with tab, ignore + it if blank after removing comments. + + * main.c: Cast results of `alloca' to `char *'. + * expand.c: Likewise. + +Sun Feb 5 18:35:46 1995 Roland McGrath + + * Version 3.72.5. + + * configure.in: Check for mktemp. + * main.c (main) [! HAVE_MKTEMP]: Use tmpnam instead of mktemp. + + * configure.in (make_cv_sysconf_open_max): New check for `sysconf + (_SC_OPEN_MAX)'. + * acconfig.h: Added #undef HAVE_SYSCONF_OPEN_MAX. + * job.c [HAVE_SYSCONF_OPEN_MAX] (getdtablesize): Define as macro + using sysconf. + +Fri Jan 27 04:42:09 1995 Roland McGrath + + * remake.c (update_file_1): When !MUST_MAKE, don't set + FILE->update_status to zero before calling notice_finished_file. + (notice_finished_file): Touch only when FILE->update_status is zero. + (remake_file): Set FILE->update_status to zero after not calling + execute_file_command and deciding to touch instead. + +Thu Jan 26 01:29:32 1995 Roland McGrath + + * main.c (debug_signal_handler): New function; toggles debug_flag. + (main): Handle SIGUSR1 with that. + +Mon Jan 16 15:46:56 1995 Roland McGrath + + * compatMakefile (realclean): Remove Info files. + +Sun Jan 15 08:23:09 1995 Roland McGrath + + * Version 3.72.4. + + * job.c (start_job_command): Save and restore environ around vfork + call. + (search_path): Function #if 0'd out. + (exec_command): Use execvp instead of search_path. + + * expand.c (variable_expand): Rewrote computed variable name and + substitution reference handling to be simpler. First expand the + entire text between the parens if it contains any $s, then examine + the result of that for subtitution references and do no further + expansion while parsing them. + + * job.c (construct_command_argv_internal): Handle " quoting too, + when no backslash, $ or ` characters appear inside the quotes. + + * configure.in (union wait check): If WEXITSTATUS and WTERMSIG are + defined, just use int. + +Tue Jan 10 06:27:27 1995 Roland McGrath + + * default.c (default_variables) [__hpux]: Remove special + definition of ARFLAGS. Existence of the `f' flag is not + consistent across HPUX versions; and one might be using GNU ar + anyway. + + * compatMakefile (clean): Don't remove Info files. + + * compatMakefile (check): Remove gratuitous target declaration. + +Sat Jan 7 11:38:23 1995 Roland McGrath + + * compatMakefile (ETAGS, CTAGS): Don't use -t. + + * arscan.c (ar_name_equal) [cray]: Subtract 1 like [__hpux]. + + * main.c (decode_switches): For --help, print usage to stdout. + +Mon Dec 5 12:42:18 1994 Roland McGrath + + * Version 3.72.3. + + * remake.c (update_file_1): Do set_command_state (FILE, + cs_not_started) only if old state was deps_running. + +Mon Nov 28 14:24:03 1994 Roland McGrath + + * job.c (start_waiting_job): Use set_command_state. + + * build.template (CPPFLAGS): New variable. + (prefix, exec_prefix): Set from @...@. + (compilation loop): Pass $CPPFLAGS to compiler. + + * GNUmakefile (build.sh.in): Make it executable. + + * GNUmakefile (globfiles): Add configure.in, configure. + + * Version 3.72.2. + + * configure.in (AC_OUTPUT): Don't write glob/Makefile. + + * configure.in (AC_CHECK_SYMBOL): Use AC_DEFINE_UNQUOTED. + + * configure.in: Don't check for ranlib. + +Tue Nov 22 22:42:40 1994 Roland McGrath + + * remake.c (notice_finished_file): Only mark also_make's as + updated if really ran cmds. + +Tue Nov 15 06:32:46 1994 Roland McGrath + + * configure.in: Put dnls before random whitespace. + +Sun Nov 13 05:02:25 1994 Roland McGrath + + * compatMakefile (CPPFLAGS): New variable, set from @CPPFLAGS@. + (RANLIB): Variable removed. + (prefix, exec_prefix): Set these from @...@. + (.c.o): Use $(CPPFLAGS). + (glob/libglob.a): Don't pass down variables to sub-make. + glob/Makefile should be configured properly by configure. + (distclean): Remove config.log and config.cache (autoconf stuff). + +Mon Nov 7 13:58:06 1994 Roland McGrath + + * acconfig.h: Add #undef HAVE_UNION_WAIT. + * configure.in: Converted to Autoconf v2. + * dir.c: Test HAVE_DIRENT_H, HAVE_SYS_DIR_H, HAVE_NDIR_H instead + of DIRENT, SYSDIR, NDIR. + * build.sh.in (prefix, exec_prefix): Set these from @...@. + (CPPFLAGS): New variable, set from @CPPFLAGS@. + (compiling loop): Pass $CPPFLAGS before $CFLAGS. + * install.sh: File renamed to install-sh. + + * main.c (define_makeflags): When no flags, set WORDS to zero. + +Sun Nov 6 18:34:01 1994 Roland McGrath + + * Version 3.72.1. + + * main.c (define_makeflags): Terminate properly when FLAGSTRING is + empty. + +Fri Nov 4 16:02:51 1994 Roland McGrath + + * Version 3.72. + +Tue Nov 1 01:18:10 1994 Roland McGrath + + * Version 3.71.5. + + * job.c (start_job_command): When ARGV is nil, only set + update_state and call notice_finished_file if job_next_command + returns zero. + + * job.c (start_job_command): Call notice_finished_file for empty + command line. + +Thu Oct 27 02:02:45 1994 Roland McGrath + + * file.c (snap_deps): Set COMMANDS_SILENT for .SILENT, not + COMMANDS_NOERROR. + +Wed Oct 26 02:14:10 1994 Roland McGrath + + * Version 3.71.4. + +Tue Oct 25 22:49:24 1994 Roland McGrath + + * file.c (snap_deps): Set command_flags bits in all :: entries. + +Mon Oct 24 18:47:50 1994 Roland McGrath + + * make.h (posix_pedantic): Declare it. + * main.c (main): Move checks .IGNORE, .SILENT, .POSIX to + snap_deps. + * file.c (snap_deps): Check .IGNORE, .SILENT, .POSIX here instead + of in main. If .IGNORE has deps, OR COMMANDS_NOERROR into their + command_flags and don't set -i. Likewise .SILENT. + * job.c (start_job_command): In FLAGS initialization, OR in + CHILD->file->command_flags. + * file.h (struct file): New member `command_flags'. + +Sun Oct 16 01:01:51 1994 Roland McGrath + + * main.c (switches): Bump flag values for --no-print-directory and + --warn-undefined-variables, so neither is 1 (which indicates a + nonoption argument). + +Sat Oct 15 23:39:48 1994 Roland McGrath + + * main.c (main): Add missing code in .IGNORE test. + +Mon Oct 10 04:09:03 1994 Roland McGrath + + * variable.c (define_automatic_variables): Define +D and +F. + +Sat Oct 1 04:07:48 1994 Roland McGrath + + * main.c (main): Define hidden automatic variable with command + vars, and MAKEOVERRIDES to a reference to that. + (define_makeflags): If posix_pedantic, write a reference to that + instead. + +Thu Sep 29 00:14:26 1994 Roland McGrath + + * main.c (posix_pedantic): New variable. + (main): Set posix_pedantic if .POSIX is a target. + Fix .IGNORE and .SILENT checks to require is_target. + + * commands.c (set_file_variables): Define new automatic variable + $+, like $^ but before calling uniquize_deps. + + * job.c (reap_children): Call delete_child_targets for non-signal + error if .DELETE_ON_ERROR is a target. + +Tue Sep 27 01:57:14 1994 Roland McGrath + + * Version 3.71.3. + +Mon Sep 26 18:16:55 1994 Roland McGrath + + * job.c (reap_children): Don't change C->file->command_state when + dying. Test it only after calling start_job_command for a new + command line. When no more cmds, just set C->file->update_status. + (start_job_command): When the last line is empty or under -n, set + C->file->update_status. + (start_waiting_job): Grok cs_not_started after start_job_command + as success. + (new_job): Set C->file->update_status when there are no cmds. + (job_next_command): When out of lines, don't set + CHILD->file->update_status or CHILD->file->command_state. + + * main.c (quote_as_word): Renamed from shell_quote. Take new arg; + if nonzero, also double $s. + (main): Define MAKEOVERRIDES from command_variables here. + (define_makeflags): Don't use command_variables here; instead write a + reference $(MAKEOVERRIDES) in MAKEFLAGS. Make vars recursive. + + * dir.c [__MSDOS__]: Fixed typo. + + * vpath.c (selective_vpath_search): Reset EXISTS when stat fails. + +Sat Sep 10 03:01:35 1994 Roland McGrath + + * remake.c: Include and use assert instead of printfs + and abort. + + * main.c (decode_switches): Loop until optind hits ARGC, not just + until getopt_long returns EOF. Initialize C to zero before loop; + in loop if C is EOF, set optarg from ARGV[optind++], else call + getopt_long. + (decode_env_switches): Use variable_expand instead of + allocated_variable_expand. Allocate a fresh buffer to copy split + words into; scan characters by hand to break words and + debackslashify. + (shell_quote): New function. + (define_makeflags): Allocate doubled space for switch args, and command + variable names and values; use shell_quote to quote those things. + +Fri Sep 9 01:37:47 1994 Roland McGrath + + * Version 3.71.2. + + * acconfig.h: Add HAVE_SYS_SIGLIST and HAVE__SYS_SIGLIST. + + * main.c (decode_switches): The non-option return from getopt is + 1, not 0. + (command_variables): New type and variable. + (decode_switches, decode_env_switches): After making a variable + definition, record the struct variable pointer in the + command_variables chain. + (define_makeflags): If ALL, write variable definitions for + command_variables. + + * main.c (other_args): Variable removed. + (goals, lastgoal): New static variables (moved from auto in main). + (main): Don't process OTHER_ARGS at all. + Don't set variable MAKEOVERRIDES at all; define MAKE to just + $(MAKE_COMMAND). + (init_switches): Prepend a - {return in order} instead of a + + {require order}. + (decode_switches): Don't set OTHER_ARGS at all. + Grok '\0' return from getopt_long as non-option argument; try + variable definition and (if !ENV) enter goal targets here. + (decode_env_switches): Use allocated_variable_expand to store value. + Use find_next_token to simplify word-splitting loop. Don't + prepend a dash to uninterpreted value. Instead, if split into + only one word, try variable definition and failing that prepend a + dash to the word and pass it to decode_switches as a single arg. + +Wed Sep 7 03:02:46 1994 Roland McGrath + + * remake.c (notice_finished_file): Only recheck modtimes if + FILE->command_state was cs_running on entry (meaning the commands + actually just ran). + (update_file_1): Whenever we set FILE->update_status, call + notice_finished_file instead of just set_command_state. + * job.c (start_job_command): Whenever we set + CHILD->file->update_status, call notice_finished_file instead of + just set_command_state. + +Tue Sep 6 19:13:54 1994 Roland McGrath + + * default.c: Add missing ". + + * job.c: Changed all assignments of command_state members to calls + to set_command_state. + * remake.c: Likewise. + * file.c (set_command_state): New function. + * file.h: Declare set_command_state. + + * main.c (init_switches): Put a + first in options. + +Mon Jul 25 18:07:46 1994 Roland McGrath + + Merge MSDOS/GO32 port from DJ Delorie . + * vpath.c: Changed all uses of ':' to PATH_SEPARATOR_CHAR. + * main.c (directory_before_chdir): New variable, moved out of main + (was local). + (main) [__MSDOS__]: Look for \ or : to delimit last component of + PROGRAM. Don't frob ARGV[0] before setting MAKE_COMMAND variable. + (die): Change back to `directory_before_chdir' before dying. + * make.h (PATH_SEPARATOR_CHAR): New macro; differing defns for + [__MSDOS__] and not. + * job.c [__MSDOS__]: Include . + [__MSDOS__] (dos_pid, dos_status, dos_bname, dos_bename, + dos_batch_file): New variables. + (reap_children) [__MSDOS__]: Don't call wait; just examine those vars. + (unblock_sigs) [__MSDOS__]: Do nothing. + (start_job_command) [__MSDOS__]: Use spawnvpe instead of vfork & exec. + (load_too_high) [__MSDOS__]: Always return true. + (search_path) [__MSDOS__]: Check for : or / in FILE to punt. + Use PATH_SEPARATOR_CHAR instead of ':'. + (construct_command_argv_internal) [__MSDOS__]: Wholly different + values for sh_chars and sh_cmds. Wholly new code to handle shell + scripts. + * function.c (expand_function: `shell') [__MSDOS__]: Wholly new + implementation. + * dir.c [__MSDOS__] (dosify): New function. + (dir_contents_file_exists_p) [__MSDOS__]: Call it on FILENAME and + process the result instead of FILENAME itself. + (file_impossible_p) [__MSDOS__]: Likewise. + * default.c [__MSDOS__]: Define GCC_IS_NATIVE. + (default_suffix_rules) [__MSDOS__]: Use `y_tab.c' instead of `y.tab.c'. + (default_variables) [GCC_IS_NATIVE]: Set CC and CXX to `gcc', YACC to + `bison -y', and LEX to `flex'. + * configure.bat, configh.dos: New files. + * commands.c (fatal_error_signal) [__MSDOS__]: Just remove + intermediates and exit. + + * commands.c (set_file_variables): Add parens in length + computation in .SUFFIXES dep loop to quiet compiler warning. From + Jim Meyering. + + * read.c (read_makefile): Free FILENAME if we allocated it. From + Jim Meyering. + +Mon Jul 4 17:47:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * misc.c (safe_stat): New function, EINTR-safe wrapper around stat. + * vpath.c (selective_vpath_search): Use safe_stat in place of stat. + * read.c (construct_include_path): Use safe_stat in place of stat. + * job.c (search_path): Use safe_stat in place of stat. + * dir.c (find_directory): Use safe_stat in place of stat. + * commands.c (delete_target): Use safe_stat in place of stat. + * arscan.c (ar_member_touch) [EINTR]: Do EINTR looping around fstat. + * remake.c (name_mtime): Use safe_stat in place of stat. + (touch_file) [EINTR]: Do EINTR looping around fstat. + +Fri Jun 24 05:40:24 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Check for a shell command first, and + then strip leading tabs before further checking if it's not a + shell command line. + + * make.h [__arm]: Undefine POSIX. + [!__GNU_LIBRARY__ && !POSIX && !_POSIX_VERSION]: Don't declare system + functions that return int. + + * job.c (construct_command_argv_internal): After swallowing a + backslash-newline combination, if INSTRING is set goto string_char + (new label) for normal INSTRING handling code. + +Sat Jun 4 01:11:20 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * configure.in: Don't check for sys_siglist and _sys_siglist with + AC_HAVE_FUNCS. Instead use two AC_COMPILE_CHECKs. + +Mon May 23 18:20:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.71.1 released. + + * make.h [!__GNU_LIBRARY__ && !POSIX]: Also test #ifndef + _POSIX_VERSION for these declarations. + + * misc.c [GETLOADAVG_PRIVILEGED] [POSIX]: Remove bogus #ifndefs + around #undefs of HAVE_SETREUID and HAVE_SETREGID. + +Sat May 21 16:26:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.71 released. + + * misc.c [GETLOADAVG_PRIVILEGED] [POSIX]: Don't test [HAVE_SETUID] + and [HAVE_SETGID]. Every system has those, and configure doesn't + check for them. + + * make.h [_POSIX_VERSION]: Don't #define POSIX #ifdef ultrix. + + * compatMakefile (loadavg): Depend on and use loadavg.c instead of + getloadavg.c. + (loadavg.c): Link or copy it from getloadavg.c. + (distclean): Remove loadavg.c. + +Mon May 16 22:59:04 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.70.4. + + * misc.c [GETLOADAVG_PRIVILEGED] [! POSIX]: Undefine HAVE_SETEUID + and HAVE_SETEGID. + + * default.c (default_terminal_rules): In SCCS rules, put + $(SCCS_OUTPUT_OPTION) before $<. On some systems -G is grokked + only before the file name. + * configure.in (SCCS_GET_MINUS_G check): Put -G flag before file name. + +Tue May 10 16:27:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Swallow + backslash-newline combinations inside '' strings too. + +Thu May 5 04:15:10 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (do_define): Call collapse_continuations on each line + before all else. + +Mon Apr 25 19:32:02 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Notice newline inside + '' string when RESTP is non-null. + +Fri Apr 22 17:33:30 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.70.3. + + * remake.c (update_goal_chain): Reset FILE to G->file after the + double-colon loop so it is never null for following code. + + * read.c (read_makefile): Fix `override define' parsing to skip + whitespace after `define' properly. + + * compatMakefile (srcdir): Define as @srcdir@; don't reference + $(VPATH). + (glob/Makefile): New target. + +Thu Apr 21 16:16:55 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.70.2. + + * misc.c (remove_comments): Use find_char_unquote. + * make.h (find_char_unquote): Declare it. + * read.c (find_char_unquote): New function, generalized from + find_percent. + (find_percent, find_semicolon, parse_file_seq): Use that. + +Wed Apr 20 18:42:39 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * implicit.c (pattern_search): Always allocate new storage for + FILE->stem. It is not safe to store STEM's address because it + might be auto storage. + + * configure.in: Check for seteuid and setegid. + * misc.c [HAVE_SETEUID]: Declare seteuid. + [HAVE_SETEGID]: Declare setegid. + (make_access, user_access) [HAVE_SETEUID]: Use seteuid. + [HAVE_SETEGID]: Use setegid. + + * remake.c (update_goal_chain): Set STATUS to FILE->update_status, + to preserve whether it's 2 for error or 1 for -q trigger. When + STATUS gets nonzero and -q is set, always stop immediately. + * main.c (main, decode_switches): Die with 2 for errors. + (main): Accept 2 return from update_goal_chain and die with that. + * misc.c (fatal, makefile_fatal): Die with 2; 1 is reserved for -q + answer. + * job.c (reap_children): Die with 2 for error. + (start_job_command): Set update_status to 2 for error. Set it to + 1 when we would run a command and question_flag is set. + + * read.c (read_makefile): Don't mark makefiles as precious. Just + like other targets, they can be left inconsistent and in need of + remaking by aborted commands. + + * read.c (read_makefile): Write no error msg for -include file. + +Tue Apr 5 05:22:19 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * commands.c (fatal_error_signal): Don't unblock signals. + + * file.h (struct file): Change member `double_colon' from flag to + `struct file *'. + * read.c (record_files): Set double_colon pointer instead of flag. + * main.c (main): When disqualifying makefiles for updating, use + double_colon pointer to find all entries for a file. + * file.c (enter_file): If there is already a double-colon entry + for the file, set NEW->double_colon to that pointer. + (file_hash_enter): Use FILE->double_colon to find all entries to + set name. + * remake.c (update_goal_chain): Do inner loop on double-colon entries. + (update_file): Use FILE->double_colon pointer to find all entries. + (f_mtime): Likewise. + (notice_finished_file): Propagate mtime change to all entries. + + * variable.c (try_variable_definition): Return after abort. + +Fri Apr 1 18:44:15 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Remove unused variable. + (parse_file_seq): When removing an elt that is just `)', properly + fix up the previous elt's next pointer. + +Mon Mar 28 18:31:49 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) + + * configure.in: Do AC_SET_MAKE. + * GNUmakefile (Makefile.in): Edit MAKE assignment into @SET_MAKE@. + +Fri Mar 4 00:02:32 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * function.c (subst_expand): If BY_WORD or SUFFIX_ONLY is set and + the search string is the empty string, find a match at the end of + each word (using end_of_token in place of sindex). + + * misc.c (end_of_token): Don't treat backslashes specially; you + can no longer escape blanks with backslashes in export, unexport, + and vpath. This was never documented anyway. + +Thu Mar 3 23:53:46 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Variable name for `define' is not just + first token; use whole rest of line and strip trailing blanks. + +Wed Feb 16 16:03:45 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.70.1. + + * read.c (read_makefile): Add -d msg stating args. + + * read.c (read_makefile): Use isspace to skip over leading + whitespace, and explicitly avoid skipping over tabs. Don't want + to skip just spaces though; formfeeds et al should be skipped. + + * default.c (default_variables) [__hpux]: Add f in ARFLAGS. + + * arscan.c (ar_name_equal) [__hpux]: Subtract 2 instead of 1 from + sizeof ar_name for max length to compare. + + * misc.c [GETLOADAVG_PRIVILEGED] [POSIX]: Undefine HAVE_SETREUID + #ifdef HAVE_SETUID; likewise HAVE_SETREGID and HAVE_SETGID. + + * main.c (main): Call user_access after setting `program', in case + it needs to use it in an error message. + + * read.c (read_makefile): Ignore an empty line starting with a tab. + +Thu Feb 10 21:45:31 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (AC_SYS_SIGLIST_DECLARED): Use this instead of + AC_COMPILE_CHECK that is now its contents. + +Fri Feb 4 16:28:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.h: #undef strerror after #include . + [! ANSI_STRING]: Declare strerror. + +Thu Feb 3 02:21:22 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * misc.c (strerror): #undef any macro before function definition. + +Mon Jan 31 19:07:23 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * variable.c (try_variable_definition): Calculate BEG before loop + to strip blanks by decrementing END. Don't decr END to before BEG. + + * read.c (read_makefile): Skip over leading space characters, but + not tabs, after removing continuations and comments (it used to + use isspace). + +Tue Jan 25 16:45:05 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * variable.c (define_automatic_variables): In $(@D) et al, use + patsubst to remove trailing slash. + + * commands.c (delete_target): New function, broken out of + delete_child_targets. Check for archive members and give special msg. + (delete_child_targets): Use delete_target. + +Mon Jan 17 17:03:22 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * default.c (default_suffix_rules): Use $(TEXI2DVI_FLAGS) in + texi2dvi rules. Use $(MAKEINFO_FLAGS) in makeinfo rules. + +Tue Jan 11 19:29:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * GNUmakefile (tarfiles): Omit make-doc. + (make-$(version).tar): Include make.info*. + +Fri Jan 7 16:27:00 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (configure, config.h.in): Comment out rules. + +Thu Jan 6 18:08:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (binprefix, manprefix): New variables. + (instname): Variable removed. + (install): Use $({bin,man}prefix)make in place of $(instname). + File targets likewised renamed. + +Mon Jan 3 17:50:25 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.70 released. + +Thu Dec 23 14:46:54 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.69.3. + + * read.c (parse_file_seq): Inside multi-word archive ref + translation loop, check NEW1==0 at end and break out of the loop. + + * GNUmakefile (make-$(version).tar): Distribute install.sh. + * install.sh: New file. + + * configure.in (SCCS_GET_MINUS_G check): Put redirection for admin + cmds outside subshell parens, to avoid "command not found" msgs + from the shell. + +Wed Dec 22 17:00:43 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (SCCS_GET_MINUS_G check): Put -G flag last in get cmd. + Redirect output & error from get to /dev/null. + Fix reversed sense of test. + +Fri Dec 17 15:31:36 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (SCCS_GET_MINUS_G check): Use parens instead of + braces inside if condition command; some shells lose. + +Thu Dec 16 15:10:23 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.69.2. + + * arscan.c [M_UNIX]: Move #undef M_XENIX for PORTAR stuff. + (PORTAR) [M_XENIX]: Define to 0 instead of 1. + + * main.c (define_makeflags): Only export MAKEFLAGS if !ALL. + +Wed Dec 15 17:47:48 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (main): Cast result of pointer arith to unsigned int + before passing to define_variable for envars. Matters when + sizeof(unsigned)!=sizeof(ptrdiff_t). + +Tue Dec 14 14:21:16 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in: Add new check for SCCS_GET_MINUS_G. + * config.h.in: Add #undef SCCS_GET_MINUS_G. + * default.c (default_terminal_rules): Use `$(SCCS_OUTPUT_OPTION)' in + place of `-G $@' in SCCS commands. + (default_variables) [SCCS_GET_MINUS_G]: Define SCCS_OUTPUT_OPTION + to "-G$@". + + * configure.in (AC_OUTPUT): Put touch stamp-config in second arg + (so it goes in config.status), rather than afterward. + + * ar.c (ar_member_date): Don't call enter_file on the archive file + if it doesn't exist (by file_exists_p). + + * compatMakefile ($(infodir)/make.info): Replace `$$d/foo.info' + with `$$dir/make.info' in install-info invocation (oops). + + * vpath.c (construct_vpath_list): Only set LASTPATH set PATH when + we do not unlink and free PATH. + + * file.c (print_file_data_base): Fix inverted calculation for + average files per hash bucket. + + * read.c (readline): When we see a NUL, give only a warning and + synthesize a newline to terminate the building line (used to + fatal). Move fgets call into the loop condition, and after the + loop test ferror (used to test !feof in the loop). + +Fri Dec 3 16:40:31 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in: Check for strerror in AC_HAVE_FUNCS. + +Thu Dec 2 15:37:50 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + Differentiate different flavors of missing makefile error msgs, + removing gratuitous `fopen: ' and giving caller for included makefiles. + * misc.c [! HAVE_STRERROR]: Define our own strerror here. + (perror_with_name, pfatal_with_name): Use strerror instead of + replicating its functionality. + * read.c (read_makefile): Return int instead of void. + (read_all_makefiles, read_makefile): Change callers to notice zero + return and give error msg. + +Thu Nov 11 11:47:36 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.69.1. + + * default.c: Put `-G $@' before $< in SCCS cmds. + +Wed Nov 10 06:06:14 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): After trying a variable defn, notice if + the line begins with a tab, and diagnose an error. + +Sun Nov 7 08:07:37 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.69. + +Wed Nov 3 06:54:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.10. + + * implicit.c (try_implicit_rule): Look for a normal rule before an + archive rule. + +Fri Oct 29 16:45:28 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * function.c (expand_function: `sort'): Double NWORDS when it + overflows, instead of adding five. + + * compatMakefile (clean): Remove loadavg. + +Wed Oct 27 17:58:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.9. + + * file.h (NEW_MTIME): Define new macro. + * main.c (main): Set time of NEW_FILES to NEW_MTIME, not to + current time returned from system. Removed variable NOW. + * remake.c (notice_finished_file): Use NEW_MTIME in place of + current time here too. + +Tue Oct 26 19:45:35 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.8. + + * remake.c (update_file_1): Don't clear MUST_MAKE when FILE has no + cmds and !DEPS_CHANGED unless also !NOEXIST. + +Mon Oct 25 15:25:21 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (parse_file_seq): When converting multi-word archive + refs, ignore a word beginning with a '('. + +Fri Oct 22 02:53:38 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in: Check for sys/timeb.h. + * make.h [HAVE_SYS_TIMEB_H]: Test this before including it. + +Thu Oct 21 16:48:17 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.7. + + * rule.c (convert_suffix_rule): New local TARGPERCENT. Set it to + TARGNAME+1 for "(%.o)", to TARGNAME for "%.?". Use it in place of + TARGNAME to initialize PERCENTS[0]. + +Mon Oct 18 06:49:35 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in: Use AC_HAVE_HEADERS(unistd.h) instead of AC_UNISTD_H. + Remove AC_USG; it is no longer used. + + * file.c (print_file): New function, broken out of + print_file_data_base. + (print_file_data_base): Call it. + * rule.c (print_rule): New function, broken out of + print_rule_data_base. + (print_rule_data_base): Call it. + +Thu Oct 14 14:54:03 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * default.c (install_default_suffix_rules): New function, broken + out of install_default_implicit_rules. + (install_default_implicit_rules): Move suffix rule code there. + * make.h: Declare install_default_suffix_rules. + * main.c (main): Call install_default_suffix_rules before reading + makefiles. Move convert_to_pattern call before + install_default_implicit_rules. + + * job.h (struct child): Make `pid' member type `pid_t' instead of + `int'. + + * compatMakefile (RANLIB): New variable, set by configure. + (glob/libglob.a): Pass RANLIB value down to submake. + + Fixes for SCO 3.2 "devsys 4.2" from pss@tfn.com (Peter Salvitti). + * make.h: Include before for SCO lossage. + * job.c [! getdtablesize] [! HAVE_GETDTABLESIZE]: If NOFILE is not + defined but NOFILES_MAX is, define it to be that. + +Mon Oct 11 19:47:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * GNUmakefile (make-$(version).tar): Depend on acconfig.h, so it + is distributed. + +Sun Oct 3 15:15:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * default.c (default_terminal_rules): Add `-G $@' to SCCS get cmds. + +Tue Sep 28 14:18:20 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Add ^ to SH_CHARS; it + is another symbol for | in some shells. + * main.c (main): Add it to CMD_DEFS quoting list as well. + +Mon Sep 20 18:05:24 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Remove '=' from + SH_CHARS. Only punt on '=' if it is unquoted in a word before the + first word without an unquoted '='. + + * main.c (define_makeflags): Set v_export for MAKEFLAGS. + +Fri Sep 17 00:37:18 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * remake.c (update_file_1): Use .DEFAULT cmds for phony targets. + + * make.h [_AIX && _POSIX_SOURCE]: Define POSIX. + + * commands.c (delete_child_targets): Don't delete phony files. + + * job.c (start_job_command): Set COMMANDS_RECURSE in FLAGS if we + see a `+' at the beginning of the command line. + +Thu Sep 9 17:57:14 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.6. + +Wed Sep 8 20:14:21 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (define_makeflags): Define MAKEFLAGS with o_file, not o_env. + +Mon Aug 30 12:31:58 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * expand.c (variable_expand): Fatal on an unterminated reference. + +Thu Aug 19 16:27:53 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.5. + + * variable.c (define_automatic_variables): Define new o_default + variable `MAKE_VERSION' from version_string and remote_description. + + * make.h (version_string, remote_description): Declare these here. + * main.c: Don't declare version_string. + (print_version): Don't declare remote_description. + +Wed Aug 18 15:01:24 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Free space pointed to by CONDITIONALS + before restoring the old pointer. + +Mon Aug 16 17:33:36 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile ($(objs)): Depend on config.h. + + * GNUmakefile (build.sh.in): Depend on compatMakefile. + + * configure.in: Touch stamp-config after AC_OUTPUT. + +Fri Aug 13 16:04:22 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.4. + +Thu Aug 12 17:18:57 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.h: Include instead of "config.h". + +Wed Aug 11 02:35:25 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (main): Make all variables interned from ENVP be v_export. + * variable.c (try_variable_definition): In v_default case, don't + check for an o_file variable that `getenv' finds. + + * job.c (reap_children): New local variable ANY_LOCAL; set it + while setting ANY_REMOTE. If !ANY_LOCAL, don't wait for local kids. + + * main.c (main): Don't call decode_env_switches on MFLAGS. DOC THIS. + + * function.c (expand_function): #if 0 out freeing of ENVP since it + is environ. + +Mon Aug 9 17:37:20 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.3. + + * remote-stub.c (remote_status): Set errno to ECHILD before return. + * job.c (reap_children): Scan the chain for remote children and + never call remote_status if there are none. + + * function.c (expand_function: `shell'): #if 0 out calling + target_environment; just set ENVP to environ instead. + + * job.c (reap_children): Check for negative return from + remote_status and fatal for it. + When blocking local child wait returns 0, then try a blocking call + to remote_status. + +Tue Aug 3 00:19:00 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (clean): Delete make.info* and make.dvi here. + (distclean): Not here. + + * dep.h (RM_*): Use #defines instead of enum to avoid lossage from + compilers that don't like enum values used as ints. + +Mon Aug 2 16:46:34 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (loadavg): Add $(LOADLIBES). + +Sun Aug 1 16:01:15 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.2. + + * compatMakefile (loadavg, check-loadavg): New targets. + (check): Depend on check-loadavg. + + * compatMakefile (glob/libglob.a): Depend on config.h. + + * misc.c (log_access): Write to stderr instead of stdout. + +Fri Jul 30 00:07:02 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68.1. + +Thu Jul 29 23:26:40 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (SYS_SIGLIST_DECLARED): In test program include + #ifdef HAVE_UNISTD_H. + + * compatMakefile (.PHONY): Put after `all' et al. + + * configure.in: Add AC_IRIX_SUN. + +Wed Jul 28 17:41:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.68. + +Mon Jul 26 14:36:49 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.8. + +Sun Jul 25 22:09:08 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.7. + + * compatMakefile ($(infodir)/make.info): Don't use $(instname). + Run install-info script if present. + +Fri Jul 23 16:03:50 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.h [STAT_MACROS_BROKEN]: Test this instead of [uts]. + + * configure.in: Add AC_STAT_MACROS_BROKEN. + +Wed Jul 14 18:48:11 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.6. + + * read.c (read_makefile): Recognize directive `-include', like + `include' but sets RM_DONTCARE flag. + + * variable.c (target_environment): If FILE is nil, use + current_variable_set_list in place of FILE->variables. + * function.c (expand_function: `shell'): Get an environment for + the child from target_environment instead of using environ. + + * dep.h: Declare read_all_makefiles here. + (RM_*): Define new enum constants. + * read.c (read_makefile): Second arg is FLAGS instead of TYPE. + Treat it as a bit mask containing RM_*. + (read_all_makefiles): For default makefiles, set D->changed to + RM_DONTCARE instead of 1. + * main.c: Don't declare read_all_makefiles here. + (main): Check `changed' member of read_makefiles elts for RM_* + flags instead of specific integer values. + +Mon Jul 12 22:42:17 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.h [sequent && i386]: #undef POSIX. From trost@cse.ogi.edu. + +Thu Jul 8 19:51:23 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * vpath.c (construct_vpath_list): If ELEM is zero 0, free PATTERN + as well as VPATH. + (build_vpath_lists): Empty `vpaths' around construct_vpath_list + call for $(VPATH). Expand $(strip $(VPATH)), not just $(VPATH). + + * rule.c (convert_suffix_rule): Use alloca instead of xmalloc for + PERCENTS, whose storage is not consumed by create_pattern_rule. + + * make.h [__mips && _SYSTYPE_SVR3]: #undef POSIX. + +Wed Jun 30 18:11:40 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.5. + + * rule.c (max_pattern_targets): New variable. + (count_implicit_rule_limits): Compute its value. + * rule.h: Declare it. + * implicit.c (pattern_search): Make TRYRULES max_target_patterns + times bigger. Move adding new TRYRULES elt inside the inner + targets loop, so each matching target gets its own elt in MATCHES + and CHECKED_LASTSLASH. + + * file.c (remove_intermediates): If SIG!=0 say `intermediate file' + instead of just `file' in error msg. + +Fri Jun 25 14:55:15 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv): Turn off + --warn-undefined-variables around expansion of SHELL and IFS. + * read.c (tilde_expand): Likewise for HOME. + (read_all_makefiles): Likewise for MAKEFILES. + * vpath.c (build_vpath_lists): Likewise for VPATH. + + * main.c (warn_undefined_variables_flag): New flag variable. + (switches): Add --warn-undefined-variables. + * make.h (warn_undefined_variables_flag): Declare it. + * expand.c (warn_undefined): New function. + (reference_variable): Call it if the variable is undefined. + (variable_expand): In substitution ref, call warn_undefined if the + variable is undefined. + + * default.c (default_pattern_rules): Add `%.c: %.w %.ch' and + `%.tex: %.w %.ch' rules. + (default_suffix_rules: .w.c, .w.tex): Pass three args: $< - $@. + (default_suffixes): Add `.ch'. + +Mon Jun 21 17:55:39 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * default.c (default_suffixes): Replace `.cweb' with `.w'. + (default_suffix_rules): Rename `.cweb.c' and `.cweb.tex' to `.w.c' + and `.w.tex'. + +Fri Jun 11 14:42:09 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile ($(bindir)/$(instname)): Add missing backslash. + +Thu Jun 10 18:14:08 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.4. + + * read.c (multi_glob): Don't free OLD and OLD->name in the + FOUND!=0 fork. Use new block-local variable F instead of + clobbering OLD. + + * ar.c (glob_pattern_p): New function, snarfed from glob/glob.c. + (ar_glob): Call it; return nil immediately if MEMBER_PATTERN + contains no metacharacters. + +Wed Jun 9 16:25:35 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * ar.c (ar_glob{_match,_alphacompare}): New function. + + * dep.h [! NO_ARCHIVES]: Declare it. + * read.c (multi_glob) [! NO_ARCHIVES]: Use it on archive member elts. + + * read.c (read_makefile): Pass flag (1) to parse_file_seq, not to + multi_glob (which doesn't take a 3rd arg). + * rule.c (install_pattern_rule): Likewise. + * default.c (set_default_suffixes): Here too. + * function.c (string_glob): Don't pass gratuitous arg to multi_glob. + + * read.c (parse_file_seq) [! NO_ARCHIVES]: Add post-processing + loop to translate archive refs "lib(a b)" into "lib(a) lib(b)". + +Mon Jun 7 19:26:51 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (installdirs): Actually pass directory names. + ($(bindir)/$(instname)): Test chgrp&&chmod exit status with `if'; + if it fails, echo a warning msg, but don't make the rule fail. + + * read.c (tilde_expand): New function, broken out of tilde_expand. + (multi_glob): Call it. + (construct_include_path): Expand ~ in directory names. + * dep.h: Declare tilde_expand. + * main.c (enter_command_line_file): Expand ~ at the start of NAME. + (main): Expand ~ in -C args. + * read.c (read_makefile): Expand ~ in FILENAME unless TYPE==2. + +Fri Jun 4 13:34:47 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (decode_env_switches): Use xmalloc instead of alloca for ARGS. + + * main.c (main): Put result of alloca in temporary variable with + simple assignment, to make SGI compiler happy. + +Thu Jun 3 20:15:46 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.3. + + * main.c (main): Before re-execing, remove intermediate files, and + print the data base under -p. Sexier debugging message. + + * implicit.c (pattern_search): Allocate an extra copy of the name + of a winning intermediate file when putting it in FOUND_FILES. + +Wed Jun 2 16:38:08 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Pass flag (1) to parse_file_seq, not to + multi_glob (which doesn't take a 3rd arg). + + * dir.c (dir_contents_file_exists_p): When reading dirents, ignore + chars within D_NAMLEN that are NULs. + + * main.c (decode_switches): Don't savestring ARGV[0] to put it + into `other_args'. + For string switch, don't savestring `optarg'. + (main): Don't free elts of makefiles->list that are "-". + Use alloca'd rather than savestring'd storage for elts of + makefiles->list that are temporary file names. + * read.c (read_all_makefiles): Don't free *MAKEFILES. + * file.c (enter_file): Don't strip `./'s. + * main.c (enter_command_line_file): New function. + (main): Use it in place of enter_file for command-line goals from + other_files, and for old_files and new_files. + +Mon May 31 18:41:40 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.2. + + * compatMakefile (.SUFFIXES): Add .info. + ($(infodir)/$(instname).info): Find make.info* in cwd if there, + else in $srcdir. Use basename to remove dir name from installed name. + +Thu May 27 17:35:02 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * implicit.c (pattern_search): When interning FOUND_FILES, try + lookup_file first; if found, free the storage for our copy of the name. + +Wed May 26 14:31:20 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67.1. + + * main.c (decode_switches): In usage msg, write `--switch=ARG' or + `--switch[=OPTARG]' rather than `--switch ARG' or `--switch [ARG]'. + +Mon May 24 16:17:31 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * rule.c (convert_suffix_rule): New function. + (convert_to_pattern): Use it instead of doing all the work here + several times. + For target suffix `.a', generate both the archive magic rule and + the normal rule. + + * compatMakefile (distclean): Remove stamp-config. + +Sat May 22 16:15:18 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.67. + + * file.c (remove_intermediates): Don't write extra space after `rm'. + + * main.c (struct command_switch.type): Remove `usage_and_exit'. + (print_usage_flag): New variable. + (switches: --help): Make type `flag', to set print_usage_flag. + (init_switches): Remove `usage_and_exit' case. + (decode_switches): Likewise. + (decode_switches): Print usage if print_usage_flag is set. + When printing usage, die with status of BAD. + (main): Die with 0 if print_version_flag. + +Fri May 21 16:09:28 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.66. + +Wed May 19 21:30:44 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (installdirs): New target. + (install): Depend on it. + +Sun May 16 20:15:07 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.65.2. + +Fri May 14 16:40:09 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * vpath.c (construct_vpath_list): In removal loop for DIRPATH==0, + set LASTPATH to PATH, not NEXT. + + * dir.c (read_dirstream): Break out of loop after incrementing + DS->buckets such that it reaches DIRFILE_BUCKETS; avoid trying to + dereference DS->contents->files[DIRFILE_BUCKETS]. + + * read.c (read_makefile): Clear no_targets after reading a + targetful rule line. + + * main.c (main): If print_version_flag is set, exit after printing + the version. + (switches): Change --version docstring to say it exits. + + * make.h [butterfly]: #undef POSIX. + +Wed May 12 15:20:21 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.65.1. + + * arscan.c (ar_scan) [! AIAMAG]: Don't declare LONG_NAME. + [AIAMAG]: Pass TRUNCATE flag arg to (*FUNCTION), always zero. + + * function.c (handle_function): Use fatal instead of + makefile_fatal when reading_filename is nil. + + * configure.in: Add AC_GETGROUPS_T. + * job.c (search_path): Use GETGROUPS_T in place of gid_t. + +Sun May 9 15:41:25 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.65. + +Fri May 7 18:34:56 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * function.c (handle_function): Fatal for unmatched paren. + +Thu May 6 16:13:41 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.64.3. + + * commands.c (handling_fatal_signal): New variable. + (fatal_error_signal): Set it. + * job.c (reap_children): Avoid nonreentrant operations if that is set. + * make.h: Declare handling_fatal_signal. + + * expand.c (reference_variable): New function, snippet of code + broken out of simple-reference case of variable_expand. + (variable_expand): Use it for simple refs. + (variable_expand): When checking for a computed variable name, + notice a colon that comes before the final CLOSEPAREN. Expand + only up to the colon, and then replace the pending text with a + copy containing the expanded name and fall through to subst ref + handling. + (variable_expand): Don't bother expanding the name if a colon + appears before the first $. + (expand_argument): Use alloca instead of savestring. + (variable_expand): For subst ref, expand both sides of = before + passing to [pat]subst_expand. Use find_percent instead of lindex + to check the lhs for a %. + +Wed May 5 14:45:52 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.64.2. + +Mon May 3 17:00:32 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * arscan.c (ar_name_equal) [AIAMAG]: Abort if TRUNCATED is nonzero. + + * read.c (read_makefile): Pass extra arg of 1 to parse_file_seq, + not to multi_glob. + +Thu Apr 29 19:47:33 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.64.1. + + * arscan.c (ar_scan): New local flag var LONG_NAME. Set it when + we read the member name in any of the fashions that allow it to be + arbitrarily long. Pass its negation to FUNCTION. + (describe_member): Take TRUNCATED from ar_scan and print it. + (ar_name_equal): Take new arg TRUNCATED; if nonzero, compare only + the first sizeof (struct ar_hdr.ar_name) chars. + (ar_member_pos): Take TRUNCATED from ar_scan, pass to ar_name_equal. + * ar.c (ar_member_date_1): Likewise. + +Wed Apr 28 21:18:22 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (reap_children): Before calling start_job_command to start + the next command line, reset C->remote by calling start_remote_job_p. + +Mon Apr 26 15:56:15 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * arscan.c (ar_scan): New local var NAMEMAP. + In loop, rename NAME to NAMEBUF; new var NAME is a pointer; new + flag IS_NAMEMAP. When extracting the member name, always put a + null at its end first. If the name is "//" or "/ARFILENAMES", set + IS_NAMEMAP. If we have already read in NAMEMAP, and NAME looks + like " /N", get full name from NAMEMAP+N. + Else if NAME looks like "#1/N", read N chars from the + elt data to be the full name. At end of loop, if IS_NAMEMAP, read + the elt's data into alloca'd NAMEMAP. + (ar_name_equal): #if 0 truncating code. + + * make.h: Don't declare vfork at all. It returns int anyway, + unless declared it; and we conflicted with some systems. + + * main.c (define_makeflags): If FLAGSTRING[1] is '-', define + MAKEFLAGS to all of FLAGSTRING, not &FLAGSTRING[1]. Don't want to + define it to something like "-no-print-directory". + Use %g format instead of %f for floating-valued things. + +Thu Apr 22 18:40:58 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * GNUmakefile (Makefile.in): Use a substitution ref on nolib-deps + to change remote-%.dep to remote-stub.dep. + +Wed Apr 21 15:17:54 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.64. + +Fri Apr 16 14:22:22 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (install): Remove - prefix from chgrp+chmod. + + * Version 3.63.8. + +Thu Apr 15 18:24:07 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * acconfig.h: New file; contains "#undef SCCS_GET" for autoheader. + * configure.in: If /usr/sccs/get exists, define SCCS_GET to that, + else to "get". + * default.c (default_variables): Set GET to macro SCCS_GET. + + * read.c (parse_file_seq): Take extra arg STRIP; strip `./' only + if nonzero. I hope this is the last time this argument is added + or removed. + (read_makefile): Pass it 1 when parsing include file names. + Pass it 1 when parsing target file names. + Pass it 1 when parsing static pattern target pattern names. + * rule.c (install_pattern_rule): Pass it 1 when parsing rule deps. + * default.c (set_default_suffixes): Pass it 1 when parsing + default_suffixes. + * function.c (string_glob): Pass it 0 here. + +Wed Apr 14 11:32:05 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * misc.c (log_access): New function. + ({init,user,make,child}_access): Call it. + (child_access): Abort if !access_inited. + + * main.c (switches: --no-print-directory): Use 1 instead of -1 for + single-letter option. + (init_switches, decode_switches, define_makeflags): An option with + no single-letter version is no longer indicated by a value of -1; + instead a value that is !isalnum. + (init_switches): Don't put such switches into the string, only + into the long_option table. + + * make.h [!NSIG] [!_NSIG]: #define NSIG 32. + + * job.c [HAVE_WAITPID]: Remove #undef HAVE_UNION_WAIT. AIX's + bsdcc defined WIF* to use union wait. + + * main.c (struct command_switch): Change member `c' to type int. + (switches): Make const. + (decode_switches): Use `const struct command_switch *'. + (define_makeflags): Likewise. + + * default.c (default_suffix_rules): Add `-o $@' to makeinfo rules. + +Mon Apr 12 12:30:04 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.63.7. + + * configure.in (AC_HAVE_HEADERS): Check for string.h and memory.h. + Removed AC_MEMORY_H. + * make.h [USG, NeXT]: Don't test these. + [HAVE_STRING_H]: Test this to include string.h and define ANSI_STRING. + [HAVE_MEMORY_H]: Test this instead of NEED_MEMORY_H. + [! ANSI_STRING]: Put decls of bcopy et al here. + [sparc]: Don't test this for alloca.h; HAVE_ALLOCA_H is sufficient. + [HAVE_SIGSETMASK]: Test this rather than USG. + [__GNU_LIBRARY__ || POSIX]: Don't #include again. + * main.c (main): Handle SIGCHLD if defined, and SIGCLD if defined. + It doesn't hurt to do both if they are both defined, and testing + USG is useless. + * dir.c: Rationalize directory header conditionals. + * arscan.c [HAVE_FCNTL_H]: Test this rather than USG || POSIX. + + * default.c (default_suffixes): Add `.txinfo'. + (default_suffix_rules): Add `.txinfo.info' and `.txinfo.dvi' rules. + + * variable.c (try_variable_definition): Replace RECURSIVE flag + with enum FLAVOR, which can be simple, recursive, or append. + Recognize += as append flavor. Set new variable VALUE in a switch + on FLAVOR. For append flavor, prepend the variable's old value. + If the variable was previously defined recursive, set FLAVOR to + recursive; if it was defined simple, expand the new value before + appending it to the old value. Pass RECURSIVE flag to + define_variable iff FLAVOR == recursive. + + * variable.c (try_variable_definition): Use alloca and bcopy for + NAME, instead of savestring. Might as well use stack storage + since we free it immediately anyway. + +Thu Apr 8 18:04:43 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (start_waiting_jobs): Move decl of JOB outside of loop. + + * main.c (define_makeflags): Rename `struct flag' member `switch' + to `cs', which is not a reserved word. + +Wed Apr 7 15:30:51 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (new_job): Call start_waiting_jobs first thing. + (start_waiting_job): Changed return type from void to int. + Return 0 when putting the child on the waiting_jobs chain. + (start_waiting_jobs): Don't check load and job_slots here. + Always take a job off the chain and call start_waiting_job on it; + give up and return when start_waiting_job returns zero. + + * main.c (define_makeflags: struct flag): Change member `char c' to + `struct command_switch *switch'. + (ADD_FLAG): Set that to CS instead of CS->c. + If CS->c is -1, increment FLAGSLEN for the long name. + When writing out FLAGS, handle FLAGS->switch->c == -1 and write + the long name instead. + + * compatMakefile (stamp-config): New target of old config.h rule. + Touch stamp-config after running config.status. + (config.h): Just depend on stamp-config, and have empty commands. + +Mon Apr 5 20:14:02 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c [HAVE_WAITPID]: #undef HAVE_UNION_WAIT. + + * configure.in (AC_HAVE_FUNCS): Check for psignal. + +Fri Apr 2 17:15:46 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (long_option_aliases): Remove "new"; it is already an + unambiguous prefix of "new-file". + +Sun Mar 28 16:57:17 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.63.6. + +Wed Mar 24 14:26:19 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * vpath.c (selective_vpath_search): When adding the + name-within-directory at the end of NAME, and we don't add a + slash, don't copy FILENAME in one char too far into NAME. + + * variable.c (define_automatic_variables): Find default_shell's + length with strlen, not numerology. + +Wed Mar 17 20:02:27 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (define_makeflags): Add the elts of a string option in + reverse order, so they come out right when reversed again. + +Fri Mar 12 15:38:45 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (make.info): Use `-o make.info'. + +Thu Mar 11 14:13:00 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (REMOTE): Set to @REMOTE@; change comments to + reflect new use. + (objs): Replace remote.o with remote-$(REMOTE).o. + (srcs): Replace remote.c with remote-$(REMOTE).c. + (remote.o): Rule removed. + + * configure.in (REMOTE): Subst this in Makefile et al; default "stub". + Use AC_WITH to grok --with-customs arg to set REMOTE=cstms. + * GNUmakefile (build.sh.in): Filter out remote-% from objs list. + * build.template (REMOTE): New var; set to @REMOTE@. + (objs): Add remote-${REMOTE}.o. + +Wed Mar 10 15:12:24 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.63.5. + + * implicit.c (pattern_search): Fix "dependent"->"dependency" in + "Rejecting impossible" -d msg. + + * file.c (file_hash_enter): New local vars {OLD,NEW}BUCKET. Store + mod'd values there; never mod {OLD,NEW}HASH. + +Mon Mar 8 13:32:48 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * remake.c [eta10]: Include instead of . + + * compatMakefile (VPATH): Set this to @srcdir@. + (srcdir): Set this to $(VPATH). + + * main.c (main): New local var DIRECTORY_BEFORE_CHDIR. Save in it + a copy of CURRENT_DIRECTORY after the first getcwd. Use it + instead of CURRENT_DIRECTORY when chdir'ing back before re-execing. + + * remake.c (notice_finished_file): Pass missing SEARCH arg to f_mtime. + + * read.c (read_makefile): Remove extraneous arg to parse_file_seq. + +Mon Feb 22 14:19:38 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile ($(infodir)/$(instname).info): Use , instead of / + as the sed delimiter char. + +Sun Feb 21 14:11:04 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.63.4. + + * rule.h (struct rule): Removed `subdir' member. + * rule.c (new_pattern_rule): No need to clear it. + (count_implicit_rule_limits): Set the `changed' flag in each dep + that refers to a nonexistent directory. No longer set rule-global + `subdir' flag with that information. + (print_rule_data_base): Don't record info on `subdir' flags. + + * implicit.c (pattern_search): Check the DEP->changed flag rather + than the (now gone) RULE->subdir flag. Also test CHECK_LASTSLASH; + if it is set, the file might exist even though the DEP->changed + flag is set. + + * rule.c (count_implicit_rule_limits): Pass "", not ".", as file + name arg to dir_file_exists_p to check for existence of directory. + + * implicit.c (pattern_search): Inside dep-finding loop, set + CHECK_LASTSLASH from the value recorded in CHECKED_LASTSLASH[I], + rather than computing it anew. + + * commands.c (set_file_variables): Must alloca space for PERCENT + and copy it, to avoid leaving the trailing `)' in the value. + + * misc.c (remove_comments): Fixed backslash-checking loop + condition to allow it to look at the first char on the line. + P2 >= LINE, not P2 > LINE. + + * compatMakefile ($(bindir)/$(instname)): Before moving $@.new to + $@, rm $@.old and mv $@ to $@.old. + + * variable.c (try_variable_definition): Take new args FILENAME and + LINENO. Fatal if the variable name is empty. + * read.c (read_makefile): Change callers. + * main.c (main): Likewise. + + * compatMakefile (group): Define to @KMEM_GROUP@, autoconf magic + that configure will replace with the group owning /dev/kmem. + +Mon Feb 8 14:26:43 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * vpath.c (vpath_search): Take second arg MTIME_PTR, pass thru to + selective_vpath_search. + (selective_vpath_search): Take second arg MTIME_PTR. + If the dir cache thinks a file exists, stat it to make sure, and + put the modtime in *MTIME_PTR. + * remake.c (library_search): Take second arg MTIME_PTR. + When we find a match, record its mtime there. + Pass MTIME_PTR through to vpath_search to do same. + (f_mtime): Pass &MTIME as new 2nd arg to {vpath,library}_search; + store it in FILE->last_mtime if set nonzero. + * implicit.c (pattern_search): Pass nil 2nd arg to vpath_search. + + * compatMakefile (remote.o): Prepend `$(srcdir)/' to `remote-*.c', + so globbing looks somewhere it will find things. + + * compatMakefile ($(infodir)/$(instname).info): Install `make.info*' + not `$(srcdir)/make.info*'; no need to use basename. + +Fri Feb 5 12:52:43 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.63.3. + + * compatMakefile (install): Add missing ;\s. + + Make -, @, and + prefixes on a pre-expanded command line affect + all lines in the expansion, not just the first. + * commands.h (struct commands): Replace `lines_recurse' member + with `lines_flags'. + (COMMANDS_{RECURSE,SILENT,NOERROR}): New macros, bits to set in + that flag byte. + * commands.c (chop_commands): Set `lines_flags' instead of + `lines_recurse'. Record not only + but also @ and - prefixes. + * remake.c (notice_finished_file): Check the COMMANDS_RECURSE bit + in FILE->cmds->lines_flags, rather than FILE->cmds->lines_recurse. + * job.c (start_job_command): Replaced RECURSIVE and NOPRINT local + var with FLAGS; initialize it to the appropriate `lines_flags' byte. + Set CHILD->noerror if the COMMANDS_NOERROR bit is set in FLAGS. + Set the COMMANDS_SILENT bit in FLAGS for a @ prefix. + + * remake.c (update_goal_chain): Set G->file to its prev after + checking for G being finished, since that check needs to examine + G->file. + + * configure.in (union wait check) [HAVE_WAITPID]: Try using + waitpid with a `union wait' STATUS arg. If waitpid and union wait + don't work together, we should not use union wait. + + * Version 3.63.2. + + * remake.c (update_goal_chain): When G->file->updated, move + G->file to its prev. We aren't finished until G->file is nil. + +Thu Feb 4 12:53:04 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (starting_directory): New global variable. + (main): Set it to cwd after doing -Cs. + (log_working_directory): Use it, rather than computing each time. + * make.h: Declare it. + + * compatMakefile (SHELL): Define to /bin/sh for losing Unix makes. + + * main.c (decode_env_switches): Allocate (1 + LEN + 1) words for + ARGV, rather than LEN words plus one byte. + +Wed Feb 3 18:13:52 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile ($(bindir)/$(instname)): Put - before + install_setgid command line, so its failure won't be an error. + (infodir): New variable. + (install): Depend on $(infodir)/$(instname).info. + ($(infodir)/$(instname).info): New target. + + * read.c (read_makefile): If FILENAMES is nil when we see a line + starting with a tab, don't treat it as a command. Just fall + through, rather than giving an error. + + * read.c (read_makefile): If the NO_TARGETS flag is set when we see a + command line, don't clear it before continuing. We want + subsequent command lines to be ignored as well. + + * job.c (new_job): Before expanding each command line, collapse + backslash-newline combinations that are inside var or fn references. + +Mon Feb 1 16:00:13 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (exec_prefix): Default to $(prefix), not /usr/local. + + * compatMakefile (make.info): Pass -I$(srcdir) to makeinfo. + + * job.c [POSIX] (unblock_sigs): Made global. + [!POSIX] (unblock_sigs): Move defns to job.h. + * job.h [POSIX] (unblock_sigs): Declare. + +Sun Jan 31 19:11:05 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * read.c (read_makefile): In vpath parsing, after finding the + pattern token, take entire rest of line as the search path, not + just the next token. + + * compatMakefile (remote.o): Depend on remote-*.c. + +Thu Jan 28 16:40:29 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * commands.c (set_file_variables): Don't define any F or D versions. + * variable.c (define_automatic_variables): Define them here as + recursively-expanded variables that use the dir and notdir funcs. + + * variable.c (target_environment): In v_default case, don't export + o_default or o_automatic variables. + + * configure.in (union wait check): Remove ` and ' inside C code; + they confuse the shell script. + +Mon Jan 25 13:10:42 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.63.1. + + * vpath.c (construct_vpath_list): When skipping further processing + of an elt that is ".", don't also skip the code that pushes P past + the next separator. + + * compatMakefile (distclean): Don't remove make-*. + + * configure.in (HAVE_UNION_WAIT): Try to use WEXITSTATUS if it's + defined. If one cannot use WEXITSTATUS with a `union wait' + argument, we don't want to believe the system has `union wait' at all. + + * remake.c (update_file): Do nothing to print "up to date" msgs. + (update_goal_chain): Do it here instead. + Use the `changed' flag of each goal's `struct dep' to keep track + of whether files_remade (now commands_started) changed around a + call to update_file for that goal. + When a goal is finished, and its file's update_status is zero (i.e., + success or nothing done), test the `changed' flag and give an "up + to date" msg iff it is clear. + * make.h (files_remade): Renamed to commands_started. + * remake.c: Changed defn. + (update_goal_chain): Changed uses. + * job.c (start_job_command): Increment commands_started here. + (reap_children): Not here. + + * remake.c (update_goal_chain): Don't do anything with files' + `prev' members. update_file now completely handles this. + + * variable.c (target_environment): Don't expand recursive + variables if they came from the environment. + + * main.c (define_makeflags): For flags with omitted optional args, + store {"", 0} with ADD_FLAG. When constructing FLAGSTRING, a flag + so stored cannot have more flags appended to the same word. + +Fri Jan 22 14:46:16 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * variable.c (print_variable_set): In vars/bucket calculation, + don't spuriously multiply by 100. + + * Version 3.63. + + * job.c [!HAVE_UNION_WAIT] (WTERMSIG, WCOREDUMP, WEXITSTATUS): + Don't define if already defined. + + * remake.c (update_file): Don't keep track of the command_state before + calling update_file_1. Remove local variable COMMANDS_FINISHED, + and don't test it to decide to print the "is up to date" msg. + Testing for files_remade having changed should always be sufficient. + The old method lost when we are called in the goal chain run on a + makefile, because the makefile's command_state is already + `cs_finished' from the makefile chain run. + + * misc.c [HAVE_SETRE[GU]ID]: Test these to decl setre[gu]id. + + * configure.in: Rewrote wait checking. + Use AC_HAVE_HEADERS to check for . + Use AC_HAVE_FUNCS to check for waitpid and wait3. + Use a compile check to test just for `union wait'. + * job.c: Rewrote conditionals accordingly. + [HAVE_WAITPID]: Test this only to define WAIT_NOHANG. + [HAVE_WAIT3]: Likewise. + [HAVE_UNION_WAIT]: Test this to define WAIT_T and W*. + + * configure.in: Set CFLAGS and LDFLAGS before all checks. + + * dir.c: Add static forward decls of {open,read}_dirstream. + +Thu Jan 21 17:18:00 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.31. + + * job.c [NGROUPS_MAX && NGROUPS_MAX==0]: #undef NGROUPS_MAX. + + * compatMakefile (CFLAGS, LDFLAGS): Set to @CFLAGS@/@LDFLAGS@. + * build.template (CFLAGS, LDFLAGS): Same here. + * configure.in: AC_SUBST(CFLAGS) and LDFLAGS. + Set them to -g if not defined in the environment. + + * remake.c (library_search): Use LIBNAME consistently, setting it + only once, to be the passed name sans `-l'. + Pass new var FILE to be modified by vpath_search. + +Mon Jan 18 14:53:54 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.30. + + * job.c (start_waiting_jobs): Return when job_slots_used is equal to + job_slots. + + * configure.in: Add AC_CONST for the sake of getopt. + + * read.c (read_makefile): Continue after parsing `override' + directive, rather than falling through to lossage. + Check for EOL or blank after "override define". + + * compatMakefile (.c.o, remote.o): Put $(CFLAGS) after other switches. + +Fri Jan 15 12:52:52 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.29. + + * main.c (define_makeflags): After writing everything into + FLAGSTRING, only back up two chars if [-1] is a dash, meaning we + just wrote " -". Always terminate the string at *P. + + * remake.c (library_search): When constructing names in std dirs, + use &(*LIB)[2] for the stem, not LIBNAME (which points at the + buffer we are writing into!). + +Thu Jan 14 13:50:06 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Set IN_IGNORED_DEFINE for "override + define" when IGNORING is true. + + * compatMakefile (distclean): Remove config.status and build.sh. + +Wed Jan 13 16:01:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.28. + + * misc.c (xmalloc, xrealloc): Cast result of malloc/realloc to + (char *). + + * arscan.c (ar_scan) [AIAMAG]: Cast read arg to (char *). + + * variable.c (define_automatic_variables): Override SHELL value for + origin o_env_override as well as o_env. + + * GNUmakefile (build.sh.in): Don't replace %globobjs%. Instead, + add the names of the glob objects (w/subdir) to %objs%. + * build.template (globobjs): Removed. + Take basename of $objs before linking. + +Tue Jan 12 12:31:06 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.27. + + * configure.in (AC_OUTPUT): Also edit build.sh. + * build.template: New file. + * GNUmakefile (build.sh.in): New rule to create it from build.template. + (make-$(version).tar.Z): Depend on build.sh.in. + + * main.c (die): Call print_data_base if -p. + (main): Don't call it here. + + * compatMakefile (defines): Add @DEFS@. configure should turn this + into -DHAVE_CONFIG_H. + +Mon Jan 11 14:39:23 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.26. + + * misc.c (init_access): Surround with #ifdef GETLOADAVG_PRIVILEGED. + ({make,user,child}_access) [! GETLOADAVG_PRIVILEGED]: Make no-op. + * compatMakefile (install_setgid): New var, set by configure. + (install): Install setgid $(group) only if $(install_setgid) is true. + +Fri Jan 8 15:31:55 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (load_too_high): If getloadavg fails with errno==0, give a + message saying that load limits are not supported. + + * vpath.c (construct_vpath_list): Rewrote path deletion code to + not try to use PATH's next link after freeing PATH. + + * main.c (define_makeflags): Rewritten; now handles string-valued + option, and has no arbitrary limits. + (switches): Set `toenv' flag for -I and -v. + + * main.c (decode_env_switches): Cast return value of alloca to char *. + + * misc.c (child_access) [HAVE_SETREUID, HAVE_SETREGID]: Use + setre[gu]id in place of set[gu]id. + +Wed Jan 6 15:06:12 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (main): Define MAKEOVERRIDES, MAKE, and MAKE_COMMAND with + origin o_default. + + * make.h [POSIX]: Don't test this to use ANSI_STRING. + Testing STDC_HEADERS should be sufficient. + + * job.h: Declare start_waiting_jobs. + + * read.c (read_makefile): Add missing parens in if stmt that find + conditional directives. + + * main.c (main): Declare init_dir. + * implicit.c (pattern_search): Always use two % specs in a + DEBUGP2, and always pass two non-nil args. + Cast field width args to int. + Add missing parens in !RULE->subdir if stmt. + * function.c (expand_function, patsubst_expand): Add parens around + assignments inside `while' stmts. + * commands.c (print_commands): Cast field width args to int. + + * read.c (do_define): Cast return value of alloca to (char *). + + * main.c (init_switches): New function, broken out of decode_switches. + (decode_switches): Take new arg ENV. If set, ignore non-option + args; print no error msgs; ignore options with clear `env' flags. + (decode_env_switches): Rewritten to chop envar value into words + and pass them to decode_switches. + (switches): Set `env' flag for -I and -v. + + * dir.c (init_dir): Cast free to __glob_closedir_hook's type. + +Tue Jan 5 14:52:15 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.25. + + * job.c [HAVE_SYS_WAIT || !USG]: Don't #include and + . interacts badly with , and + we don't need these anyway. + + * configure.in (AC_HAVE_FUNCS): Check for setre[gu]id. + * misc.c ({user,make}_access): Test #ifndef HAVE_SETRE[GU]ID, not + #ifdef POSIX || USG. SunOS 4.1 is supposedly POSIX.1 compliant, + but its set[gu]id functions aren't; its setre[gu]id functions work. + + * misc.c ({user,make,child}_access): Give name of caller in error msgs. + + * job.c (load_too_high): Say "cannot enforce load limit" in error msg. + + * configure.in: Call AC_PROG_CC. + * compatMakefile (CC): Define to @CC@ (autoconf magic). + + * compatMakefile: Add .NOEXPORT magic target. + +Mon Jan 4 17:00:03 1993 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (print_version): Updated copyright to include 93. + +Thu Dec 31 12:26:15 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * make.h [_AIX]: Don't declare alloca. + +Tue Dec 29 13:45:13 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.24. + + * compatMakefile (objs): Add signame.o. + (srcs): Add signame.[ch]. + + * compatMakefile (srcs): Add config.h.in. + (remote.o): Add -I. before -I$(srcdir). + +Mon Dec 28 15:51:26 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.23. + + * read.c (readline): Fatal when LEN==0, indicating a line starting + with a NUL. + (readline): Take new arg LINENO, for use in error msg. + (read_makefile, do_define): Pass it. + + * compatMakefile (glob/libglob.a): Pass -DHAVE_CONFIG_H in CPPFLAGS. + (.c.o): Add -I. before -I$(srcdir). + +Wed Dec 23 12:12:04 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Accept and ignore a rule with no targets. + + * compatMakefile (ALLOCA_SRC): New variable. + (srcs): Include its value. + + * read.c (struct conditional): Renamed member `max_ignoring' to + `allocated'; added new member `seen_else'. + (conditional_line): Initialize seen_else flag when starting an `if...'; + set it when we see an `else'; fatal if set when we see `else'. + (read_makefile): Fatal "missing `endif'" if there are any pending + conditionals, not just if we are still ignoring. + +Tue Dec 22 15:36:28 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (manext): Set to 1, not l. + ($(mandir)/$(instname).$(manext)): Use $(srcdir) for make.man in cmds. + + * file.c (file_hash_enter): Don't call uniquize_deps here. + * read.c (record_files): Likewise. + * implicit.c (pattern_search): Likewise. + * commands.c (set_file_variables): Call it only here. + + * default.c (default_variables) [__convex__]: FC=fc. + + * variable.c (target_environment): Expand the values of recursively + expanded variables when putting them into the environment. + * expand.c (recursively_expand): Made global. + * make.h (recursively_expand): Declare it. + + * remake.c (check_dep): Set FILE->command_state to cs_deps_running + when a dep's command_state is cs_running or cs_deps_running. + + * read.c (read_makefile): Changed error msg for spurious cmds to + not say "first target". + +Sun Dec 20 17:56:09 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * configure.in: Do AC_CONFIG_HEADER right after AC_INIT. + * make.h (HAVE_CONFIG_H): #include "config.h", then #define this. + * compatMakefile (config.h, configure, config.h.in): New rules. + (defines): Removed @DEFS@. + +Thu Dec 17 16:11:40 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (realclean): Just depend on distclean; no cmds. + (distclean): Do what realclean did before; also remove Makefile and + config.h; don't remove configure. + (info, dvi): New targets; depend on make.{info,dvi}. + (doc): Removed target. + (MAKEINFO, TEXI2DVI): New vars. + (make.info, make.dvi): Use them instead of explicit cmds. + +Wed Dec 16 16:25:24 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in: Added fcntl.h to AC_HAVE_HEADERS. getloadavg cares. + +Wed Dec 9 15:21:01 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (long_option_aliases): Add --new-file alias for -W. + + * default.c (default_variables): Change all C++ to CXX and C++FLAGS + to CXXFLAGS. + + * read.c (do_define): Expand the variable name before using it. + + * main.c (main): Define variable "MAKE_COMMAND" to argv[0]; + define "MAKE=$(MAKE_COMMAND) $(MAKEOVERRIDES)" always. + + * remake.c (library_search): Search for libNAME.a in cwd; look in + vpath before looking in standard dirs, not after. + Changed order of std dirs to: /lib, /usr/lib, ${prefix}/lib. + +Mon Nov 23 14:57:34 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * default.c (default_pattern_rules, default_terminal_rules): Added + brackets around initializers. + + * variable.c (try_variable_definition): Don't check for LINE[0]=='\t'. + (try_variable_definition): Expand the name before defining the var. + + * job.c (init_siglist): Removed function. + Removed decl of `sys_siglist'. + * make.h [! HAVE_SYS_SIGLIST]: #include "signame.h". + [HAVE_SYS_SIGLIST && !SYS_SIGLIST_DECLARED]: Declare sys_siglist + only under these conditions. + * main.c (main): Don't declare init_siglist. + (main) [! HAVE_SYS_SIGLIST]: Call signame_init instead of init_siglist. + +Wed Nov 18 14:52:51 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (record_files): Don't try to append to FIRSTDEPS if it's + nil; instead just set it to MOREDEPS. + +Mon Nov 16 17:49:17 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * vpath.c (construct_vpath_list): Initialize P to DIRPATH before + loop that sets MAXELEM. + +Fri Nov 13 18:23:18 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.22. + +Thu Nov 12 15:45:31 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (start_job_command): Under -n, increment files_remade after + processing (i.e., printing) all command lines. + +Tue Nov 10 15:33:53 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * read.c (record_files): Append new deps if this rule has no + commands; prepend them to existing deps if this rule has no commands. + + * dir.c (open_dirstream): Return nil if DIR->contents->files is nil. + + * read.c (parse_file_seq): Removed last arg STRIP. Always strip `./'s. + (read_makefile): Changed callers. + * function.c (string_glob): Likewise. + * rule.c (install_pattern_rule): Likewise. + +Mon Nov 9 17:50:16 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * remake.c (files_remade): Made global. + (notice_finished_file): Don't increment files_remade here; this + function gets called in many situations where no remaking was in + fact done. + * job.c (reap_children): Do it here instead, when we know that + actual commands have been run for the file. + * make.h (files_remade): Declare it. + +Thu Nov 5 18:26:10 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * vpath.c (construct_vpath_list): Allow blanks as well as colons to + separate elts in the search path. + + * read.c (read_makefile): Don't fatal on extra tokens in `vpath'. + The search path can contain spaces now. + +Tue Nov 3 20:44:32 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (check): New target; no-op. + + * file.c (file_hash_enter): Mod OLDHASH by FILE_BUCKETS after + testing for OLDHASH==0 but before using the value. + (rename_file): Don't mod OLDHASH by FILE_BUCKETS before passing it + to file_hash_enter. + + * file.c (rename_file): Notice when OLDFILE->cmds came from + default.c, and don't try to print ->filename in that case. + +Sun Oct 25 01:48:23 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * remake.c (update_file): Don't process F->also_make here. + (notice_finished_file): Don't process FILE->also_make if no attempt + to update FILE was actually made. + Fixed to call f_mtime directly to refresh their modtimes. + +Sat Oct 24 22:08:59 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (find_percent): Don't increment P again after skipping + an escaped %. + + * expand.c (variable_expand): In call to patsubst_expand, don't + find `%'s ourselves; let that function do it. + + * read.c (read_makefile: record_waiting_files): Don't call + record_files if FILENAMES is nil. + (read_makefile): All alternatives in the parsing, except for rule + lines, fall through to the end of the loop. At the end of the + loop, do record_waiting_files so we notice later spurious cmds. + +Fri Oct 23 15:57:37 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * variable.c (define_automatic_variables): Free old value of SHELL + before replacing it. + +Thu Oct 15 18:57:56 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (.c.o): Add -I$(srcdir)/glob to flags. + + * dir.c (open_dirstream): Cast return value to __ptr_t. + + * default.c (default_variables: "GET") [_IBMR2]: Use USG defn. + + * make.h (MAXPATHLEN): Moved out of #ifndef POSIX. + (GET_PATH_MAX): Moved from #ifdef POSIX to #ifdef PATH_MAX #else. + Define as (get_path_max ()). + [! PATH_MAX] (NEED_GET_PATH_MAX): Define. + [! PATH_MAX] (get_path_max): Declare fn. + * misc.c [NEED_GET_PATH_MAX] (get_path_max): New function. + +Mon Oct 12 13:34:45 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.21. + + * job.c (sys_siglist): Only declare #ifndef SYS_SIGLIST_DECLARED. + * make.h [! HAVE_SYS_SIGLIST && HAVE__SYS_SIGLIST]: #define + SYS_SIGLIST_DECLARED. + + * dir.c (file_impossible): When initializing DIR->contents, set + DIR->contents->dirstream to nil. + + * compatMakefile (GLOB): Define new variable. + (objs): Use it, rather than glob/libglob.a explicitly. + + * read.c (parse_file_seq): When stripping "./", handle cases like + ".///foo" and "./////". + * file.c (lookup_file, enter_file): Likewise. + +Sun Oct 11 17:00:35 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * dir.c (struct dirstream, {open,read}_dirstream): New + data type and functions to read a directory sequentially. + (init_dir): New function to hook it into glob. + * main.c (main): Call init_dir. + + * compatMakefile (objs): Added glob/libglob.a. + * configure.in: Remove code to test for glob. + +Fri Oct 9 12:08:30 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (record_files): Generalized test for NAME pointing + somewhere into F->name. + + * variable.c (define_variable_in_set): Free old value when replacing. + + * read.c (do_define): Free the linebuffer before returning. + (record_files): When clearing .SUFFIXES deps, free their data. + (multi_glob): Free OLD and its data when replacing it with results + of glob run. + + * commands.c (set_file_variables): Use alloca in place of xmalloc + for temp space for $^, $?, et al. + + * dir.c (struct directory): New member `contents' replaces `files' + and `dirstream'. + (struct directory_contents): New type. + (directories_contents): New hash table. + (dir_struct_file_exists_p): Take a struct directory_contents. + (dir_file_exists_p): Pass it the `contents' member of the dir found. + (dir_struct_file_exists_p): Renamed to dir_contents_file_exists_p; + made static. Return 0 if DIR is nil (meaning it couldn't be stat'd). + (dir_file_exists_p, find_directory): Change all callers. + (file_impossible): Use DIR->contents, initializing it if nil. + (print_dir_data_base): Use DIR->contents, and print out device and + inode numbers with each directory. + + * Changes for performance win from John Gilmore : + * dir.c (DIRECTORY_BUCKETS): Increase to 199. + (DIRFILE_BUCKETS): Decrease to 107. + (find_directory): Allocate and zero a multiple of + sizeof (struct dirfile *), not of sizeof (struct dirfile). + (dir_struct_file_exists_p): New function, nearly all code from + dir_file_exists_p. + (dir_file_exists_p): Just call find_directory+dir_struct_file_exists_p. + * vpath.c (selective_vpath_search): Remove redundant + dir_file_exists_p call. + + * configure.in: Comment out glob check; always use our code. + +Fri Oct 2 19:41:20 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * make.h [! HAVE_SYS_SIGLIST && HAVE__SYS_SIGLIST]: #define + HAVE_SYS_SIGLIST; after doing #define sys_siglist _sys_siglist, we + do have it. + +Wed Sep 30 19:21:01 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (main): Don't do -w automatically if -s. + +Tue Sep 29 21:07:55 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (printed_version): Move variable inside print_version. + (print_version): Return immediately if printed_version is set. + (die): Don't test printed_version here. + (decode_switches): Under -v, do print_version before giving usage. + (DESCRIPTION_COLUMN): New macro. + (decode_switches): Use it when printing the usage message. + Leave at least two spaces between options and their descriptions. + +Fri Sep 25 13:12:42 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.20. + +Wed Sep 16 16:15:22 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * read.c (read_makefile): Save errno value from trying to open + FILENAME, and restore it before erring; otherwise we get the errno + value from the last elt of the search path. + +Tue Sep 15 15:12:47 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (long_option_aliases): Add --stop for -S. + + * read.c (word1eq): Do strncmp before dereferencing someplace that + may be out in space. + +Wed Sep 9 15:50:41 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * remake.c (notice_finished_file): If all the command lines were + recursive, don't do the touching. + + * job.c (start_job_command): Don't check for + here. + * commands.c (chop_commands): Do it here instead. + + * default.c (default_terminal_rules): Prepend + to cmds for RCS. + +Wed Sep 2 17:53:08 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (objs): Include $(ALLOCA). + + * make.h [CRAY]: Move #define signal bsdsignal to before #includes. + +Thu Aug 27 17:45:43 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * read.c (default_include_directories): Add INCLUDEDIR first. + * compatMakefile (includedir): Define. + (defines): Add -D for INCLUDEDIR="$(includedir)". + + * read.c (read_makefile): Grok multiple files in `include'; + globbing too. + + * remake.c (library_search): New function. + (library_file_mtime): Remove function. + (f_mtime): Use library_search instead of library_file_mtime. + * compatMakefile (libdir): Define. + (defines): Add -D for LIBDIR="$(libdir)". + * make.texinfo (Libraries/Search): Document change. + + * file.c (rename_file): Fix file_hash_enter call with missing arg. + +Wed Aug 26 17:10:46 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.19. + + * main.c (main): Set command_state to cs_finished for temp files + made for stdin makefiles. + + * main.c (decode_switches): Don't tell getopt to return non-option + args in order. + Ignore an argument of `-'. + +Thu Aug 20 13:36:04 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * job.c (start_job_command): If (touch_flag && !RECURSIVE), ignore + the command line and go to the next. + (notice_finished_file): Under -t, touch FILE. + * remake.c (remake_file): Don't touch it here. + +Wed Aug 19 16:06:09 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * function.c (pattern_matches): Use temporary for strlen (WORD) + instead of two function calls. + + * compatMakefile (LOAD_AVG): Remove variable and comments. + +Tue Aug 18 14:58:58 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * make.texinfo (Running): Node renamed to `make Invocation'. + +Fri Aug 14 12:27:10 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * arscan.c (ar_name_equal): Don't compare [MAX-3..MAX] if + NAMELEN != MEMLEN. + +Thu Aug 13 17:50:09 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.18. + + * main.c: Don't #include ; make.h already does. + +Mon Aug 10 17:03:01 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * implicit.c (pattern_search): Fixed copying of suffix when building + also_make elts. + + * function.c (expand_function: `shell'): Make sure BUFFER is + null-terminated before replacing newlines. + + * compatMakefile (mandir): Use man$(manext), not always manl. + +Sun Aug 2 01:42:50 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * rule.c (new_pattern_rule): Not static. + * rule.h: Declare it. + + * file.c (file_hash_enter): New function, most code from rename_file. + (rename_file): Call it. + * file.h (file_hash_enter): Declare it. + + * dep.h: Doc fix. + +Thu Jul 30 15:40:48 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (decode_switches): Handle usage_and_exit when building + long options vector. + + * default.c (default_terminal_rules): Make RCS rules use $(CHECKOUT,v). + (default_variables): Define CHECKOUT,v (hairy). + + * make.h [!HAVE_SYS_SIGLIST && HAVE__SYS_SIGLIST]: #define + sys_siglist to _sys_siglist. + +Sun Jul 26 16:56:32 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * NEWS: Add header and tail copyright info like Emacs NEWS. + + * make.h [ANSI_STRING]: Don't #define index, rindex, bcmp, bzero, + bcopy if already #define'd. + [STDC_HEADERS] (qsort, abort, exit): Declare here. + [! __GNU_LIBRARY__ && !POSIX]: Not here. + + * make.h [_AIX]: #pragma alloca first thing. + + * job.c (start_waiting_job): Set the command_state to cs_running + when we queue a job on waiting_jobs. + +Fri Jul 24 02:16:28 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * variable.c (define_automatic_variables): Use "" instead of nil + for empty value. + +Thu Jul 23 22:31:18 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.17. + + * main.c (struct command_switch.type): Add alternative usage_and_exit. + (command_switches): Add -h/--help. + +Thu Jul 16 14:27:50 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * GNUmakefile (make-$(version).tar.Z): Include NEWS, not CHANGES. + * README.template: Mention NEWS. + * CHANGES: Renamed to NEWS. + + * main.c [! STDC_HEADERS] [sun]: Don't declare exit. + +Tue Jul 14 18:48:41 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (main): Set -o files' command_states to cs_finished. + + * rule.c (count_implicit_rule_limits): Decrement num_pattern_rules + when tossing a rule. + + * main.c (main): Use alloca only in simple local var assignment, + for braindead SGI compiler. + + * rule.c (print_rule_data_base): Barf if num_pattern_rules is + inconsistent with the number computed when listing them. + +Mon Jul 13 17:51:53 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * commands.c (set_file_variables): For $? and $^ elts that are archive + member refs, use member name only. + +Fri Jul 10 00:05:04 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * variable.h (struct variable.export): Add new alternative v_ifset. + * variable.c (target_environment): Check for it. + (define_automatic_variables): Set it for MAKEFILES. + +Thu Jul 9 21:24:28 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (objs): Remove getloadavg.o; $(extras) gets it. + (remote.o): Use $(srcdir)/remote.c, not $remote.c<. + (distclean, mostlyclean): New targets. + +Tue Jul 7 19:12:49 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.16. + + * compatMakefile (config.status): Remove rule. + + * job.c (start_waiting_job): Free C after using C->file, not before. + +Sat Jul 4 20:51:49 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * commands.c, job.c, main.c, make.h, remote-cstms.c: Use #ifdef + HAVE_* instead of #ifndef *_MISSING. + * configure.in: Use AC_HAVE_FUNCS instead of AC_MISSING_FUNCS (gone). + +Thu Jul 2 18:47:52 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * main.c (main): makelevel>0 or -C implies -w. + +Tue Jun 30 20:50:17 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * file.c, job.c, function.c: Don't #include . + make.h: Do it here instead. + * arscan.c (ar_member_touch): Don't declare errno. + +Thu Jun 25 17:06:55 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * GNUmakefile (make-$(version).tar.Z): Depend on INSTALL, configure.in. + + * remake.c (update_file): If commands or deps are running after + update_file_1 returns, break out of the :: rule (->prev) loop and + just return. + + * job.c (job_next_command): New function; code from start_job. + (start_job_command): Renamed from start_job. Call job_next_command + and recurse for empty command lines and -n. + (start_waiting_job): Call start_job_command, not start_job. + (new_job): Call job_next_command to prime the child structure, and + then call start_waiting_job. + (reap_children): Use job_next_command and start_job_command. + (start_waiting_job): Call start_remote_job_p here, and store its + result in C->remote. If zero, check the load average and + maybe put C on waiting_jobs. + (start_job_command): Test CHILD->remote rather than calling + start_remote_job_p. Don't do load avg checking at all here. + + * main.c (main): Don't handle SIGILL, SIGIOT, SIGEMT, SIGBUS, + SIGSEGV, SIGFPE or SIGTRAP. + + * compatMakefile (glob/libglob.a): Don't pass srcdir to sub-make. + configure will set it in glob/Makefile. + +Wed Jun 24 19:40:34 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * dir.c [DIRENT] (direct): Don't define to dirent. + [! DIRENT] (direct): Define to dirent. + (dir_file_exists_p): Use struct dirent instead of struct direct. + + * make.h (getcwd): No space between macro and ( for args! + + * job.c (start_job): Don't put the job on waiting_jobs if + job_slots_used==0. + + * make.texinfo (Missing): Shortened title. + +Tue Jun 23 18:42:21 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * file.c (remove_intermediates): Print "rm" commands under -n. + +Mon Jun 22 16:20:02 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.15. + +Fri Jun 19 16:20:26 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * arscan.c [M_UNIX]: #undef M_XENIX. + +Wed Jun 17 17:59:28 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * default.c (default_terminal_rules): Put @ prefix on RCS cmds. + +Tue Jun 16 19:24:17 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile (getloadavg.o): Removed special rule. + (CFLAGS): Don't include $(defines). + (.c.o): Define suffix rule. + (glob/libglob.a): Pass CPPFLAGS=$(defines) to submake. + (GETOPT_SRC, srcs, tagsrcs): Prefix files with $(srcdir)/. + + * arscan.c (ar_name_equal): Moved local vars inside #if'd block. + + * make.h (max): Removed. + * expand.c (variable_buffer_output): Don't use it. + + * compatMakefile (INSTALL): Define. + (Makefile): New rule to make from Makefile.in. + (srcdir): Define. + (VPATH): Define. + (getloadavg.o, remote.o): Use autoconf $foo< hack. + + * commands.c (fatal_error_signal): Removed return. + +Mon Jun 15 17:42:51 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.14. + + * make.texinfo (Summary): New node. + (Special Targets): Mention .EXPORT_ALL_VARIABLES here. + + * variable.c (max): Moved to make.h. + + * compatMakefile (objs, srcs): Added ar & arscan. + + * job.c (start_waiting_job): New function, 2nd half of new_job. + (new_job): Call it. + (start_waiting_jobs): New function. + * remake.c (update_goal_chain): Call start_waiting_jobs at the top + of the main loop. + * compatMakefile (objs, srcs): Removed load, added getloadavg. + +Fri Jun 12 19:33:16 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * job.c (load_too_high): New function. Uses getloadavg. + (waiting_jobs): New variable. + (start_job): Don't call wait_to_start_job. Instead, if + load_too_high returns nonzero, add the child to the + `waiting_jobs' chain and return without starting the job. + +Thu Jun 11 00:05:28 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * expand.c (variable_buffer_output): Made global again. + * variable.h: And declare it. + + * arscan.c (PORTAR): Define for all systems if PORT5AR is not defined. + (AR_NAMELEN, AR_TRAILING_SLASH): Removed. + (ar_scan): Don't use it. Don't #ifdef AR_TRAILING_SLASH; just look + for a slash in the archive at run time. + (ar_name_equal): Rewrote .o hacking to not use AR_NAMELEN, and to + cope with trailing-slash and non-trailing-slash archives. + + * main.c (main) [! SETVBUF_REVERSED]: Test this instead of USGr3 et al. + [SETVBUF_REVERSED]: Always allocate a buffer ourselves. + + * load.c (load_average) [sgi]: Use sysmp call. + + * compatMakefile (INSTALL_DATA, INSTALL_PROGRAM): Define. + ($(bindir)/$(instname), $(mandir)/make.$(manext)): Use them. + + * make.h [HAVE_VFORK_H]: #include . + (vfork, VFORK_NAME): Don't define. + * job.c (start_job): Use "vfork" in place of VFORK_NAME. + + * make.h [HAVE_LIMITS_H, HAVE_SYS_PARAM_H]: If #define'd, #include + the each file. Rearranged PATH_MAX hacking. + * job.c: Rearranged NGROUPS_MAX hacking. + + * remake.c (fstat, time): Don't declare. + + * compatMakefile (defines): Value is @DEFS@. + (LOADLIBES): Value is @LIBS@. + (extras): Value is @LIBOBJS@. + (ARCHIVES, ARCHIVES_SRC, ALLOCASRC): Removed. + * arscan.c, ar.c: Surround body with #ifndef NO_ARCHIVES. + + * misc.c [! HAVE_UNISTD_H]: Test instead of !POSIX to decl get*id. + + * make.h [GETCWD_MISSING]: Test instead of !USG && !POSIX et al. + (getcwd): Just declare if present. If not, declare as a macro + using getwd, and declare getwd. + [PATH_MAX] (GET_PATH_MAX): #define to PATH_MAX. + * main.c (main, log_working_directory): Use getcwd instead of getwd. + + * main.c (main) [SETLINEBUF_MISSING]: Test this instead of USG. + + * make.h (SIGHANDLER, SIGNAL): Removed. + (RETSIGTYPE): Define if not #define'd. + * main.c (main): Use signal in place of SIGNAL. + + * main.c [SYS_SIGLIST_MISSING]: Test instead of USG. + + * job.c (search_path) [GETGROUPS_MISSING]: Test instead of USG. + [HAVE_UNISTD_H]: Test instead of POSIX to not decl getgroups. + + * main.c [! HAVE_UNISTD_H]: Test instead of !POSIX to decl chdir. + [! STDC_HEADERS]: Test instead of !POSIX to decl exit & atof. + + * job.c (child_handler), commands.c (fatal_error_signal): Return + RETSIGTYPE instead of int. + * main.c (main): Declare fatal_error_signal and child_handler here + to return RETSIGTYPE; removed top-level decl of former. + + * commands.c (fatal_error_signal), job.c (unblock_sigs, start_job), + main.c [SIGSETMASK_MISSING]: Test this instead of USG. + +Wed Jun 10 22:06:13 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * job.c [HAVE_WAITPID]: Test this instead of USG. + [! HAVE_UNISTD_H]: Test this instead of !POSIX to declare misc fns. + (GID_T): Don't #define. + (search_path): Use gid_t instead of GID_T. + [GETDTABLESIZE_MISSING, SYS_SIGLIST_MISSING, DUP2_MISSING]: Test + these individually instead of USG for all. + * make.h (ctime): Don't declare. #include time.h instead. + [HAVE_UNISTD_H]: #include and #define POSIX #ifdef + _POSIX_VERSION. + * dir.c [__GNU_LIBRARY__] (D_NAMLEN): Define to use d_namlen member. + * make.h [NEED_MEMORY_H]: Only include memory.h #ifdef this. + + * arscan.c: Removed #ifdef mess about string.h et al. + Just #include make.h instead. + * make.h (fstat, atol): Declare. + + * commands.c (fatal_error_signal): Don't use sigmask to check for + propagated signals; use ||s instead. + (PROPAGATED_SIGNAL_MASK): Removed. + (fatal_error_signal) [POSIX]: Use sigprocmask in place of sigsetmask. + + * variable.c (variable_buffer, variable_buffer_length, + initialize_variable_output, variable_output): Moved to expand.c; + made all static. + (struct output_state, save_variable_output, + restore_variable_output): Removed. + * expand.c (initialize_variable_output): Put a NUL at the beginning + of the new buffer after allocating it. + (allocated_variable_expand_for_file): Don't use + {save,restore}_variable_output. Do it by hand instead, keeping + state on the stack instead of malloc'ing it. + (allocated_variable_expand): Removed. + * variable.h (allocated_variable_expand): Define here as macro. + (variable_buffer_output, initialize_variable_output, + save_variable_output, restore_variable_output): Removed decls. + + * read.c (conditional_line): For an if cmd, if any elt of the + conditionals stack is ignoring, just push a new level that ignores + and return 1; don't evaluate the condition. + +Thu Jun 4 21:01:20 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (main): Put #ifdef's around frobbing SIGSYS and SIGBUS. + + * job.c (getdtablesize): Don't declare or #define if already #define'd. + +Wed Jun 3 23:42:36 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * file.c (snap_deps): If `.EXPORT_ALL_VARIABLES' is a target, set + export_all_variables. + * make.texinfo (Variables/Recursion): Document .EXPORT_ALL_VARIABLES. + +Tue Jun 2 21:08:35 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.13. + + * commands.c (set_file_variables): Calculate length for ^D and ?D + individually, making sure to give them at least enough space for "./". + + * make.h [CRAY]: #define signal to bsdsignal. + + * default.c (default_variables) [CRAY]: Define PC, SEGLDR, + CF77PPFLAGS, CF77PP, CFT, CF, and FC. + + * arscan.c (AR_HDR_SIZE): Define to sizeof (struct ar_hdr), if it + wasn't defined by . + +Thu May 28 00:56:53 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.12. + +Tue May 26 01:26:30 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * rule.c (new_pattern_rule): Initialize LASTRULE to nil, not + pattern_rules. + +Mon May 25 19:02:15 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (decode_switches): Initialize all the long_option elt members. + +Thu May 21 16:34:24 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * make.texinfo (Text Functions): Correct filter-out description. + +Tue May 19 20:50:01 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * compatMakefile (realclean): Don't remove backup files. + + * main.c (decode_switches): Allocate ARGC+1 elts in `other_args'. + +Sun May 17 16:38:48 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * Version 3.62.11. + +Thu May 14 16:42:33 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * job.c (reap_children): Don't die if wait returns EINTR. + +Wed May 13 18:28:25 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * job.c (reap_children): Always run the next command for a + successful target. If we are going to die, we don't want to leave + the target partially made. + +Tue May 12 00:39:19 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): After loop, if we only + have one word, check it for being a shell command. + + * main.c (decode_switches): Allocate ARGC slots in other_args to + begin with, so we never need to worry about growing it. + If we get a non-option arg and POSIXLY_CORRECT is in the + environment, break out of the loop. After the loop, add all remaining + args to other_args list. + + * main.c (decode_switches): For positive_int and floating switches + when optarg is nil, use next arg if it looks right (start with a + digit, or maybe decimal point for floating). + + * variable.c (define_automatic_variables): Always set SHELL to + default if it comes from the environment. Set its export bit. + * make.texinfo (Environment): Document change. + +Mon May 11 00:32:46 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * Version 3.62.10. + + * compatMakefile (tags, TAGS): Use vars for cmds. + (ETAGS, CTAGS): Define. + + * main.c (decode_switches): If a switches elt has a nil long_name, + make the long option name elt be "". + Fixed loop to not ignore all the options. + + * make.texinfo (Option Summary): Added long options. + + * main.c (switches): Changed -m's description to "-b". + (decode_switches): When printing the usage message, don't print + switches whose descriptions start with -. + When constructing the list of names for switch -C, search the + switches vector for switches whose descriptions are "-C". + + * main.c (switches): Call -S --no-keep-going, not --dont-keep-going. + Call -I --include-dir, not --include-path. + (long_option_aliases): Added --new == -W, --assume-new == -W, + --assume-old == -o, --max-load == -l, --dry-run == -n, --recon == -n, + --makefile == -f. + + * main.c (switches): Removed bogus "silent" elt. + (long_option_aliases): Define new var. + (decode_switches): Add long_option_aliases onto the end of the long + options vector created for getopt_long. + Look through long_option_aliases for extra names to list + in usage message. + +Sat May 9 00:21:05 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (log_working_directory): Fixed to properly not print the + leaving message when we haven't printed the entering message. + +Fri May 8 21:55:35 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * main.c (struct command_switch): Added elts `long_name', + `description', and `argdesc'. + (switches): Added initializers for new members. + (decode_switches): Rewritten to use getopt_long. + * compatMakefile (GETOPT, GETOPT_SRC): Define. + (objs, srcs): Include them. + + * job.c (child_died): Renamed to dead_children; made static. + (child_handler): Increment dead_children instead of setting child_died. + (reap_children): Decrement dead_children instead of clearing + child_died. The point of all this is to avoid printing "waiting + for unfinished jobs" when we don't actually need to block. + This happened when multiple SIGCHLDs before reap_children was called. + + * job.c (reap_children): If ERR is set, so we don't call start_job + on the child being reaped, instead set its command_state to + cs_finished. + (reap_children, child_handler, new_job): I added several + debugging printf's while fixing this. I left them in if (debug_flag) + because they may be useful for debugging this stuff again. + +Wed May 6 22:02:37 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * read.c (read_makefile): v_export is not 1. + +Mon May 4 17:27:37 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.9. + + * variable.c (export_all_variables): New variable. + (target_environment): Export variables whose `export' member is + v_default if export_all_variables is set and their names are benign. + * variable.h: Declare export_all_variables. + * read.c (read_makefile): If export or unexport is given with no + args, set or clear export_all_variables, respectively. + + * variable.c (target_environment): Exclude MAKELEVEL in the loop, + so it isn't duplicated when we add it at the end. + +Sun May 3 17:44:48 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.8. + + * variable.h (struct variable): Added new member `export'. + * variable.c (define_variable_in_set): Initialize it to v_default. + (target_environment): Don't check for .NOEXPORT. + Export variables whose `export' member is v_default and that would + have been exported under .NOEXPORT, and variables whose `export' + member is v_export. + (try_variable_definition): Return the variable defined. + * variable.h (try_variable_definition): Changed decl. + * read.c (read_makefile): Recognize `export' and `unexport' directives. + +Fri May 1 11:39:38 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * main.c (main) [POSIX]: Reversed args to sigaddset. + +Thu Apr 30 17:33:32 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * job.c [POSIX || !USG] (unblock_sigs): New fn. + (start_job): Block signals before forking. + (new_job): Unblock signals after putting the new child on the chain. + * main.c (main) [POSIX]: Use sigset_t fatal_signal_set instead of + int fatal_signal_mask. + + * load.c [sgi] (LDAV_CVT): Define. + +Wed Apr 29 17:15:59 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * Version 3.62.7. + + * load.c (load_average) [sgi]: Clear the high bit of the address + from the symbol table before looking it up in kmem. + + * misc.c (fatal, makefile_fatal): Put *** in fatal error messages. + (remake_file): No longer needed in message here. + + * main.c (die): Call reap_children with BLOCK==1. + +Tue Apr 28 20:44:35 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * rule.c (freerule): Don't set LASTRULE->next if LASTRULE is nil. + +Sun Apr 26 15:09:51 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * rule.c (count_implicit_rule_limits): Initialize LASTRULE to nil, + not to head of chain. Extract next ptr before we might do + freerule, and use that for next iteration. + (freerule): Still do next ptr frobbing if LASTRULE is nil. + +Tue Apr 21 03:16:29 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * job.c (child_error): Removed extra %s from error msg format. + + * Version 3.62.6. + + * job.c (reap_children): Don't start later commands in a sequence + if ERR is nonzero. + + * job.c (new_job): Always call reap_children with BLOCK==0 first thing. + + * job.c (reap_children): New function; work that used to be done in + child_handler. + (child_died): New global var. + (child_handler): Now just sets child_died. + (wait_for_children): Removed. + (unknown_children_possible, block_signals, unblock_signals, + push_signals_blocked_p, pop_signals_blocked_p): Removed. + (child_execute_job): Removed call to unblock_signals. + (new_job): Removed calls to push_signals_blocked_p and + pop_signals_blocked_p. + * job.h: Declare reap_children, not wait_for_children. + * commands.c (fatal_error_signal), job.c (new_job), + load.c [LDAV_BASED] (wait_to_start_job), main.c (die), + remake.c (update_goal_chain), function.c (expand_function: `shell'): + Changed wait_for_children calls to reap_children. + Some needed to be loops to wait for all children to die. + * commands.c (fatal_error_signal), main.c (main, + log_working_directory), function.c (expand_function): Removed calls + to push_signals_blocked_p and pop_signals_blocked_p. + * job.h: Removed decls. + + * job.h: Added copyright notice. + +Wed Apr 15 02:02:40 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (child_error): No *** for ignored error. + +Tue Apr 14 18:31:21 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * implicit.c (DEBUGP2): Use do ... while (0) instead of if ... else to + avoid compiler warnings. + + * read.c (parse_file_seq): Don't remove ./ when it is followed by a + blank. + +Mon Apr 13 21:56:15 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.h (DEBUGPR): Use do ... while (0) instead of if ... else to + avoid compiler warnings. + + * remake.c (notice_finished_file): Run file_mtime on the also_make + files, so vpath_search can happen. + + * GNUmakefile (tests): Use perl test suite from csa@sw.stratus.com. + (alpha-files): Include test suite tar file. + +Fri Apr 3 00:50:13 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 3.62.5. + +Wed Apr 1 05:31:18 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * remake.c (update_file, update_file_1): Do check_renamed on elts + of dep chains when traversing them. Something unrelated might have + renamed one of the files the dep chain points to. + + * file.c (rename_file): If FILE has been renamed, follow its + `renamed' ptr, so we get to the final real FILE. Using the renamed + ones loses because they are not in the hash table, so the removal + code loops infinitely. + + * read.c (read_all_makefiles): Clobber null terminator into + MAKEFILES expansion, so string passed to read_makefile is properly + terminated. + +Mon Mar 30 20:18:02 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * commands.c (set_file_variables): $* for archive member with + explicit cmds is stem of member, not of whole `lib(member)'. + +Thu Mar 26 15:24:38 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * Version 3.62.4. + +Tue Mar 24 05:20:51 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * rule.c (new_pattern_rule): Rules are identical only if all their + targets match (regardless of order). + +Wed Mar 11 13:49:54 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * remake.c (remake_file): Changed error "no way to make" to "no + rule to make". Fiat Hugh. + + * make.texinfo (Last Resort): Describe %:: rules and new .DEFAULT + behavior. + + * remake.c (update_file_1): Only use .DEFAULT cmds if FILE is not a + target. + +Tue Mar 10 18:13:13 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * remote-stub.c, remote-cstms.c (start_remote_job): Take new arg, + environment to pass to child. + * job.c (start_job): Pass it. + +Mon Mar 9 19:00:11 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * file.c (enter_file): Also strip ./s here, to get command-line + target names. + + * remote-cstms.c: Add comment telling people to leave me alone. + + * compatMakefile (manpage install): Remove target before copying. + +Tue Mar 3 18:43:21 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.texinfo (Missing): Renamed to "Incompatibilities and ...". + Added paragraph describing $? incompatibility with Unix and POSIX.2. + +Sun Mar 1 15:50:54 1992 Roland McGrath (roland@nutrimat.gnu.ai.mit.edu) + + * function.c (expand_function: `shell'): Don't declare fork or pipe. + Use vfork instead of fork. + +Tue Feb 25 22:05:32 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * make.texinfo (Chained Rules): Clarify .PRECIOUS to save + intermediate files. + + * load.c [sun] (LDAV_CVT): Define to divide by FSCALE. + +Sun Feb 16 02:05:16 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * Version 3.62.3. + +Sat Feb 15 17:12:20 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * compatMakefile (makeinfo): Use emacs batch-texinfo-format fn. + +Fri Feb 14 00:11:55 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * read.c (read_makefile): Correctly handle define & endef in ifdefs. + + * read.c (record_files): Pass arg for %s in error msg. + + * main.c (main) [__IBMR2, POSIX]: Use correct (a la USGr3) setvbuf + call. + +Wed Feb 12 12:07:39 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * make.texinfo (Libraries/Search): Say it does /usr/local/lib too. + +Sun Feb 9 23:06:24 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * read.c (read_makefile): Check for extraneous `endef' when ignoring. + +Thu Feb 6 16:15:48 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 3.62.2. + +Tue Feb 4 20:04:46 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Correctly ignore + whitespace after backslash-NL. + +Fri Jan 31 18:30:05 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * compatMakefile: Ignore errors from chgrp and chmod when installing. + +Wed Jan 29 18:13:30 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * main.c (main): When setting MAKELEVEL in the env to re-exec, + allocate space so as not to clobber past the end of the old string. + + * make.h [HAVE_ALLOCA_H]: Include + * compatMakefile (defines): Document HAVE_ALLOCA_H. + +Mon Jan 20 13:40:05 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * make.h [VFORK_MISSING]: Use fork instead. + * compatMakefile (defines): Document same. + + * job.c (construct_command_argv_internal): Don't create an empty + arg if backslash-NL is at beginning of word. + +Sun Jan 19 16:26:53 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * main.c [DGUX]: Call setvbuf as for USGr3. + + * job.c (construct_command_argv_internal): Notice correctly that + backslash-NL is the end of the arg (because it is replaced with a + space). + +Thu Jan 16 18:42:38 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): If SHELL is nil, set it + to default_shell before proceeding. + + * make.h [sgi]: No alloca.h, after all. + +Wed Jan 15 12:30:04 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * read.c (multi_glob): Cons up the chain of the results of glob + from back to front, so it comes out in forward order. + + * job.c (construct_command_argv_internal): Don't eat char following + backslash-NL. + +Mon Jan 13 19:16:56 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * Version 3.62.1. + + * default.c (default_variables) [ultrix]: GET=get, like USG. + + * job.c (construct_command_argv_internal): Remove tabs following + backslash-NL combos in the input line, so they don't show up when + that line is printed. + + * read.c (read_makefile): Don't collapse_continuations the line on + input; do it on the copy we do remove_comments on. + For rule lines, collapse_continuations the line after chopping + ";cmds" off the end, so we don't eat conts in the cmds. + Give error for ";cmds" with no rule. + * job.c (construct_command_argv_internal): Eat backslash-NL combos + when constructing the line to recurse on for slow, too. + +Sat Jan 11 02:20:27 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * file.c (enter_file): Don't strip leading `./'s. + * read.c (parse_file_seq): Take new arg STRIP; if nonzero, do it here. + * default.c (set_default_suffixes), function.c (string_glob), + read.c (read_makefile), rule.c (install_pattern_rule): Change callers. + + * default.c (default_variables) [_IBMR2]: FC=xlf + + * job.c (construct_command_argv_internal): Turn backslash-NL and + following whitespace into a single space, rather than just eating + the backslash. + + * make.texinfo (Copying): @include gpl.texinfo, rather than + duplicating its contents. + +Fri Nov 8 20:06:03 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Make sure not to bother + processing an empty line. + + * Version 3.62.0. + + * job.c (construct_command_argv_internal): Always recurse for slow; + simple case didn't handle finding newlines. + +Tue Nov 5 18:51:10 1991 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * job.c (construct_command_argv_internal): Set RESTP properly when + slow; don't \ify past a newline. + +Fri Nov 1 19:34:28 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * make.h [sgi]: #include . + + + +See ChangeLog.1 for earlier changes. diff --git a/Makefile.am b/Makefile.am index c393a96..5d70f42 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = 1.6 dist-bzip2 ACLOCAL_AMFLAGS = -I config -SUBDIRS = glob config po +SUBDIRS = glob config po doc bin_PROGRAMS = make @@ -23,10 +23,9 @@ EXTRA_make_SOURCES = remote-stub.c remote-cstms.c noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \ debug.h getopt.h gettext.h -make_LDADD = @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ +make_LDADD = @LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@ man_MANS = make.1 -info_TEXINFOS = make.texinfo DEFS = -DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@ @@ -40,7 +39,7 @@ AM_CPPFLAGS = $(GLOBINC) EXTRA_DIST = README build.sh.in $(man_MANS)\ README.customs\ - make-stds.texi SCOPTIONS SMakefile\ + SCOPTIONS SMakefile\ README.Amiga Makefile.ami config.ami make.lnk amiga.c amiga.h\ README.DOS Makefile.DOS configure.bat dosbuild.bat configh.dos\ README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat\ @@ -50,6 +49,13 @@ EXTRA_DIST = README build.sh.in $(man_MANS)\ MAKE_HOST = @MAKE_HOST@ +# Forward targets + +html pdf: + cd doc && $(MAKE) $(AM_MAKEFLAGS) $@ + +.PHONY: html pdf + # --------------- Internationalization Section localedir = $(datadir)/locale diff --git a/NEWS b/NEWS index aefa9a1..0237ae4 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ GNU make NEWS -*-indented-text-*- History of user-visible changes. - 21 April 2002 + 06 July 2002 Copyright (C) 2002 Free Software Foundation, Inc. See the end for copying conditions. @@ -14,6 +14,22 @@ reports. Version +* A new function is defined: $(quote ...). The argument to this + function is the _name_ of a variable. The result of the function is + the value of the variable, without having been expanded. + +* A new function is defined: $(eval ...). The arguments to this + function should expand to makefile commands, which will then be + evaluated as if they had appeared in the makefile. In combination + with define/endef multiline variable definitions this is an extremely + powerful capability. The $(quote ...) function is also useful here. + +* A new built-in variable is defined, $(MAKEFILE_LIST). It contains a + list of each makefile GNU make has read, or started to read, in the + order in which they were encountered. So, the last filename in the + list when a makefile is just being read (before any includes) is the + name of the current makefile. + * The arguments to $(call ...) functions were being stored in $1, $2, etc. as recursive variables, even though they are fully expanded before assignment. This means that escaped dollar signs ($$ etc.) diff --git a/README.cvs b/README.cvs index 367f8c5..96898e1 100644 --- a/README.cvs +++ b/README.cvs @@ -24,7 +24,7 @@ Building From CVS ----------------- To build GNU make from CVS, you will need Autoconf 2.53 (or better), -Automake 1.6.1 (or better), and Gettext 0.11.1 (or better), and any +Automake 1.6.1 (or better), and Gettext 0.11.3-pre2 (or better), and any tools that those utilities require (GNU m4, Perl, etc.). After checking out the code, you will need to perform these steps to get @@ -34,19 +34,11 @@ Hopefully at some point in the (near) future this will all be obsolete and you can just run "autoreconf" and have it DTRT. - 1) $ gettextize --no-changelog - $ mv config/Makefile.am{~,} - $ mv Makefile.am{~,} - $ mv configure.in{~,} + 1) $ autopoint This will instantiate various m4 macros files, etc. in the config and po directories. - The mv commands are necessary because gettextize doesn't realize - that the things it's adding to those files already exist in it. - Hopefully there will be a better solution for this in upcoming - versions of Gettext. - 2) $ aclocal -I config @@ -129,10 +121,7 @@ swift click o' mouse-2 into an xterm. I even grudgingly removed my use of "advanced shell features" like {}. Go for it! -gettextize --no-changelog -mv config/Makefile.am~ config/Makefile.am -mv Makefile.am~ Makefile.am -mv configure.in~ configure.in +autopoint aclocal -I config autoheader automake --add-missing diff --git a/configure.in b/configure.in index 36730a0..31a081f 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(GNU make,3.79.2a1,bug-make@gnu.org) +AC_INIT(GNU make,3.80rc1,bug-make@gnu.org) AC_PREREQ(2.53) @@ -31,7 +31,8 @@ AC_ISC_POSIX AC_MINIX # Enable gettext, in "external" mode. -# Maintainers: this requires gettext 0.11 or better! + +GETTEXT_VERSION=0.11.3-pre2 AM_GNU_GETTEXT([external]) # This test must come as early as possible after the compiler configuration @@ -279,7 +280,7 @@ AC_CACHE_VAL(make_cv_sys_gnu_glob, [ #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1 # include # if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION -# gnu glob + gnu glob # endif #endif ], [AC_MSG_RESULT(yes) @@ -354,7 +355,7 @@ esac # We only generate the build.sh if we have a build.sh.in; we won't have # one before we've created a distribution. -AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile) +AC_CONFIG_FILES(Makefile glob/Makefile po/Makefile.in config/Makefile doc/Makefile) if test -f $srcdir/build.sh.in; then AC_CONFIG_FILES(build.sh) diff --git a/dep.h b/dep.h index ca8112f..e649921 100644 --- a/dep.h +++ b/dep.h @@ -72,5 +72,6 @@ extern char *dep_name (); extern struct dep *copy_dep_chain PARAMS ((struct dep *d)); extern struct dep *read_all_makefiles PARAMS ((char **makefiles)); +extern int eval_buffer PARAMS ((char *buffer)); extern int update_goal_chain PARAMS ((struct dep *goals, int makefiles)); extern void uniquize_deps PARAMS ((struct dep *)); diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..bf979c8 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,29 @@ +## Process this file with automake to create Makefile.in. + +## Makefile for GNU make documentation. +## Copyright 2002 Free Software Foundation, Inc. + +TEXI2HTML = texi2html +TEXI2HTML_FLAGS = -split_chapter + +info_TEXINFOS = make.texi +make_TEXINFOS = fdl.texi make-stds.texi + +CLEANFILES = make*.html make*.pdf + +## ----------------------------- ## +## Other documentation formats. ## +## ----------------------------- ## + +html: make_1.html + +make_1.html: $(info_TEXINFOS) $(make_TEXINFOS) + $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(srcdir)/make.texi + + +pdf: make.pdf + +make.pdf: $(info_TEXINFOS) $(make_TEXINFOS) + $(TEXI2DVI) --pdf --batch $(srcdir)/make.texi + +.PHONY: html pdf diff --git a/doc/make.texi b/doc/make.texi new file mode 100644 index 0000000..20fc1c8 --- /dev/null +++ b/doc/make.texi @@ -0,0 +1,10141 @@ +\input texinfo @c -*- Texinfo -*- +@c %**start of header +@setfilename make.info +@settitle GNU @code{make} +@setchapternewpage odd +@c %**end of header + +@c FSF publishers: format makebook.texi instead of using this file directly. + +@set RCSID $Id$ +@set EDITION 0.60 +@set VERSION 3.80 +@set UPDATED 08 July 2002 +@set UPDATE-MONTH July 2002 +@comment The ISBN number might need to change on next publication. +@set ISBN 1-882114-81-7 @c From Brian Youmans <3diff@gnu.org>, 25 Apr 2000 + +@c finalout + +@c ISPELL CHECK: done, 10 June 1993 --roland +@c ISPELL CHECK: done, 2000-06-25 --Martin Buchholz + +@c Combine the variable and function indices: +@syncodeindex vr fn +@c Combine the program and concept indices: +@syncodeindex pg cp + +@dircategory GNU Packages +@direntry +* Make: (make). Remake files automatically. +@end direntry + +@ifinfo +This file documents the GNU Make utility, which determines +automatically which pieces of a large program need to be recompiled, +and issues the commands to recompile them. + +This is Edition @value{EDITION}, last updated @value{UPDATED}, +of @cite{The GNU Make Manual}, for @code{make}, Version @value{VERSION}. + +Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002 +Free Software Foundation, Inc. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the section entitled +``GNU Free Documentation License''. +@end ifinfo + +@iftex +@shorttitlepage GNU Make +@end iftex +@titlepage +@title GNU Make +@subtitle A Program for Directing Recompilation +@subtitle GNU @code{make} Version @value{VERSION} +@subtitle @value{UPDATE-MONTH} +@author Richard M. Stallman, Roland McGrath, Paul Smith +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, +1996, 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +@sp 2 +Published by the Free Software Foundation @* +59 Temple Place -- Suite 330, @* +Boston, MA 02111-1307 USA @* +ISBN @value{ISBN} @* + +Maintenance and updates since Version 3.76 by Paul D. Smith. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the section entitled +``GNU Free Documentation License''. +@sp 2 +Cover art by Etienne Suvasa. +@end titlepage +@page + +@ifinfo +@node Top, Overview, (dir), (dir) +@top Make + +The GNU @code{make} utility automatically determines which pieces of a +large program need to be recompiled, and issues the commands to +recompile them.@refill + +This edition of the @cite{GNU Make Manual}, +last updated @value{UPDATED}, +documents GNU @code{make} Version @value{VERSION}.@refill + +This manual describes @code{make} and contains the following chapters:@refill +@end ifinfo + +@menu +* Overview:: Overview of @code{make}. +* Introduction:: An introduction to @code{make}. +* Makefiles:: Makefiles tell @code{make} what to do. +* Rules:: Rules describe when a file must be remade. +* Commands:: Commands say how to remake a file. +* Using Variables:: You can use variables to avoid repetition. +* Conditionals:: Use or ignore parts of the makefile based + on the values of variables. +* Functions:: Many powerful ways to manipulate text. +* Invoking make: Running. How to invoke @code{make} on the command line. +* Implicit Rules:: Use implicit rules to treat many files alike, + based on their file names. +* Archives:: How @code{make} can update library archives. +* Features:: Features GNU @code{make} has over other @code{make}s. +* Missing:: What GNU @code{make} lacks from other @code{make}s. +* Makefile Conventions:: Conventions for writing makefiles for + GNU programs. +* Quick Reference:: A quick reference for experienced users. +* Error Messages:: A list of common errors generated by @code{make}. +* Complex Makefile:: A real example of a straightforward, + but nontrivial, makefile. + +* GNU Free Documentation License:: License for copying this manual +* Concept Index:: Index of Concepts +* Name Index:: Index of Functions, Variables, & Directives + +@detailmenu + --- The Detailed Node Listing --- + +Overview of @code{make} + +* Preparing:: Preparing and Running Make +* Reading:: On Reading this Text +* Bugs:: Problems and Bugs + +An Introduction to Makefiles + +* Rule Introduction:: What a rule looks like. +* Simple Makefile:: A Simple Makefile +* How Make Works:: How @code{make} Processes This Makefile +* Variables Simplify:: Variables Make Makefiles Simpler +* make Deduces:: Letting @code{make} Deduce the Commands +* Combine By Prerequisite:: Another Style of Makefile +* Cleanup:: Rules for Cleaning the Directory + +Writing Makefiles + +* Makefile Contents:: What makefiles contain. +* Makefile Names:: How to name your makefile. +* Include:: How one makefile can use another makefile. +* MAKEFILES Variable:: The environment can specify extra makefiles. +* MAKEFILE_LIST Variable:: Discover which makefiles have been read. +* Remaking Makefiles:: How makefiles get remade. +* Overriding Makefiles:: How to override part of one makefile + with another makefile. +* Reading Makefiles:: How makefiles are parsed. + +Writing Rules + +* Rule Example:: An example explained. +* Rule Syntax:: General syntax explained. +* Wildcards:: Using wildcard characters such as `*'. +* Directory Search:: Searching other directories for source files. +* Phony Targets:: Using a target that is not a real file's name. +* Force Targets:: You can use a target without commands + or prerequisites to mark other + targets as phony. +* Empty Targets:: When only the date matters and the + files are empty. +* Special Targets:: Targets with special built-in meanings. +* Multiple Targets:: When to make use of several targets in a rule. +* Multiple Rules:: How to use several rules with the same target. +* Static Pattern:: Static pattern rules apply to multiple targets + and can vary the prerequisites according to + the target name. +* Double-Colon:: How to use a special kind of rule to allow + several independent rules for one target. +* Automatic Prerequisites:: How to automatically generate rules giving + prerequisites from source files themselves. + +Using Wildcard Characters in File Names + +* Wildcard Examples:: Several examples +* Wildcard Pitfall:: Problems to avoid. +* Wildcard Function:: How to cause wildcard expansion where + it does not normally take place. + +Searching Directories for Prerequisites + +* General Search:: Specifying a search path that applies + to every prerequisite. +* Selective Search:: Specifying a search path + for a specified class of names. +* Search Algorithm:: When and how search paths are applied. +* Commands/Search:: How to write shell commands that work together + with search paths. +* Implicit/Search:: How search paths affect implicit rules. +* Libraries/Search:: Directory search for link libraries. + +Static Pattern Rules + +* Static Usage:: The syntax of static pattern rules. +* Static versus Implicit:: When are they better than implicit rules? + +Writing the Commands in Rules + +* Echoing:: How to control when commands are echoed. +* Execution:: How commands are executed. +* Parallel:: How commands can be executed in parallel. +* Errors:: What happens after a command execution error. +* Interrupts:: What happens when a command is interrupted. +* Recursion:: Invoking @code{make} from makefiles. +* Sequences:: Defining canned sequences of commands. +* Empty Commands:: Defining useful, do-nothing commands. + +Recursive Use of @code{make} + +* MAKE Variable:: The special effects of using @samp{$(MAKE)}. +* Variables/Recursion:: How to communicate variables to a sub-@code{make}. +* Options/Recursion:: How to communicate options to a sub-@code{make}. +* -w Option:: How the @samp{-w} or @samp{--print-directory} option + helps debug use of recursive @code{make} commands. + +How to Use Variables + +* Reference:: How to use the value of a variable. +* Flavors:: Variables come in two flavors. +* Advanced:: Advanced features for referencing a variable. +* Values:: All the ways variables get their values. +* Setting:: How to set a variable in the makefile. +* Appending:: How to append more text to the old value + of a variable. +* Override Directive:: How to set a variable in the makefile even if + the user has set it with a command argument. +* Defining:: An alternate way to set a variable + to a verbatim string. +* Environment:: Variable values can come from the environment. +* Target-specific:: Variable values can be defined on a per-target + basis. +* Pattern-specific:: Target-specific variable values can be applied + to a group of targets that match a pattern. + +Advanced Features for Reference to Variables + +* Substitution Refs:: Referencing a variable with + substitutions on the value. +* Computed Names:: Computing the name of the variable to refer to. + +Conditional Parts of Makefiles + +* Conditional Example:: Example of a conditional +* Conditional Syntax:: The syntax of conditionals. +* Testing Flags:: Conditionals that test flags. + +Functions for Transforming Text + +* Syntax of Functions:: How to write a function call. +* Text Functions:: General-purpose text manipulation functions. +* File Name Functions:: Functions for manipulating file names. +* Foreach Function:: Repeat some text with controlled variation. +* If Function:: Conditionally expand a value. +* Call Function:: Expand a user-defined function. +* Value Function:: Return the un-expanded value of a variable. +* Eval Function:: Evaluate the arguments as makefile syntax. +* Origin Function:: Find where a variable got its value. +* Shell Function:: Substitute the output of a shell command. +* Make Control Functions:: Functions that control how make runs. + +How to Run @code{make} + +* Makefile Arguments:: How to specify which makefile to use. +* Goals:: How to use goal arguments to specify which + parts of the makefile to use. +* Instead of Execution:: How to use mode flags to specify what + kind of thing to do with the commands + in the makefile other than simply + execute them. +* Avoiding Compilation:: How to avoid recompiling certain files. +* Overriding:: How to override a variable to specify + an alternate compiler and other things. +* Testing:: How to proceed past some errors, to + test compilation. +* Options Summary:: Summary of Options + +Using Implicit Rules + +* Using Implicit:: How to use an existing implicit rule + to get the commands for updating a file. +* Catalogue of Rules:: A list of built-in implicit rules. +* Implicit Variables:: How to change what predefined rules do. +* Chained Rules:: How to use a chain of implicit rules. +* Pattern Rules:: How to define new implicit rules. +* Last Resort:: How to defining commands for rules + which cannot find any. +* Suffix Rules:: The old-fashioned style of implicit rule. +* Implicit Rule Search:: The precise algorithm for applying + implicit rules. + +Defining and Redefining Pattern Rules + +* Pattern Intro:: An introduction to pattern rules. +* Pattern Examples:: Examples of pattern rules. +* Automatic:: How to use automatic variables in the + commands of implicit rules. +* Pattern Match:: How patterns match. +* Match-Anything Rules:: Precautions you should take prior to + defining rules that can match any + target file whatever. +* Canceling Rules:: How to override or cancel built-in rules. + +Using @code{make} to Update Archive Files + +* Archive Members:: Archive members as targets. +* Archive Update:: The implicit rule for archive member targets. +* Archive Pitfalls:: Dangers to watch out for when using archives. +* Archive Suffix Rules:: You can write a special kind of suffix rule + for updating archives. + +Implicit Rule for Archive Member Targets + +* Archive Symbols:: How to update archive symbol directories. + +Makefile Conventions + +* Makefile Basics:: General Conventions for Makefiles +* Utilities in Makefiles:: Utilities in Makefiles +* Command Variables:: Variables for Specifying Commands +* Directory Variables:: Variables for Installation Directories +* Standard Targets:: Standard Targets for Users +* Install Command Categories:: Three categories of commands in the `install' + +Copying This Manual + +@end detailmenu +@end menu + +@node Overview, Introduction, Top, Top +@comment node-name, next, previous, up +@chapter Overview of @code{make} + +The @code{make} utility automatically determines which pieces of a large +program need to be recompiled, and issues commands to recompile them. +This manual describes GNU @code{make}, which was implemented by Richard +Stallman and Roland McGrath. Development since Version 3.76 has been +handled by Paul Smith. + +GNU @code{make} conforms to section 6.2 of @cite{IEEE Standard +1003.2-1992} (POSIX.2). +@cindex POSIX +@cindex IEEE Standard 1003.2 +@cindex standards conformance + +Our examples show C programs, since they are most common, but you can use +@code{make} with any programming language whose compiler can be run with a +shell command. Indeed, @code{make} is not limited to programs. You can +use it to describe any task where some files must be updated automatically +from others whenever the others change. + +@menu +* Preparing:: Preparing and Running Make +* Reading:: On Reading this Text +* Bugs:: Problems and Bugs +@end menu + +@node Preparing, Reading, Overview, Overview +@ifinfo +@heading Preparing and Running Make +@end ifinfo + +To prepare to use @code{make}, you must write a file called +the @dfn{makefile} that describes the relationships among files +in your program and provides commands for updating each file. +In a program, typically, the executable file is updated from object +files, which are in turn made by compiling source files.@refill + +Once a suitable makefile exists, each time you change some source files, +this simple shell command: + +@example +make +@end example + +@noindent +suffices to perform all necessary recompilations. The @code{make} program +uses the makefile data base and the last-modification times of the files to +decide which of the files need to be updated. For each of those files, it +issues the commands recorded in the data base. + +You can provide command line arguments to @code{make} to control which +files should be recompiled, or how. @xref{Running, ,How to Run +@code{make}}. + +@node Reading, Bugs, Preparing, Overview +@section How to Read This Manual + +If you are new to @code{make}, or are looking for a general +introduction, read the first few sections of each chapter, skipping the +later sections. In each chapter, the first few sections contain +introductory or general information and the later sections contain +specialized or technical information. +@ifinfo +The exception is the second chapter, @ref{Introduction, ,An +Introduction to Makefiles}, all of which is introductory. +@end ifinfo +@iftex +The exception is @ref{Introduction, ,An Introduction to Makefiles}, +all of which is introductory. +@end iftex + +If you are familiar with other @code{make} programs, see @ref{Features, +,Features of GNU @code{make}}, which lists the enhancements GNU +@code{make} has, and @ref{Missing, ,Incompatibilities and Missing +Features}, which explains the few things GNU @code{make} lacks that +others have. + +For a quick summary, see @ref{Options Summary}, @ref{Quick Reference}, +and @ref{Special Targets}. + +@node Bugs, , Reading, Overview +@section Problems and Bugs +@cindex reporting bugs +@cindex bugs, reporting +@cindex problems and bugs, reporting + +If you have problems with GNU @code{make} or think you've found a bug, +please report it to the developers; we cannot promise to do anything but +we might well want to fix it. + +Before reporting a bug, make sure you've actually found a real bug. +Carefully reread the documentation and see if it really says you can do +what you're trying to do. If it's not clear whether you should be able +to do something or not, report that too; it's a bug in the +documentation! + +Before reporting a bug or trying to fix it yourself, try to isolate it +to the smallest possible makefile that reproduces the problem. Then +send us the makefile and the exact results @code{make} gave you. When +generating this small makefile, be sure to not use any non-free or +unusual tools in your commands: you can almost always emulate what +such a tool would do with simple shell commands. Finally, be sure to +explain what you expected to occur; this will help us decide whether +the problem was really in the documentation. + +Once you've got a precise problem, please send electronic mail to: + +@example + bug-make@@gnu.org +@end example + +@noindent +Please include the version number of @code{make} you are using. You can +get this information with the command @samp{make --version}. +Be sure also to include the type of machine and operating system you are +using. + +@node Introduction, Makefiles, Overview, Top +@comment node-name, next, previous, up +@chapter An Introduction to Makefiles + +You need a file called a @dfn{makefile} to tell @code{make} what to do. +Most often, the makefile tells @code{make} how to compile and link a +program. +@cindex makefile + +In this chapter, we will discuss a simple makefile that describes how to +compile and link a text editor which consists of eight C source files +and three header files. The makefile can also tell @code{make} how to +run miscellaneous commands when explicitly asked (for example, to remove +certain files as a clean-up operation). To see a more complex example +of a makefile, see @ref{Complex Makefile}. + +When @code{make} recompiles the editor, each changed C source file +must be recompiled. If a header file has changed, each C source file +that includes the header file must be recompiled to be safe. Each +compilation produces an object file corresponding to the source file. +Finally, if any source file has been recompiled, all the object files, +whether newly made or saved from previous compilations, must be linked +together to produce the new executable editor. +@cindex recompilation +@cindex editor + +@menu +* Rule Introduction:: What a rule looks like. +* Simple Makefile:: A Simple Makefile +* How Make Works:: How @code{make} Processes This Makefile +* Variables Simplify:: Variables Make Makefiles Simpler +* make Deduces:: Letting @code{make} Deduce the Commands +* Combine By Prerequisite:: Another Style of Makefile +* Cleanup:: Rules for Cleaning the Directory +@end menu + +@node Rule Introduction, Simple Makefile, Introduction, Introduction +@comment node-name, next, previous, up +@section What a Rule Looks Like +@cindex rule, introduction to +@cindex makefile rule parts +@cindex parts of makefile rule + +A simple makefile consists of ``rules'' with the following shape: + +@cindex targets, introduction to +@cindex prerequisites, introduction to +@cindex commands, introduction to +@example +@group +@var{target} @dots{} : @var{prerequisites} @dots{} + @var{command} + @dots{} + @dots{} +@end group +@end example + +A @dfn{target} is usually the name of a file that is generated by a +program; examples of targets are executable or object files. A target +can also be the name of an action to carry out, such as @samp{clean} +(@pxref{Phony Targets}). + +A @dfn{prerequisite} is a file that is used as input to create the +target. A target often depends on several files. + +@cindex tabs in rules +A @dfn{command} is an action that @code{make} carries out. +A rule may have more than one command, each on its own line. +@strong{Please note:} you need to put a tab character at the beginning of +every command line! This is an obscurity that catches the unwary. + +Usually a command is in a rule with prerequisites and serves to create a +target file if any of the prerequisites change. However, the rule that +specifies commands for the target need not have prerequisites. For +example, the rule containing the delete command associated with the +target @samp{clean} does not have prerequisites. + +A @dfn{rule}, then, explains how and when to remake certain files +which are the targets of the particular rule. @code{make} carries out +the commands on the prerequisites to create or update the target. A +rule can also explain how and when to carry out an action. +@xref{Rules, , Writing Rules}. + +A makefile may contain other text besides rules, but a simple makefile +need only contain rules. Rules may look somewhat more complicated +than shown in this template, but all fit the pattern more or less. + +@node Simple Makefile, How Make Works, Rule Introduction, Introduction +@section A Simple Makefile +@cindex simple makefile +@cindex makefile, simple + +Here is a straightforward makefile that describes the way an +executable file called @code{edit} depends on eight object files +which, in turn, depend on eight C source and three header files. + +In this example, all the C files include @file{defs.h}, but only those +defining editing commands include @file{command.h}, and only low +level files that change the editor buffer include @file{buffer.h}. + +@example +@group +edit : main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + cc -o edit main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + +main.o : main.c defs.h + cc -c main.c +kbd.o : kbd.c defs.h command.h + cc -c kbd.c +command.o : command.c defs.h command.h + cc -c command.c +display.o : display.c defs.h buffer.h + cc -c display.c +insert.o : insert.c defs.h buffer.h + cc -c insert.c +search.o : search.c defs.h buffer.h + cc -c search.c +files.o : files.c defs.h buffer.h command.h + cc -c files.c +utils.o : utils.c defs.h + cc -c utils.c +clean : + rm edit main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o +@end group +@end example + +@noindent +We split each long line into two lines using backslash-newline; this is +like using one long line, but is easier to read. +@cindex continuation lines +@cindex @code{\} (backslash), for continuation lines +@cindex backslash (@code{\}), for continuation lines +@cindex quoting newline, in makefile +@cindex newline, quoting, in makefile + +To use this makefile to create the executable file called @file{edit}, +type: + +@example +make +@end example + +To use this makefile to delete the executable file and all the object +files from the directory, type: + +@example +make clean +@end example + +In the example makefile, the targets include the executable file +@samp{edit}, and the object files @samp{main.o} and @samp{kbd.o}. The +prerequisites are files such as @samp{main.c} and @samp{defs.h}. +In fact, each @samp{.o} file is both a target and a prerequisite. +Commands include @w{@samp{cc -c main.c}} and @w{@samp{cc -c kbd.c}}. + +When a target is a file, it needs to be recompiled or relinked if any +of its prerequisites change. In addition, any prerequisites that are +themselves automatically generated should be updated first. In this +example, @file{edit} depends on each of the eight object files; the +object file @file{main.o} depends on the source file @file{main.c} and +on the header file @file{defs.h}. + +A shell command follows each line that contains a target and +prerequisites. These shell commands say how to update the target file. +A tab character must come at the beginning of every command line to +distinguish commands lines from other lines in the makefile. (Bear in +mind that @code{make} does not know anything about how the commands +work. It is up to you to supply commands that will update the target +file properly. All @code{make} does is execute the commands in the rule +you have specified when the target file needs to be updated.) +@cindex shell command + +The target @samp{clean} is not a file, but merely the name of an +action. Since you +normally +do not want to carry out the actions in this rule, @samp{clean} is not a prerequisite of any other rule. +Consequently, @code{make} never does anything with it unless you tell +it specifically. Note that this rule not only is not a prerequisite, it +also does not have any prerequisites, so the only purpose of the rule +is to run the specified commands. Targets that do not refer to files +but are just actions are called @dfn{phony targets}. @xref{Phony +Targets}, for information about this kind of target. @xref{Errors, , +Errors in Commands}, to see how to cause @code{make} to ignore errors +from @code{rm} or any other command. +@cindex @code{clean} target +@cindex @code{rm} (shell command) + +@node How Make Works, Variables Simplify, Simple Makefile, Introduction +@comment node-name, next, previous, up +@section How @code{make} Processes a Makefile +@cindex processing a makefile +@cindex makefile, how @code{make} processes + +By default, @code{make} starts with the first target (not targets whose +names start with @samp{.}). This is called the @dfn{default goal}. +(@dfn{Goals} are the targets that @code{make} strives ultimately to +update. @xref{Goals, , Arguments to Specify the Goals}.) +@cindex default goal +@cindex goal, default +@cindex goal + +In the simple example of the previous section, the default goal is to +update the executable program @file{edit}; therefore, we put that rule +first. + +Thus, when you give the command: + +@example +make +@end example + +@noindent +@code{make} reads the makefile in the current directory and begins by +processing the first rule. In the example, this rule is for relinking +@file{edit}; but before @code{make} can fully process this rule, it +must process the rules for the files that @file{edit} depends on, +which in this case are the object files. Each of these files is +processed according to its own rule. These rules say to update each +@samp{.o} file by compiling its source file. The recompilation must +be done if the source file, or any of the header files named as +prerequisites, is more recent than the object file, or if the object +file does not exist. + +The other rules are processed because their targets appear as +prerequisites of the goal. If some other rule is not depended on by the +goal (or anything it depends on, etc.), that rule is not processed, +unless you tell @code{make} to do so (with a command such as +@w{@code{make clean}}). + +Before recompiling an object file, @code{make} considers updating its +prerequisites, the source file and header files. This makefile does not +specify anything to be done for them---the @samp{.c} and @samp{.h} files +are not the targets of any rules---so @code{make} does nothing for these +files. But @code{make} would update automatically generated C programs, +such as those made by Bison or Yacc, by their own rules at this time. + +After recompiling whichever object files need it, @code{make} decides +whether to relink @file{edit}. This must be done if the file +@file{edit} does not exist, or if any of the object files are newer than +it. If an object file was just recompiled, it is now newer than +@file{edit}, so @file{edit} is relinked. +@cindex relinking + +Thus, if we change the file @file{insert.c} and run @code{make}, +@code{make} will compile that file to update @file{insert.o}, and then +link @file{edit}. If we change the file @file{command.h} and run +@code{make}, @code{make} will recompile the object files @file{kbd.o}, +@file{command.o} and @file{files.o} and then link the file @file{edit}. + +@node Variables Simplify, make Deduces, How Make Works, Introduction +@section Variables Make Makefiles Simpler +@cindex variables +@cindex simplifying with variables + +In our example, we had to list all the object files twice in the rule for +@file{edit} (repeated here): + +@example +@group +edit : main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + cc -o edit main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o +@end group +@end example + +@cindex @code{objects} +Such duplication is error-prone; if a new object file is added to the +system, we might add it to one list and forget the other. We can eliminate +the risk and simplify the makefile by using a variable. @dfn{Variables} +allow a text string to be defined once and substituted in multiple places +later (@pxref{Using Variables, ,How to Use Variables}). + +@cindex @code{OBJECTS} +@cindex @code{objs} +@cindex @code{OBJS} +@cindex @code{obj} +@cindex @code{OBJ} +It is standard practice for every makefile to have a variable named +@code{objects}, @code{OBJECTS}, @code{objs}, @code{OBJS}, @code{obj}, +or @code{OBJ} which is a list of all object file names. We would +define such a variable @code{objects} with a line like this in the +makefile:@refill + +@example +@group +objects = main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o +@end group +@end example + +@noindent +Then, each place we want to put a list of the object file names, we can +substitute the variable's value by writing @samp{$(objects)} +(@pxref{Using Variables, ,How to Use Variables}). + +Here is how the complete simple makefile looks when you use a variable +for the object files: + +@example +@group +objects = main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + +edit : $(objects) + cc -o edit $(objects) +main.o : main.c defs.h + cc -c main.c +kbd.o : kbd.c defs.h command.h + cc -c kbd.c +command.o : command.c defs.h command.h + cc -c command.c +display.o : display.c defs.h buffer.h + cc -c display.c +insert.o : insert.c defs.h buffer.h + cc -c insert.c +search.o : search.c defs.h buffer.h + cc -c search.c +files.o : files.c defs.h buffer.h command.h + cc -c files.c +utils.o : utils.c defs.h + cc -c utils.c +clean : + rm edit $(objects) +@end group +@end example + +@node make Deduces, Combine By Prerequisite, Variables Simplify, Introduction +@section Letting @code{make} Deduce the Commands +@cindex deducing commands (implicit rules) +@cindex implicit rule, introduction to +@cindex rule, implicit, introduction to + +It is not necessary to spell out the commands for compiling the individual +C source files, because @code{make} can figure them out: it has an +@dfn{implicit rule} for updating a @samp{.o} file from a correspondingly +named @samp{.c} file using a @samp{cc -c} command. For example, it will +use the command @samp{cc -c main.c -o main.o} to compile @file{main.c} into +@file{main.o}. We can therefore omit the commands from the rules for the +object files. @xref{Implicit Rules, ,Using Implicit Rules}.@refill + +When a @samp{.c} file is used automatically in this way, it is also +automatically added to the list of prerequisites. We can therefore omit +the @samp{.c} files from the prerequisites, provided we omit the commands. + +Here is the entire example, with both of these changes, and a variable +@code{objects} as suggested above: + +@example +@group +objects = main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + +edit : $(objects) + cc -o edit $(objects) + +main.o : defs.h +kbd.o : defs.h command.h +command.o : defs.h command.h +display.o : defs.h buffer.h +insert.o : defs.h buffer.h +search.o : defs.h buffer.h +files.o : defs.h buffer.h command.h +utils.o : defs.h + +.PHONY : clean +clean : + rm edit $(objects) +@end group +@end example + +@noindent +This is how we would write the makefile in actual practice. (The +complications associated with @samp{clean} are described elsewhere. +See @ref{Phony Targets}, and @ref{Errors, ,Errors in Commands}.) + +Because implicit rules are so convenient, they are important. You +will see them used frequently.@refill + +@node Combine By Prerequisite, Cleanup, make Deduces, Introduction +@section Another Style of Makefile +@cindex combining rules by prerequisite + +When the objects of a makefile are created only by implicit rules, an +alternative style of makefile is possible. In this style of makefile, +you group entries by their prerequisites instead of by their targets. +Here is what one looks like: + +@example +@group +objects = main.o kbd.o command.o display.o \ + insert.o search.o files.o utils.o + +edit : $(objects) + cc -o edit $(objects) + +$(objects) : defs.h +kbd.o command.o files.o : command.h +display.o insert.o search.o files.o : buffer.h +@end group +@end example + +@noindent +Here @file{defs.h} is given as a prerequisite of all the object files; +@file{command.h} and @file{buffer.h} are prerequisites of the specific +object files listed for them. + +Whether this is better is a matter of taste: it is more compact, but some +people dislike it because they find it clearer to put all the information +about each target in one place. + +@node Cleanup, , Combine By Prerequisite, Introduction +@section Rules for Cleaning the Directory +@cindex cleaning up +@cindex removing, to clean up + +Compiling a program is not the only thing you might want to write rules +for. Makefiles commonly tell how to do a few other things besides +compiling a program: for example, how to delete all the object files +and executables so that the directory is @samp{clean}. + +@cindex @code{clean} target +Here is how we +could write a @code{make} rule for cleaning our example editor: + +@example +@group +clean: + rm edit $(objects) +@end group +@end example + +In practice, we might want to write the rule in a somewhat more +complicated manner to handle unanticipated situations. We would do this: + +@example +@group +.PHONY : clean +clean : + -rm edit $(objects) +@end group +@end example + +@noindent +This prevents @code{make} from getting confused by an actual file +called @file{clean} and causes it to continue in spite of errors from +@code{rm}. (See @ref{Phony Targets}, and @ref{Errors, ,Errors in +Commands}.) + +@noindent +A rule such as this should not be placed at the beginning of the +makefile, because we do not want it to run by default! Thus, in the +example makefile, we want the rule for @code{edit}, which recompiles +the editor, to remain the default goal. + +Since @code{clean} is not a prerequisite of @code{edit}, this rule will not +run at all if we give the command @samp{make} with no arguments. In +order to make the rule run, we have to type @samp{make clean}. +@xref{Running, ,How to Run @code{make}}. + +@node Makefiles, Rules, Introduction, Top +@chapter Writing Makefiles + +@cindex makefile, how to write +The information that tells @code{make} how to recompile a system comes from +reading a data base called the @dfn{makefile}. + +@menu +* Makefile Contents:: What makefiles contain. +* Makefile Names:: How to name your makefile. +* Include:: How one makefile can use another makefile. +* MAKEFILES Variable:: The environment can specify extra makefiles. +* MAKEFILE_LIST Variable:: Discover which makefiles have been read. +* Remaking Makefiles:: How makefiles get remade. +* Overriding Makefiles:: How to override part of one makefile + with another makefile. +* Reading Makefiles:: How makefiles are parsed. +@end menu + +@node Makefile Contents, Makefile Names, Makefiles, Makefiles +@section What Makefiles Contain + +Makefiles contain five kinds of things: @dfn{explicit rules}, +@dfn{implicit rules}, @dfn{variable definitions}, @dfn{directives}, +and @dfn{comments}. Rules, variables, and directives are described at +length in later chapters.@refill + +@itemize @bullet +@cindex rule, explicit, definition of +@cindex explicit rule, definition of +@item +An @dfn{explicit rule} says when and how to remake one or more files, +called the rule's targets. It lists the other files that the targets +depend on, call the @dfn{prerequisites} of the target, and may also give +commands to use to create or update the targets. @xref{Rules, ,Writing +Rules}. + +@cindex rule, implicit, definition of +@cindex implicit rule, definition of +@item +An @dfn{implicit rule} says when and how to remake a class of files +based on their names. It describes how a target may depend on a file +with a name similar to the target and gives commands to create or +update such a target. @xref{Implicit Rules, ,Using Implicit Rules}. + +@cindex variable definition +@item +A @dfn{variable definition} is a line that specifies a text string +value for a variable that can be substituted into the text later. The +simple makefile example shows a variable definition for @code{objects} +as a list of all object files (@pxref{Variables Simplify, , Variables +Make Makefiles Simpler}). + +@cindex directive +@item +A @dfn{directive} is a command for @code{make} to do something special while +reading the makefile. These include: + +@itemize @bullet +@item +Reading another makefile (@pxref{Include, ,Including Other Makefiles}). + +@item +Deciding (based on the values of variables) whether to use or +ignore a part of the makefile (@pxref{Conditionals, ,Conditional Parts of Makefiles}). + +@item +Defining a variable from a verbatim string containing multiple lines +(@pxref{Defining, ,Defining Variables Verbatim}). +@end itemize + +@cindex comments, in makefile +@cindex @code{#} (comments), in makefile +@item +@samp{#} in a line of a makefile starts a @dfn{comment}. It and the rest of +the line are ignored, except that a trailing backslash not escaped by +another backslash will continue the comment across multiple lines. +Comments may appear on any of the lines in the makefile, except within a +@code{define} directive, and perhaps within commands (where the shell +decides what is a comment). A line containing just a comment (with +perhaps spaces before it) is effectively blank, and is ignored.@refill +@end itemize + +@node Makefile Names, Include, Makefile Contents, Makefiles +@section What Name to Give Your Makefile +@cindex makefile name +@cindex name of makefile +@cindex default makefile name +@cindex file name of makefile + +@c following paragraph rewritten to avoid overfull hbox +By default, when @code{make} looks for the makefile, it tries the +following names, in order: @file{GNUmakefile}, @file{makefile} +and @file{Makefile}.@refill +@findex Makefile +@findex GNUmakefile +@findex makefile + +@cindex @code{README} +Normally you should call your makefile either @file{makefile} or +@file{Makefile}. (We recommend @file{Makefile} because it appears +prominently near the beginning of a directory listing, right near other +important files such as @file{README}.) The first name checked, +@file{GNUmakefile}, is not recommended for most makefiles. You should +use this name if you have a makefile that is specific to GNU +@code{make}, and will not be understood by other versions of +@code{make}. Other @code{make} programs look for @file{makefile} and +@file{Makefile}, but not @file{GNUmakefile}. + +If @code{make} finds none of these names, it does not use any makefile. +Then you must specify a goal with a command argument, and @code{make} +will attempt to figure out how to remake it using only its built-in +implicit rules. @xref{Implicit Rules, ,Using Implicit Rules}. + +@cindex @code{-f} +@cindex @code{--file} +@cindex @code{--makefile} +If you want to use a nonstandard name for your makefile, you can specify +the makefile name with the @samp{-f} or @samp{--file} option. The +arguments @w{@samp{-f @var{name}}} or @w{@samp{--file=@var{name}}} tell +@code{make} to read the file @var{name} as the makefile. If you use +more than one @samp{-f} or @samp{--file} option, you can specify several +makefiles. All the makefiles are effectively concatenated in the order +specified. The default makefile names @file{GNUmakefile}, +@file{makefile} and @file{Makefile} are not checked automatically if you +specify @samp{-f} or @samp{--file}.@refill +@cindex specifying makefile name +@cindex makefile name, how to specify +@cindex name of makefile, how to specify +@cindex file name of makefile, how to specify + +@node Include, MAKEFILES Variable, Makefile Names, Makefiles +@section Including Other Makefiles +@cindex including other makefiles +@cindex makefile, including + +@findex include +The @code{include} directive tells @code{make} to suspend reading the +current makefile and read one or more other makefiles before continuing. +The directive is a line in the makefile that looks like this: + +@example +include @var{filenames}@dots{} +@end example + +@noindent +@var{filenames} can contain shell file name patterns. +@cindex shell file name pattern (in @code{include}) +@cindex shell wildcards (in @code{include}) +@cindex wildcard, in @code{include} + +Extra spaces are allowed and ignored at the beginning of the line, but +a tab is not allowed. (If the line begins with a tab, it will be +considered a command line.) Whitespace is required between +@code{include} and the file names, and between file names; extra +whitespace is ignored there and at the end of the directive. A +comment starting with @samp{#} is allowed at the end of the line. If +the file names contain any variable or function references, they are +expanded. @xref{Using Variables, ,How to Use Variables}. + +For example, if you have three @file{.mk} files, @file{a.mk}, +@file{b.mk}, and @file{c.mk}, and @code{$(bar)} expands to +@code{bish bash}, then the following expression + +@example +include foo *.mk $(bar) +@end example + +is equivalent to + +@example +include foo a.mk b.mk c.mk bish bash +@end example + +When @code{make} processes an @code{include} directive, it suspends +reading of the containing makefile and reads from each listed file in +turn. When that is finished, @code{make} resumes reading the +makefile in which the directive appears. + +One occasion for using @code{include} directives is when several programs, +handled by individual makefiles in various directories, need to use a +common set of variable definitions +(@pxref{Setting, ,Setting Variables}) or pattern rules +(@pxref{Pattern Rules, ,Defining and Redefining Pattern Rules}). + +Another such occasion is when you want to generate prerequisites from +source files automatically; the prerequisites can be put in a file that +is included by the main makefile. This practice is generally cleaner +than that of somehow appending the prerequisites to the end of the main +makefile as has been traditionally done with other versions of +@code{make}. @xref{Automatic Prerequisites}. +@cindex prerequisites, automatic generation +@cindex automatic generation of prerequisites +@cindex generating prerequisites automatically + +@cindex @code{-I} +@cindex @code{--include-dir} +@cindex included makefiles, default directories +@cindex default directories for included makefiles +@findex /usr/gnu/include +@findex /usr/local/include +@findex /usr/include +If the specified name does not start with a slash, and the file is not +found in the current directory, several other directories are searched. +First, any directories you have specified with the @samp{-I} or +@samp{--include-dir} option are searched +(@pxref{Options Summary, ,Summary of Options}). +Then the following directories (if they exist) +are searched, in this order: +@file{@var{prefix}/include} (normally @file{/usr/local/include} +@footnote{GNU Make compiled for MS-DOS and MS-Windows behaves as if +@var{prefix} has been defined to be the root of the DJGPP tree +hierarchy.}) +@file{/usr/gnu/include}, +@file{/usr/local/include}, @file{/usr/include}. + +If an included makefile cannot be found in any of these directories, a +warning message is generated, but it is not an immediately fatal error; +processing of the makefile containing the @code{include} continues. +Once it has finished reading makefiles, @code{make} will try to remake +any that are out of date or don't exist. +@xref{Remaking Makefiles, ,How Makefiles Are Remade}. +Only after it has tried to find a way to remake a makefile and failed, +will @code{make} diagnose the missing makefile as a fatal error. + +If you want @code{make} to simply ignore a makefile which does not exist +and cannot be remade, with no error message, use the @w{@code{-include}} +directive instead of @code{include}, like this: + +@example +-include @var{filenames}@dots{} +@end example + +This acts like @code{include} in every way except that there is no +error (not even a warning) if any of the @var{filenames} do not exist. +For compatibility with some other @code{make} implementations, +@code{sinclude} is another name for @w{@code{-include}}. + +@node MAKEFILES Variable, MAKEFILE_LIST Variable, Include, Makefiles +@section The Variable @code{MAKEFILES} +@cindex makefile, and @code{MAKEFILES} variable +@cindex including (@code{MAKEFILES} variable) + +@vindex MAKEFILES +If the environment variable @code{MAKEFILES} is defined, @code{make} +considers its value as a list of names (separated by whitespace) of +additional makefiles to be read before the others. This works much like +the @code{include} directive: various directories are searched for those +files (@pxref{Include, ,Including Other Makefiles}). In addition, the +default goal is never taken from one of these makefiles and it is not an +error if the files listed in @code{MAKEFILES} are not found.@refill + +@cindex recursion, and @code{MAKEFILES} variable +The main use of @code{MAKEFILES} is in communication between recursive +invocations of @code{make} (@pxref{Recursion, ,Recursive Use of +@code{make}}). It usually is not desirable to set the environment +variable before a top-level invocation of @code{make}, because it is +usually better not to mess with a makefile from outside. However, if +you are running @code{make} without a specific makefile, a makefile in +@code{MAKEFILES} can do useful things to help the built-in implicit +rules work better, such as defining search paths (@pxref{Directory Search}). + +Some users are tempted to set @code{MAKEFILES} in the environment +automatically on login, and program makefiles to expect this to be done. +This is a very bad idea, because such makefiles will fail to work if run by +anyone else. It is much better to write explicit @code{include} directives +in the makefiles. @xref{Include, , Including Other Makefiles}. + +@node MAKEFILE_LIST Variable, Remaking Makefiles, MAKEFILES Variable, Makefiles +@comment node-name, next, previous, up +@section The Variable @code{MAKEFILE_LIST} +@cindex makefiles, and @code{MAKEFILE_LIST} variable +@cindex including (@code{MAKEFILE_LIST} variable) + +As @code{make} reads various makefiles, including any obtained from the +@code{MAKEFILES} variable, the command line, the default files, or +from @code{include} directives, their names will be automatically +appended to the @code{MAKEFILE_LIST} variable. They are added right +before @code{make} begins to parse them. + +This means that if the first thing a makefile does is examine the last +word in this variable, it will be the name of the current makefile. +Once the current makefile has used @code{include}, however, the last +word will be the just-included makefile. + +If a makefile named @code{Makefile} has this content: + +@example +@group +name1 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) + +include inc.mk + +name2 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) + +all: + @@echo name1 = $(name1) + @@echo name2 = $(name2) +@end group +@end example + +@noindent +then you would expect to see this output: + +@example +@group +name1 = Makefile +name2 = inc.mk +@end group +@end example + +@xref{Text Functions}, for more information on the @code{word} and +@code{words} functions used above. @xref{Flavors, The Two Flavors of +Variables}, for more information on simply-expanded (@code{:=}) +variable definitions. + +@node Remaking Makefiles, Overriding Makefiles, MAKEFILE_LIST Variable, Makefiles +@section How Makefiles Are Remade + +@cindex updating makefiles +@cindex remaking makefiles +@cindex makefile, remaking of +Sometimes makefiles can be remade from other files, such as RCS or SCCS +files. If a makefile can be remade from other files, you probably want +@code{make} to get an up-to-date version of the makefile to read in. + +To this end, after reading in all makefiles, @code{make} will consider +each as a goal target and attempt to update it. If a makefile has a +rule which says how to update it (found either in that very makefile or +in another one) or if an implicit rule applies to it (@pxref{Implicit +Rules, ,Using Implicit Rules}), it will be updated if necessary. After +all makefiles have been checked, if any have actually been changed, +@code{make} starts with a clean slate and reads all the makefiles over +again. (It will also attempt to update each of them over again, but +normally this will not change them again, since they are already up to +date.)@refill + +If you know that one or more of your makefiles cannot be remade and you +want to keep @code{make} from performing an implicit rule search on +them, perhaps for efficiency reasons, you can use any normal method of +preventing implicit rule lookup to do so. For example, you can write an +explicit rule with the makefile as the target, and an empty command +string (@pxref{Empty Commands, ,Using Empty Commands}). + +If the makefiles specify a double-colon rule to remake a file with +commands but no prerequisites, that file will always be remade +(@pxref{Double-Colon}). In the case of makefiles, a makefile that has a +double-colon rule with commands but no prerequisites will be remade every +time @code{make} is run, and then again after @code{make} starts over +and reads the makefiles in again. This would cause an infinite loop: +@code{make} would constantly remake the makefile, and never do anything +else. So, to avoid this, @code{make} will @strong{not} attempt to +remake makefiles which are specified as targets of a double-colon rule +with commands but no prerequisites.@refill + +If you do not specify any makefiles to be read with @samp{-f} or +@samp{--file} options, @code{make} will try the default makefile names; +@pxref{Makefile Names, ,What Name to Give Your Makefile}. Unlike +makefiles explicitly requested with @samp{-f} or @samp{--file} options, +@code{make} is not certain that these makefiles should exist. However, +if a default makefile does not exist but can be created by running +@code{make} rules, you probably want the rules to be run so that the +makefile can be used. + +Therefore, if none of the default makefiles exists, @code{make} will try +to make each of them in the same order in which they are searched for +(@pxref{Makefile Names, ,What Name to Give Your Makefile}) +until it succeeds in making one, or it runs out of names to try. Note +that it is not an error if @code{make} cannot find or make any makefile; +a makefile is not always necessary.@refill + +When you use the @samp{-t} or @samp{--touch} option +(@pxref{Instead of Execution, ,Instead of Executing the Commands}), +you would not want to use an out-of-date makefile to decide which +targets to touch. So the @samp{-t} option has no effect on updating +makefiles; they are really updated even if @samp{-t} is specified. +Likewise, @samp{-q} (or @samp{--question}) and @samp{-n} (or +@samp{--just-print}) do not prevent updating of makefiles, because an +out-of-date makefile would result in the wrong output for other targets. +Thus, @samp{make -f mfile -n foo} will update @file{mfile}, read it in, +and then print the commands to update @file{foo} and its prerequisites +without running them. The commands printed for @file{foo} will be those +specified in the updated contents of @file{mfile}. + +However, on occasion you might actually wish to prevent updating of even +the makefiles. You can do this by specifying the makefiles as goals in +the command line as well as specifying them as makefiles. When the +makefile name is specified explicitly as a goal, the options @samp{-t} +and so on do apply to them. + +Thus, @samp{make -f mfile -n mfile foo} would read the makefile +@file{mfile}, print the commands needed to update it without actually +running them, and then print the commands needed to update @file{foo} +without running them. The commands for @file{foo} will be those +specified by the existing contents of @file{mfile}. + +@node Overriding Makefiles, Reading Makefiles, Remaking Makefiles, Makefiles +@section Overriding Part of Another Makefile + +@cindex overriding makefiles +@cindex makefile, overriding +Sometimes it is useful to have a makefile that is mostly just like +another makefile. You can often use the @samp{include} directive to +include one in the other, and add more targets or variable definitions. +However, if the two makefiles give different commands for the same +target, @code{make} will not let you just do this. But there is another way. + +@cindex match-anything rule, used to override +In the containing makefile (the one that wants to include the other), +you can use a match-anything pattern rule to say that to remake any +target that cannot be made from the information in the containing +makefile, @code{make} should look in another makefile. +@xref{Pattern Rules}, for more information on pattern rules. + +For example, if you have a makefile called @file{Makefile} that says how +to make the target @samp{foo} (and other targets), you can write a +makefile called @file{GNUmakefile} that contains: + +@example +foo: + frobnicate > foo + +%: force + @@$(MAKE) -f Makefile $@@ +force: ; +@end example + +If you say @samp{make foo}, @code{make} will find @file{GNUmakefile}, +read it, and see that to make @file{foo}, it needs to run the command +@samp{frobnicate > foo}. If you say @samp{make bar}, @code{make} will +find no way to make @file{bar} in @file{GNUmakefile}, so it will use the +commands from the pattern rule: @samp{make -f Makefile bar}. If +@file{Makefile} provides a rule for updating @file{bar}, @code{make} +will apply the rule. And likewise for any other target that +@file{GNUmakefile} does not say how to make. + +The way this works is that the pattern rule has a pattern of just +@samp{%}, so it matches any target whatever. The rule specifies a +prerequisite @file{force}, to guarantee that the commands will be run even +if the target file already exists. We give @file{force} target empty +commands to prevent @code{make} from searching for an implicit rule to +build it---otherwise it would apply the same match-anything rule to +@file{force} itself and create a prerequisite loop! + +@node Reading Makefiles, , Overriding Makefiles, Makefiles +@section How @code{make} Reads a Makefile +@cindex reading makefiles +@cindex makefile, parsing + +GNU @code{make} does its work in two distinct phases. During the first +phase it reads all the makefiles, included makefiles, etc. and +internalizes all the variables and their values, implicit and explicit +rules, and constructs a dependency graph of all the targets and their +prerequisites. During the second phase, @code{make} uses these internal +structures to determine what targets will need to be rebuilt and to +invoke the rules necessary to do so. + +It's important to understand this two-phase approach because it has a +direct impact on how variable and function expansion happens; this is +often a source of some confusion when writing makefiles. Here we will +present a summary of the phases in which expansion happens for different +constructs within the makefile. We say that expansion is +@dfn{immediate} if it happens during the first phase: in this case +@code{make} will expand any variables or functions in that section of a +construct as the makefile is parsed. We say that expansion is +@dfn{deferred} if expansion is not performed immediately. Expansion of +deferred construct is not performed until either the construct appears +later in an immediate context, or until the second phase. + +You may not be familiar with some of these constructs yet. You can +reference this section as you become familiar with them, in later +chapters. + +@subheading Variable Assignment +@cindex +=, expansion +@cindex =, expansion +@cindex ?=, expansion +@cindex +=, expansion +@cindex define, expansion + +Variable definitions are parsed as follows: + +@example +@var{immediate} = @var{deferred} +@var{immediate} ?= @var{deferred} +@var{immediate} := @var{immediate} +@var{immediate} += @var{deferred} or @var{immediate} + +define @var{immediate} + @var{deferred} +endef +@end example + +For the append operator, @samp{+=}, the right-hand side is considered +immediate if the variable was previously set as a simple variable +(@samp{:=}), and deferred otherwise. + +@subheading Conditional Statements +@cindex ifdef, expansion +@cindex ifeq, expansion +@cindex ifndef, expansion +@cindex ifneq, expansion + +All instances of conditional syntax are parsed immediately, in their +entirety; this includes the @code{ifdef}, @code{ifeq}, @code{ifndef}, +and @code{ifneq} forms. + +@subheading Rule Definition +@cindex target, expansion +@cindex prerequisite, expansion +@cindex implicit rule, expansion +@cindex pattern rule, expansion +@cindex explicit rule, expansion + +A rule is always expanded the same way, regardless of the form: + +@example +@var{immediate} : @var{immediate} ; @var{deferred} + @var{deferred} +@end example + +That is, the target and prerequisite sections are expanded immediately, +and the commands used to construct the target are always deferred. This +general rule is true for explicit rules, pattern rules, suffix rules, +static pattern rules, and simple prerequisite definitions. + +@node Rules, Commands, Makefiles, Top +@chapter Writing Rules +@cindex writing rules +@cindex rule, how to write +@cindex target +@cindex prerequisite + +A @dfn{rule} appears in the makefile and says when and how to remake +certain files, called the rule's @dfn{targets} (most often only one per rule). +It lists the other files that are the @dfn{prerequisites} of the target, and +@dfn{commands} to use to create or update the target. + +@cindex default goal +@cindex goal, default +The order of rules is not significant, except for determining the +@dfn{default goal}: the target for @code{make} to consider, if you do +not otherwise specify one. The default goal is the target of the first +rule in the first makefile. If the first rule has multiple targets, +only the first target is taken as the default. There are two +exceptions: a target starting with a period is not a default unless it +contains one or more slashes, @samp{/}, as well; and, a target that +defines a pattern rule has no effect on the default goal. +(@xref{Pattern Rules, ,Defining and Redefining Pattern Rules}.) + +Therefore, we usually write the makefile so that the first rule is the +one for compiling the entire program or all the programs described by +the makefile (often with a target called @samp{all}). +@xref{Goals, ,Arguments to Specify the Goals}. + +@menu +* Rule Example:: An example explained. +* Rule Syntax:: General syntax explained. +* Wildcards:: Using wildcard characters such as `*'. +* Directory Search:: Searching other directories for source files. +* Phony Targets:: Using a target that is not a real file's name. +* Force Targets:: You can use a target without commands + or prerequisites to mark other + targets as phony. +* Empty Targets:: When only the date matters and the + files are empty. +* Special Targets:: Targets with special built-in meanings. +* Multiple Targets:: When to make use of several targets in a rule. +* Multiple Rules:: How to use several rules with the same target. +* Static Pattern:: Static pattern rules apply to multiple targets + and can vary the prerequisites according to + the target name. +* Double-Colon:: How to use a special kind of rule to allow + several independent rules for one target. +* Automatic Prerequisites:: How to automatically generate rules giving + prerequisites from source files themselves. +@end menu + +@ifinfo +@node Rule Example, Rule Syntax, Rules, Rules +@section Rule Example + +Here is an example of a rule: + +@example +foo.o : foo.c defs.h # module for twiddling the frobs + cc -c -g foo.c +@end example + +Its target is @file{foo.o} and its prerequisites are @file{foo.c} and +@file{defs.h}. It has one command, which is @samp{cc -c -g foo.c}. +The command line starts with a tab to identify it as a command. + +This rule says two things: + +@itemize @bullet +@item +How to decide whether @file{foo.o} is out of date: it is out of date +if it does not exist, or if either @file{foo.c} or @file{defs.h} is +more recent than it. + +@item +How to update the file @file{foo.o}: by running @code{cc} as stated. +The command does not explicitly mention @file{defs.h}, but we presume +that @file{foo.c} includes it, and that that is why @file{defs.h} was +added to the prerequisites. +@end itemize +@end ifinfo + +@node Rule Syntax, Wildcards, Rule Example, Rules +@section Rule Syntax + +@cindex rule syntax +@cindex syntax of rules +In general, a rule looks like this: + +@example +@var{targets} : @var{prerequisites} + @var{command} + @dots{} +@end example + +@noindent +or like this: + +@example +@var{targets} : @var{prerequisites} ; @var{command} + @var{command} + @dots{} +@end example + +@cindex targets +@cindex rule targets +The @var{targets} are file names, separated by spaces. Wildcard +characters may be used (@pxref{Wildcards, ,Using Wildcard Characters +in File Names}) and a name of the form @file{@var{a}(@var{m})} +represents member @var{m} in archive file @var{a} +(@pxref{Archive Members, ,Archive Members as Targets}). +Usually there is only one +target per rule, but occasionally there is a reason to have more +(@pxref{Multiple Targets, , Multiple Targets in a Rule}).@refill + +@cindex commands +@cindex tab character (in commands) +The @var{command} lines start with a tab character. The first command may +appear on the line after the prerequisites, with a tab character, or may +appear on the same line, with a semicolon. Either way, the effect is the +same. @xref{Commands, ,Writing the Commands in Rules}. + +@cindex dollar sign (@code{$}), in rules +@cindex @code{$}, in rules +@cindex rule, and @code{$} +Because dollar signs are used to start variable references, if you really +want a dollar sign in a rule you must write two of them, @samp{$$} +(@pxref{Using Variables, ,How to Use Variables}). +You may split a long line by inserting a backslash +followed by a newline, but this is not required, as @code{make} places no +limit on the length of a line in a makefile. + +A rule tells @code{make} two things: when the targets are out of date, +and how to update them when necessary. + +@cindex prerequisites +@cindex rule prerequisites +The criterion for being out of date is specified in terms of the +@var{prerequisites}, which consist of file names separated by spaces. +(Wildcards and archive members (@pxref{Archives}) are allowed here too.) +A target is out of date if it does not exist or if it is older than any +of the prerequisites (by comparison of last-modification times). The +idea is that the contents of the target file are computed based on +information in the prerequisites, so if any of the prerequisites changes, +the contents of the existing target file are no longer necessarily +valid. + +How to update is specified by @var{commands}. These are lines to be +executed by the shell (normally @samp{sh}), but with some extra features +(@pxref{Commands, ,Writing the Commands in Rules}). + +@node Wildcards, Directory Search, Rule Syntax, Rules +@section Using Wildcard Characters in File Names +@cindex wildcard +@cindex file name with wildcards +@cindex globbing (wildcards) + +@cindex @code{*} (wildcard character) +@cindex @code{?} (wildcard character) +@cindex @code{[@dots{}]} (wildcard characters) +A single file name can specify many files using @dfn{wildcard characters}. +The wildcard characters in @code{make} are @samp{*}, @samp{?} and +@samp{[@dots{}]}, the same as in the Bourne shell. For example, @file{*.c} +specifies a list of all the files (in the working directory) whose names +end in @samp{.c}.@refill + +@cindex @code{~} (tilde) +@cindex tilde (@code{~}) +@cindex home directory +The character @samp{~} at the beginning of a file name also has special +significance. If alone, or followed by a slash, it represents your home +directory. For example @file{~/bin} expands to @file{/home/you/bin}. +If the @samp{~} is followed by a word, the string represents the home +directory of the user named by that word. For example @file{~john/bin} +expands to @file{/home/john/bin}. On systems which don't have a home +directory for each user (such as MS-DOS or MS-Windows), this +functionality can be simulated by setting the environment variable +@var{HOME}.@refill + +Wildcard expansion happens automatically in targets, in prerequisites, +and in commands (where the shell does the expansion). In other +contexts, wildcard expansion happens only if you request it explicitly +with the @code{wildcard} function. + +The special significance of a wildcard character can be turned off by +preceding it with a backslash. Thus, @file{foo\*bar} would refer to a +specific file whose name consists of @samp{foo}, an asterisk, and +@samp{bar}.@refill + +@menu +* Wildcard Examples:: Several examples +* Wildcard Pitfall:: Problems to avoid. +* Wildcard Function:: How to cause wildcard expansion where + it does not normally take place. +@end menu + +@node Wildcard Examples, Wildcard Pitfall, Wildcards, Wildcards +@subsection Wildcard Examples + +Wildcards can be used in the commands of a rule, where they are expanded +by the shell. For example, here is a rule to delete all the object files: + +@example +@group +clean: + rm -f *.o +@end group +@end example +@cindex @code{rm} (shell command) + +Wildcards are also useful in the prerequisites of a rule. With the +following rule in the makefile, @samp{make print} will print all the +@samp{.c} files that have changed since the last time you printed them: + +@example +print: *.c + lpr -p $? + touch print +@end example + +@cindex @code{print} target +@cindex @code{lpr} (shell command) +@cindex @code{touch} (shell command) +@noindent +This rule uses @file{print} as an empty target file; see @ref{Empty +Targets, ,Empty Target Files to Record Events}. (The automatic variable +@samp{$?} is used to print only those files that have changed; see +@ref{Automatic, ,Automatic Variables}.)@refill + +Wildcard expansion does not happen when you define a variable. Thus, if +you write this: + +@example +objects = *.o +@end example + +@noindent +then the value of the variable @code{objects} is the actual string +@samp{*.o}. However, if you use the value of @code{objects} in a target, +prerequisite or command, wildcard expansion will take place at that time. +To set @code{objects} to the expansion, instead use: + +@example +objects := $(wildcard *.o) +@end example + +@noindent +@xref{Wildcard Function}. + +@node Wildcard Pitfall, Wildcard Function, Wildcard Examples, Wildcards +@subsection Pitfalls of Using Wildcards +@cindex wildcard pitfalls +@cindex pitfalls of wildcards +@cindex mistakes with wildcards +@cindex errors with wildcards +@cindex problems with wildcards + +Now here is an example of a naive way of using wildcard expansion, that +does not do what you would intend. Suppose you would like to say that the +executable file @file{foo} is made from all the object files in the +directory, and you write this: + +@example +objects = *.o + +foo : $(objects) + cc -o foo $(CFLAGS) $(objects) +@end example + +@noindent +The value of @code{objects} is the actual string @samp{*.o}. Wildcard +expansion happens in the rule for @file{foo}, so that each @emph{existing} +@samp{.o} file becomes a prerequisite of @file{foo} and will be recompiled if +necessary. + +But what if you delete all the @samp{.o} files? When a wildcard matches +no files, it is left as it is, so then @file{foo} will depend on the +oddly-named file @file{*.o}. Since no such file is likely to exist, +@code{make} will give you an error saying it cannot figure out how to +make @file{*.o}. This is not what you want! + +Actually it is possible to obtain the desired result with wildcard +expansion, but you need more sophisticated techniques, including the +@code{wildcard} function and string substitution. +@ifinfo +@xref{Wildcard Function, ,The Function @code{wildcard}}. +@end ifinfo +@iftex +These are described in the following section. +@end iftex + +@cindex wildcards and MS-DOS/MS-Windows backslashes +@cindex backslashes in pathnames and wildcard expansion + +Microsoft operating systems (MS-DOS and MS-Windows) use backslashes to +separate directories in pathnames, like so: + +@example + c:\foo\bar\baz.c +@end example + +This is equivalent to the Unix-style @file{c:/foo/bar/baz.c} (the +@file{c:} part is the so-called drive letter). When @code{make} runs on +these systems, it supports backslashes as well as the Unix-style forward +slashes in pathnames. However, this support does @emph{not} include the +wildcard expansion, where backslash is a quote character. Therefore, +you @emph{must} use Unix-style slashes in these cases. + + +@node Wildcard Function, , Wildcard Pitfall, Wildcards +@subsection The Function @code{wildcard} +@findex wildcard + +Wildcard expansion happens automatically in rules. But wildcard expansion +does not normally take place when a variable is set, or inside the +arguments of a function. If you want to do wildcard expansion in such +places, you need to use the @code{wildcard} function, like this: + +@example +$(wildcard @var{pattern}@dots{}) +@end example + +@noindent +This string, used anywhere in a makefile, is replaced by a +space-separated list of names of existing files that match one of the +given file name patterns. If no existing file name matches a pattern, +then that pattern is omitted from the output of the @code{wildcard} +function. Note that this is different from how unmatched wildcards +behave in rules, where they are used verbatim rather than ignored +(@pxref{Wildcard Pitfall}). + +One use of the @code{wildcard} function is to get a list of all the C source +files in a directory, like this: + +@example +$(wildcard *.c) +@end example + +We can change the list of C source files into a list of object files by +replacing the @samp{.c} suffix with @samp{.o} in the result, like this: + +@example +$(patsubst %.c,%.o,$(wildcard *.c)) +@end example + +@noindent +(Here we have used another function, @code{patsubst}. +@xref{Text Functions, ,Functions for String Substitution and Analysis}.)@refill + +Thus, a makefile to compile all C source files in the directory and then +link them together could be written as follows: + +@example +objects := $(patsubst %.c,%.o,$(wildcard *.c)) + +foo : $(objects) + cc -o foo $(objects) +@end example + +@noindent +(This takes advantage of the implicit rule for compiling C programs, so +there is no need to write explicit rules for compiling the files. +@xref{Flavors, ,The Two Flavors of Variables}, for an explanation of +@samp{:=}, which is a variant of @samp{=}.) + +@node Directory Search, Phony Targets, Wildcards, Rules +@section Searching Directories for Prerequisites +@vindex VPATH +@findex vpath +@cindex vpath +@cindex search path for prerequisites (@code{VPATH}) +@cindex directory search (@code{VPATH}) + +For large systems, it is often desirable to put sources in a separate +directory from the binaries. The @dfn{directory search} features of +@code{make} facilitate this by searching several directories +automatically to find a prerequisite. When you redistribute the files +among directories, you do not need to change the individual rules, +just the search paths. + +@menu +* General Search:: Specifying a search path that applies + to every prerequisite. +* Selective Search:: Specifying a search path + for a specified class of names. +* Search Algorithm:: When and how search paths are applied. +* Commands/Search:: How to write shell commands that work together + with search paths. +* Implicit/Search:: How search paths affect implicit rules. +* Libraries/Search:: Directory search for link libraries. +@end menu + +@node General Search, Selective Search, Directory Search, Directory Search +@subsection @code{VPATH}: Search Path for All Prerequisites +@vindex VPATH + +The value of the @code{make} variable @code{VPATH} specifies a list of +directories that @code{make} should search. Most often, the +directories are expected to contain prerequisite files that are not in the +current directory; however, @code{VPATH} specifies a search list that +@code{make} applies for all files, including files which are targets of +rules. + +Thus, if a file that is listed as a target or prerequisite does not exist +in the current directory, @code{make} searches the directories listed in +@code{VPATH} for a file with that name. If a file is found in one of +them, that file may become the prerequisite (see below). Rules may then +specify the names of files in the prerequisite list as if they all +existed in the current directory. @xref{Commands/Search, ,Writing Shell +Commands with Directory Search}. + +In the @code{VPATH} variable, directory names are separated by colons or +blanks. The order in which directories are listed is the order followed +by @code{make} in its search. (On MS-DOS and MS-Windows, semi-colons +are used as separators of directory names in @code{VPATH}, since the +colon can be used in the pathname itself, after the drive letter.) + +For example, + +@example +VPATH = src:../headers +@end example + +@noindent +specifies a path containing two directories, @file{src} and +@file{../headers}, which @code{make} searches in that order. + +With this value of @code{VPATH}, the following rule, + +@example +foo.o : foo.c +@end example + +@noindent +is interpreted as if it were written like this: + +@example +foo.o : src/foo.c +@end example + +@noindent +assuming the file @file{foo.c} does not exist in the current directory but +is found in the directory @file{src}. + +@node Selective Search, Search Algorithm, General Search, Directory Search +@subsection The @code{vpath} Directive +@findex vpath + +Similar to the @code{VPATH} variable, but more selective, is the +@code{vpath} directive (note lower case), which allows you to specify a +search path for a particular class of file names: those that match a +particular pattern. Thus you can supply certain search directories for +one class of file names and other directories (or none) for other file +names. + +There are three forms of the @code{vpath} directive: + +@table @code +@item vpath @var{pattern} @var{directories} +Specify the search path @var{directories} for file names that match +@var{pattern}. + +The search path, @var{directories}, is a list of directories to be +searched, separated by colons (semi-colons on MS-DOS and MS-Windows) or +blanks, just like the search path used in the @code{VPATH} variable. + +@item vpath @var{pattern} +Clear out the search path associated with @var{pattern}. + +@c Extra blank line makes sure this gets two lines. +@item vpath + +Clear all search paths previously specified with @code{vpath} directives. +@end table + +A @code{vpath} pattern is a string containing a @samp{%} character. The +string must match the file name of a prerequisite that is being searched +for, the @samp{%} character matching any sequence of zero or more +characters (as in pattern rules; @pxref{Pattern Rules, ,Defining and +Redefining Pattern Rules}). For example, @code{%.h} matches files that +end in @code{.h}. (If there is no @samp{%}, the pattern must match the +prerequisite exactly, which is not useful very often.) + +@cindex @code{%}, quoting in @code{vpath} +@cindex @code{%}, quoting with @code{\} (backslash) +@cindex @code{\} (backslash), to quote @code{%} +@cindex backslash (@code{\}), to quote @code{%} +@cindex quoting @code{%}, in @code{vpath} +@samp{%} characters in a @code{vpath} directive's pattern can be quoted +with preceding backslashes (@samp{\}). Backslashes that would otherwise +quote @samp{%} characters can be quoted with more backslashes. +Backslashes that quote @samp{%} characters or other backslashes are +removed from the pattern before it is compared to file names. Backslashes +that are not in danger of quoting @samp{%} characters go unmolested.@refill + +When a prerequisite fails to exist in the current directory, if the +@var{pattern} in a @code{vpath} directive matches the name of the +prerequisite file, then the @var{directories} in that directive are searched +just like (and before) the directories in the @code{VPATH} variable. + +For example, + +@example +vpath %.h ../headers +@end example + +@noindent +tells @code{make} to look for any prerequisite whose name ends in @file{.h} +in the directory @file{../headers} if the file is not found in the current +directory. + +If several @code{vpath} patterns match the prerequisite file's name, then +@code{make} processes each matching @code{vpath} directive one by one, +searching all the directories mentioned in each directive. @code{make} +handles multiple @code{vpath} directives in the order in which they +appear in the makefile; multiple directives with the same pattern are +independent of each other. + +@need 750 +Thus, + +@example +@group +vpath %.c foo +vpath % blish +vpath %.c bar +@end group +@end example + +@noindent +will look for a file ending in @samp{.c} in @file{foo}, then +@file{blish}, then @file{bar}, while + +@example +@group +vpath %.c foo:bar +vpath % blish +@end group +@end example + +@noindent +will look for a file ending in @samp{.c} in @file{foo}, then +@file{bar}, then @file{blish}. + +@node Search Algorithm, Commands/Search, Selective Search, Directory Search +@subsection How Directory Searches are Performed +@cindex algorithm for directory search +@cindex directory search algorithm + +When a prerequisite is found through directory search, regardless of type +(general or selective), the pathname located may not be the one that +@code{make} actually provides you in the prerequisite list. Sometimes +the path discovered through directory search is thrown away. + +The algorithm @code{make} uses to decide whether to keep or abandon a +path found via directory search is as follows: + +@enumerate +@item +If a target file does not exist at the path specified in the makefile, +directory search is performed. + +@item +If the directory search is successful, that path is kept and this file +is tentatively stored as the target. + +@item +All prerequisites of this target are examined using this same method. + +@item +After processing the prerequisites, the target may or may not need to be +rebuilt: + +@enumerate a +@item +If the target does @emph{not} need to be rebuilt, the path to the file +found during directory search is used for any prerequisite lists which +contain this target. In short, if @code{make} doesn't need to rebuild +the target then you use the path found via directory search. + +@item +If the target @emph{does} need to be rebuilt (is out-of-date), the +pathname found during directory search is @emph{thrown away}, and the +target is rebuilt using the file name specified in the makefile. In +short, if @code{make} must rebuild, then the target is rebuilt locally, +not in the directory found via directory search. +@end enumerate +@end enumerate + +This algorithm may seem complex, but in practice it is quite often +exactly what you want. + +@cindex traditional directory search (GPATH) +@cindex directory search, traditional (GPATH) +Other versions of @code{make} use a simpler algorithm: if the file does +not exist, and it is found via directory search, then that pathname is +always used whether or not the target needs to be built. Thus, if the +target is rebuilt it is created at the pathname discovered during +directory search. + +@vindex GPATH +If, in fact, this is the behavior you want for some or all of your +directories, you can use the @code{GPATH} variable to indicate this to +@code{make}. + +@code{GPATH} has the same syntax and format as @code{VPATH} (that is, a +space- or colon-delimited list of pathnames). If an out-of-date target +is found by directory search in a directory that also appears in +@code{GPATH}, then that pathname is not thrown away. The target is +rebuilt using the expanded path. + +@node Commands/Search, Implicit/Search, Search Algorithm, Directory Search +@subsection Writing Shell Commands with Directory Search +@cindex shell command, and directory search +@cindex directory search (@code{VPATH}), and shell commands + +When a prerequisite is found in another directory through directory search, +this cannot change the commands of the rule; they will execute as written. +Therefore, you must write the commands with care so that they will look for +the prerequisite in the directory where @code{make} finds it. + +This is done with the @dfn{automatic variables} such as @samp{$^} +(@pxref{Automatic, ,Automatic Variables}). +For instance, the value of @samp{$^} is a +list of all the prerequisites of the rule, including the names of +the directories in which they were found, and the value of +@samp{$@@} is the target. Thus:@refill + +@example +foo.o : foo.c + cc -c $(CFLAGS) $^ -o $@@ +@end example + +@noindent +(The variable @code{CFLAGS} exists so you can specify flags for C +compilation by implicit rules; we use it here for consistency so it will +affect all C compilations uniformly; +@pxref{Implicit Variables, ,Variables Used by Implicit Rules}.) + +Often the prerequisites include header files as well, which you do not +want to mention in the commands. The automatic variable @samp{$<} is +just the first prerequisite: + +@example +VPATH = src:../headers +foo.o : foo.c defs.h hack.h + cc -c $(CFLAGS) $< -o $@@ +@end example + +@node Implicit/Search, Libraries/Search, Commands/Search, Directory Search +@subsection Directory Search and Implicit Rules +@cindex @code{VPATH}, and implicit rules +@cindex directory search (@code{VPATH}), and implicit rules +@cindex search path for prerequisites (@code{VPATH}), and implicit rules +@cindex implicit rule, and directory search +@cindex implicit rule, and @code{VPATH} +@cindex rule, implicit, and directory search +@cindex rule, implicit, and @code{VPATH} + +The search through the directories specified in @code{VPATH} or with +@code{vpath} also happens during consideration of implicit rules +(@pxref{Implicit Rules, ,Using Implicit Rules}). + +For example, when a file @file{foo.o} has no explicit rule, @code{make} +considers implicit rules, such as the built-in rule to compile +@file{foo.c} if that file exists. If such a file is lacking in the +current directory, the appropriate directories are searched for it. If +@file{foo.c} exists (or is mentioned in the makefile) in any of the +directories, the implicit rule for C compilation is applied. + +The commands of implicit rules normally use automatic variables as a +matter of necessity; consequently they will use the file names found by +directory search with no extra effort. + +@node Libraries/Search, , Implicit/Search, Directory Search +@subsection Directory Search for Link Libraries +@cindex link libraries, and directory search +@cindex libraries for linking, directory search +@cindex directory search (@code{VPATH}), and link libraries +@cindex @code{VPATH}, and link libraries +@cindex search path for prerequisites (@code{VPATH}), and link libraries +@cindex @code{-l} (library search) +@cindex link libraries, patterns matching +@cindex @code{.LIBPATTERNS}, and link libraries +@vindex .LIBPATTERNS + +Directory search applies in a special way to libraries used with the +linker. This special feature comes into play when you write a prerequisite +whose name is of the form @samp{-l@var{name}}. (You can tell something +strange is going on here because the prerequisite is normally the name of a +file, and the @emph{file name} of a library generally looks like +@file{lib@var{name}.a}, not like @samp{-l@var{name}}.)@refill + +When a prerequisite's name has the form @samp{-l@var{name}}, @code{make} +handles it specially by searching for the file @file{lib@var{name}.so} in +the current directory, in directories specified by matching @code{vpath} +search paths and the @code{VPATH} search path, and then in the +directories @file{/lib}, @file{/usr/lib}, and @file{@var{prefix}/lib} +(normally @file{/usr/local/lib}, but MS-DOS/MS-Windows versions of +@code{make} behave as if @var{prefix} is defined to be the root of the +DJGPP installation tree). + +If that file is not found, then the file @file{lib@var{name}.a} is +searched for, in the same directories as above. + +For example, if there is a @file{/usr/lib/libcurses.a} library on your +system (and no @file{/usr/lib/libcurses.so} file), then + +@example +@group +foo : foo.c -lcurses + cc $^ -o $@@ +@end group +@end example + +@noindent +would cause the command @samp{cc foo.c /usr/lib/libcurses.a -o foo} to +be executed when @file{foo} is older than @file{foo.c} or than +@file{/usr/lib/libcurses.a}.@refill + +Although the default set of files to be searched for is +@file{lib@var{name}.so} and @file{lib@var{name}.a}, this is customizable +via the @code{.LIBPATTERNS} variable. Each word in the value of this +variable is a pattern string. When a prerequisite like +@samp{-l@var{name}} is seen, @code{make} will replace the percent in +each pattern in the list with @var{name} and perform the above directory +searches using that library filename. If no library is found, the next +word in the list will be used. + +The default value for @code{.LIBPATTERNS} is ``@samp{lib%.so lib%.a}'', +which provides the default behavior described above. + +You can turn off link library expansion completely by setting this +variable to an empty value. + +@node Phony Targets, Force Targets, Directory Search, Rules +@section Phony Targets +@cindex phony targets +@cindex targets, phony +@cindex targets without a file + +A phony target is one that is not really the name of a file. It is just a +name for some commands to be executed when you make an explicit request. +There are two reasons to use a phony target: to avoid a conflict with +a file of the same name, and to improve performance. + +If you write a rule whose commands will not create the target file, the +commands will be executed every time the target comes up for remaking. +Here is an example: + +@example +@group +clean: + rm *.o temp +@end group +@end example + +@noindent +Because the @code{rm} command does not create a file named @file{clean}, +probably no such file will ever exist. Therefore, the @code{rm} command +will be executed every time you say @samp{make clean}. +@cindex @code{rm} (shell command) + +@findex .PHONY +The phony target will cease to work if anything ever does create a file +named @file{clean} in this directory. Since it has no prerequisites, the +file @file{clean} would inevitably be considered up to date, and its +commands would not be executed. To avoid this problem, you can explicitly +declare the target to be phony, using the special target @code{.PHONY} +(@pxref{Special Targets, ,Special Built-in Target Names}) as follows: + +@example +.PHONY : clean +@end example + +@noindent +Once this is done, @samp{make clean} will run the commands regardless of +whether there is a file named @file{clean}. + +Since it knows that phony targets do not name actual files that could be +remade from other files, @code{make} skips the implicit rule search for +phony targets (@pxref{Implicit Rules}). This is why declaring a target +phony is good for performance, even if you are not worried about the +actual file existing. + +Thus, you first write the line that states that @code{clean} is a +phony target, then you write the rule, like this: + +@example +@group +.PHONY: clean +clean: + rm *.o temp +@end group +@end example + +Another example of the usefulness of phony targets is in conjunction +with recursive invocations of @code{make}. In this case the makefile +will often contain a variable which lists a number of subdirectories to +be built. One way to handle this is with one rule whose command is a +shell loop over the subdirectories, like this: + +@example +@group +SUBDIRS = foo bar baz + +subdirs: + for dir in $(SUBDIRS); do \ + $(MAKE) -C $$dir; \ + done +@end group +@end example + +There are a few problems with this method, however. First, any error +detected in a submake is not noted by this rule, so it will continue to +build the rest of the directories even when one fails. This can be +overcome by adding shell commands to note the error and exit, but then +it will do so even if @code{make} is invoked with the @code{-k} option, +which is unfortunate. Second, and perhaps more importantly, you cannot +take advantage of the parallel build capabilities of make using this +method, since there is only one rule. + +By declaring the subdirectories as phony targets (you must do this as +the subdirectory obviously always exists; otherwise it won't be built) +you can remove these problems: + +@example +@group +SUBDIRS = foo bar baz + +.PHONY: subdirs $(SUBDIRS) + +subdirs: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@@ + +foo: baz +@end group +@end example + +Here we've also declared that the @file{foo} subdirectory cannot be +built until after the @file{baz} subdirectory is complete; this kind of +relationship declaration is particularly important when attempting +parallel builds. + +A phony target should not be a prerequisite of a real target file; if it +is, its commands are run every time @code{make} goes to update that +file. As long as a phony target is never a prerequisite of a real +target, the phony target commands will be executed only when the phony +target is a specified goal (@pxref{Goals, ,Arguments to Specify the +Goals}). + +Phony targets can have prerequisites. When one directory contains multiple +programs, it is most convenient to describe all of the programs in one +makefile @file{./Makefile}. Since the target remade by default will be the +first one in the makefile, it is common to make this a phony target named +@samp{all} and give it, as prerequisites, all the individual programs. For +example: + +@example +all : prog1 prog2 prog3 +.PHONY : all + +prog1 : prog1.o utils.o + cc -o prog1 prog1.o utils.o + +prog2 : prog2.o + cc -o prog2 prog2.o + +prog3 : prog3.o sort.o utils.o + cc -o prog3 prog3.o sort.o utils.o +@end example + +@noindent +Now you can say just @samp{make} to remake all three programs, or specify +as arguments the ones to remake (as in @samp{make prog1 prog3}). + +When one phony target is a prerequisite of another, it serves as a subroutine +of the other. For example, here @samp{make cleanall} will delete the +object files, the difference files, and the file @file{program}: + +@example +.PHONY: cleanall cleanobj cleandiff + +cleanall : cleanobj cleandiff + rm program + +cleanobj : + rm *.o + +cleandiff : + rm *.diff +@end example + +@node Force Targets, Empty Targets, Phony Targets, Rules +@section Rules without Commands or Prerequisites +@cindex force targets +@cindex targets, force +@cindex @code{FORCE} +@cindex rule, no commands or prerequisites + +If a rule has no prerequisites or commands, and the target of the rule +is a nonexistent file, then @code{make} imagines this target to have +been updated whenever its rule is run. This implies that all targets +depending on this one will always have their commands run. + +An example will illustrate this: + +@example +@group +clean: FORCE + rm $(objects) +FORCE: +@end group +@end example + +Here the target @samp{FORCE} satisfies the special conditions, so the +target @file{clean} that depends on it is forced to run its commands. +There is nothing special about the name @samp{FORCE}, but that is one name +commonly used this way. + +As you can see, using @samp{FORCE} this way has the same results as using +@samp{.PHONY: clean}. + +Using @samp{.PHONY} is more explicit and more efficient. However, +other versions of @code{make} do not support @samp{.PHONY}; thus +@samp{FORCE} appears in many makefiles. @xref{Phony Targets}. + +@node Empty Targets, Special Targets, Force Targets, Rules +@section Empty Target Files to Record Events +@cindex empty targets +@cindex targets, empty +@cindex recording events with empty targets + +The @dfn{empty target} is a variant of the phony target; it is used to hold +commands for an action that you request explicitly from time to time. +Unlike a phony target, this target file can really exist; but the file's +contents do not matter, and usually are empty. + +The purpose of the empty target file is to record, with its +last-modification time, when the rule's commands were last executed. It +does so because one of the commands is a @code{touch} command to update the +target file. + +The empty target file should have some prerequisites (otherwise it +doesn't make sense). When you ask to remake the empty target, the +commands are executed if any prerequisite is more recent than the target; +in other words, if a prerequisite has changed since the last time you +remade the target. Here is an example: + +@example +print: foo.c bar.c + lpr -p $? + touch print +@end example +@cindex @code{print} target +@cindex @code{lpr} (shell command) +@cindex @code{touch} (shell command) + +@noindent +With this rule, @samp{make print} will execute the @code{lpr} command if +either source file has changed since the last @samp{make print}. The +automatic variable @samp{$?} is used to print only those files that have +changed (@pxref{Automatic, ,Automatic Variables}). + +@node Special Targets, Multiple Targets, Empty Targets, Rules +@section Special Built-in Target Names +@cindex special targets +@cindex built-in special targets +@cindex targets, built-in special + +Certain names have special meanings if they appear as targets. + +@table @code +@findex .PHONY +@item .PHONY + +The prerequisites of the special target @code{.PHONY} are considered to +be phony targets. When it is time to consider such a target, +@code{make} will run its commands unconditionally, regardless of +whether a file with that name exists or what its last-modification +time is. @xref{Phony Targets, ,Phony Targets}. + +@findex .SUFFIXES +@item .SUFFIXES + +The prerequisites of the special target @code{.SUFFIXES} are the list +of suffixes to be used in checking for suffix rules. +@xref{Suffix Rules, , Old-Fashioned Suffix Rules}. + +@findex .DEFAULT +@item .DEFAULT + +The commands specified for @code{.DEFAULT} are used for any target for +which no rules are found (either explicit rules or implicit rules). +@xref{Last Resort}. If @code{.DEFAULT} commands are specified, every +file mentioned as a prerequisite, but not as a target in a rule, will have +these commands executed on its behalf. @xref{Implicit Rule Search, +,Implicit Rule Search Algorithm}. + +@findex .PRECIOUS +@item .PRECIOUS +@cindex precious targets +@cindex preserving with @code{.PRECIOUS} + +The targets which @code{.PRECIOUS} depends on are given the following +special treatment: if @code{make} is killed or interrupted during the +execution of their commands, the target is not deleted. +@xref{Interrupts, ,Interrupting or Killing @code{make}}. Also, if the +target is an intermediate file, it will not be deleted after it is no +longer needed, as is normally done. @xref{Chained Rules, ,Chains of +Implicit Rules}. In this latter respect it overlaps with the +@code{.SECONDARY} special target. + +You can also list the target pattern of an implicit rule (such as +@samp{%.o}) as a prerequisite file of the special target @code{.PRECIOUS} +to preserve intermediate files created by rules whose target patterns +match that file's name. + +@findex .INTERMEDIATE +@item .INTERMEDIATE +@cindex intermediate targets, explicit + +The targets which @code{.INTERMEDIATE} depends on are treated as +intermediate files. @xref{Chained Rules, ,Chains of Implicit Rules}. +@code{.INTERMEDIATE} with no prerequisites has no effect. + +@findex .SECONDARY +@item .SECONDARY +@cindex secondary targets +@cindex preserving with @code{.SECONDARY} + +The targets which @code{.SECONDARY} depends on are treated as +intermediate files, except that they are never automatically deleted. +@xref{Chained Rules, ,Chains of Implicit Rules}. + +@code{.SECONDARY} with no prerequisites causes all targets to be treated +as secondary (i.e., no target is removed because it is considered +intermediate). + +@findex .DELETE_ON_ERROR +@item .DELETE_ON_ERROR +@cindex removing targets on failure + +If @code{.DELETE_ON_ERROR} is mentioned as a target anywhere in the +makefile, then @code{make} will delete the target of a rule if it has +changed and its commands exit with a nonzero exit status, just as it +does when it receives a signal. @xref{Errors, ,Errors in Commands}. + +@findex .IGNORE +@item .IGNORE + +If you specify prerequisites for @code{.IGNORE}, then @code{make} will +ignore errors in execution of the commands run for those particular +files. The commands for @code{.IGNORE} are not meaningful. + +If mentioned as a target with no prerequisites, @code{.IGNORE} says to +ignore errors in execution of commands for all files. This usage of +@samp{.IGNORE} is supported only for historical compatibility. Since +this affects every command in the makefile, it is not very useful; we +recommend you use the more selective ways to ignore errors in specific +commands. @xref{Errors, ,Errors in Commands}. + +@findex .LOW_RESOLUTION_TIME +@item .LOW_RESOLUTION_TIME + +If you specify prerequisites for @code{.LOW_RESOLUTION_TIME}, +@command{make} assumes that these files are created by commands that +generate low resolution time stamps. The commands for +@code{.LOW_RESOLUTION_TIME} are not meaningful. + +The high resolution file time stamps of many modern hosts lessen the +chance of @command{make} incorrectly concluding that a file is up to +date. Unfortunately, these hosts provide no way to set a high +resolution file time stamp, so commands like @samp{cp -p} that +explicitly set a file's time stamp must discard its subsecond part. If +a file is created by such a command, you should list it as a +prerequisite of @code{.LOW_RESOLUTION_TIME} so that @command{make} does +not mistakenly conclude that the file is out of date. For example: + +@example +@group +.LOW_RESOLUTION_TIME: dst +dst: src + cp -p src dst +@end group +@end example + +Since @samp{cp -p} discards the subsecond part of @file{src}'s time +stamp, @file{dst} is typically slightly older than @file{src} even when +it is up to date. The @code{.LOW_RESOLUTION_TIME} line causes +@command{make} to consider @file{dst} to be up to date if its time stamp +is at the start of the same second that @file{src}'s time stamp is in. + +Due to a limitation of the archive format, archive member time stamps +are always low resolution. You need not list archive members as +prerequisites of @code{.LOW_RESOLUTION_TIME}, as @command{make} does this +automatically. + +@findex .SILENT +@item .SILENT + +If you specify prerequisites for @code{.SILENT}, then @code{make} will +not print the commands to remake those particular files before executing +them. The commands for @code{.SILENT} are not meaningful. + +If mentioned as a target with no prerequisites, @code{.SILENT} says not +to print any commands before executing them. This usage of +@samp{.SILENT} is supported only for historical compatibility. We +recommend you use the more selective ways to silence specific commands. +@xref{Echoing, ,Command Echoing}. If you want to silence all commands +for a particular run of @code{make}, use the @samp{-s} or +@w{@samp{--silent}} option (@pxref{Options Summary}). + +@findex .EXPORT_ALL_VARIABLES +@item .EXPORT_ALL_VARIABLES + +Simply by being mentioned as a target, this tells @code{make} to +export all variables to child processes by default. +@xref{Variables/Recursion, ,Communicating Variables to a +Sub-@code{make}}. + +@findex .NOTPARALLEL +@item .NOTPARALLEL +@cindex parallel execution, overriding + +If @code{.NOTPARALLEL} is mentioned as a target, then this invocation of +@code{make} will be run serially, even if the @samp{-j} option is +given. Any recursively invoked @code{make} command will still be run in +parallel (unless its makefile contains this target). Any prerequisites +on this target are ignored. +@end table + +Any defined implicit rule suffix also counts as a special target if it +appears as a target, and so does the concatenation of two suffixes, such +as @samp{.c.o}. These targets are suffix rules, an obsolete way of +defining implicit rules (but a way still widely used). In principle, any +target name could be special in this way if you break it in two and add +both pieces to the suffix list. In practice, suffixes normally begin with +@samp{.}, so these special target names also begin with @samp{.}. +@xref{Suffix Rules, ,Old-Fashioned Suffix Rules}. + +@node Multiple Targets, Multiple Rules, Special Targets, Rules +@section Multiple Targets in a Rule +@cindex multiple targets +@cindex several targets in a rule +@cindex targets, multiple +@cindex rule, with multiple targets + +A rule with multiple targets is equivalent to writing many rules, each with +one target, and all identical aside from that. The same commands apply to +all the targets, but their effects may vary because you can substitute the +actual target name into the command using @samp{$@@}. The rule contributes +the same prerequisites to all the targets also. + +This is useful in two cases. + +@itemize @bullet +@item +You want just prerequisites, no commands. For example: + +@example +kbd.o command.o files.o: command.h +@end example + +@noindent +gives an additional prerequisite to each of the three object files +mentioned. + +@item +Similar commands work for all the targets. The commands do not need +to be absolutely identical, since the automatic variable @samp{$@@} +can be used to substitute the particular target to be remade into the +commands (@pxref{Automatic, ,Automatic Variables}). For example: + +@example +@group +bigoutput littleoutput : text.g + generate text.g -$(subst output,,$@@) > $@@ +@end group +@end example +@findex subst + +@noindent +is equivalent to + +@example +bigoutput : text.g + generate text.g -big > bigoutput +littleoutput : text.g + generate text.g -little > littleoutput +@end example + +@noindent +Here we assume the hypothetical program @code{generate} makes two +types of output, one if given @samp{-big} and one if given +@samp{-little}. +@xref{Text Functions, ,Functions for String Substitution and Analysis}, +for an explanation of the @code{subst} function. +@end itemize + +Suppose you would like to vary the prerequisites according to the target, +much as the variable @samp{$@@} allows you to vary the commands. +You cannot do this with multiple targets in an ordinary rule, but you can +do it with a @dfn{static pattern rule}. +@xref{Static Pattern, ,Static Pattern Rules}. + +@node Multiple Rules, Static Pattern, Multiple Targets, Rules +@section Multiple Rules for One Target +@cindex multiple rules for one target +@cindex several rules for one target +@cindex rule, multiple for one target +@cindex target, multiple rules for one + +One file can be the target of several rules. All the prerequisites +mentioned in all the rules are merged into one list of prerequisites for +the target. If the target is older than any prerequisite from any rule, +the commands are executed. + +There can only be one set of commands to be executed for a file. If +more than one rule gives commands for the same file, @code{make} uses +the last set given and prints an error message. (As a special case, +if the file's name begins with a dot, no error message is printed. +This odd behavior is only for compatibility with other implementations +of @code{make}... you should avoid using it). Occasionally it is +useful to have the same target invoke multiple commands which are +defined in different parts of your makefile; you can use +@dfn{double-colon rules} (@pxref{Double-Colon}) for this. + +An extra rule with just prerequisites can be used to give a few extra +prerequisites to many files at once. For example, makefiles often +have a variable, such as @code{objects}, containing a list of all the +compiler output files in the system being made. An easy way to say +that all of them must be recompiled if @file{config.h} changes is to +write the following: + +@example +objects = foo.o bar.o +foo.o : defs.h +bar.o : defs.h test.h +$(objects) : config.h +@end example + +This could be inserted or taken out without changing the rules that really +specify how to make the object files, making it a convenient form to use if +you wish to add the additional prerequisite intermittently. + +Another wrinkle is that the additional prerequisites could be specified with +a variable that you set with a command argument to @code{make} +(@pxref{Overriding, ,Overriding Variables}). For example, + +@example +@group +extradeps= +$(objects) : $(extradeps) +@end group +@end example + +@noindent +means that the command @samp{make extradeps=foo.h} will consider +@file{foo.h} as a prerequisite of each object file, but plain @samp{make} +will not. + +If none of the explicit rules for a target has commands, then @code{make} +searches for an applicable implicit rule to find some commands +@pxref{Implicit Rules, ,Using Implicit Rules}). + +@node Static Pattern, Double-Colon, Multiple Rules, Rules +@section Static Pattern Rules +@cindex static pattern rule +@cindex rule, static pattern +@cindex pattern rules, static (not implicit) +@cindex varying prerequisites +@cindex prerequisites, varying (static pattern) + +@dfn{Static pattern rules} are rules which specify multiple targets and +construct the prerequisite names for each target based on the target name. +They are more general than ordinary rules with multiple targets because the +targets do not have to have identical prerequisites. Their prerequisites must +be @emph{analogous}, but not necessarily @emph{identical}. + +@menu +* Static Usage:: The syntax of static pattern rules. +* Static versus Implicit:: When are they better than implicit rules? +@end menu + +@node Static Usage, Static versus Implicit, Static Pattern, Static Pattern +@subsection Syntax of Static Pattern Rules +@cindex static pattern rule, syntax of +@cindex pattern rules, static, syntax of + +Here is the syntax of a static pattern rule: + +@example +@var{targets} @dots{}: @var{target-pattern}: @var{prereq-patterns} @dots{} + @var{commands} + @dots{} +@end example + +@noindent +The @var{targets} list specifies the targets that the rule applies to. +The targets can contain wildcard characters, just like the targets of +ordinary rules (@pxref{Wildcards, ,Using Wildcard Characters in File +Names}). + +@cindex target pattern, static (not implicit) +@cindex stem +The @var{target-pattern} and @var{prereq-patterns} say how to compute the +prerequisites of each target. Each target is matched against the +@var{target-pattern} to extract a part of the target name, called the +@dfn{stem}. This stem is substituted into each of the @var{prereq-patterns} +to make the prerequisite names (one from each @var{prereq-pattern}). + +Each pattern normally contains the character @samp{%} just once. When the +@var{target-pattern} matches a target, the @samp{%} can match any part of +the target name; this part is called the @dfn{stem}. The rest of the +pattern must match exactly. For example, the target @file{foo.o} matches +the pattern @samp{%.o}, with @samp{foo} as the stem. The targets +@file{foo.c} and @file{foo.out} do not match that pattern.@refill + +@cindex prerequisite pattern, static (not implicit) +The prerequisite names for each target are made by substituting the stem +for the @samp{%} in each prerequisite pattern. For example, if one +prerequisite pattern is @file{%.c}, then substitution of the stem +@samp{foo} gives the prerequisite name @file{foo.c}. It is legitimate +to write a prerequisite pattern that does not contain @samp{%}; then this +prerequisite is the same for all targets. + +@cindex @code{%}, quoting in static pattern +@cindex @code{%}, quoting with @code{\} (backslash) +@cindex @code{\} (backslash), to quote @code{%} +@cindex backslash (@code{\}), to quote @code{%} +@cindex quoting @code{%}, in static pattern +@samp{%} characters in pattern rules can be quoted with preceding +backslashes (@samp{\}). Backslashes that would otherwise quote @samp{%} +characters can be quoted with more backslashes. Backslashes that quote +@samp{%} characters or other backslashes are removed from the pattern +before it is compared to file names or has a stem substituted into it. +Backslashes that are not in danger of quoting @samp{%} characters go +unmolested. For example, the pattern @file{the\%weird\\%pattern\\} has +@samp{the%weird\} preceding the operative @samp{%} character, and +@samp{pattern\\} following it. The final two backslashes are left alone +because they cannot affect any @samp{%} character.@refill + +Here is an example, which compiles each of @file{foo.o} and @file{bar.o} +from the corresponding @file{.c} file: + +@example +@group +objects = foo.o bar.o + +all: $(objects) + +$(objects): %.o: %.c + $(CC) -c $(CFLAGS) $< -o $@@ +@end group +@end example + +@noindent +Here @samp{$<} is the automatic variable that holds the name of the +prerequisite and @samp{$@@} is the automatic variable that holds the name +of the target; see @ref{Automatic, , Automatic Variables}. + +Each target specified must match the target pattern; a warning is issued +for each target that does not. If you have a list of files, only some of +which will match the pattern, you can use the @code{filter} function to +remove nonmatching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}): + +@example +files = foo.elc bar.o lose.o + +$(filter %.o,$(files)): %.o: %.c + $(CC) -c $(CFLAGS) $< -o $@@ +$(filter %.elc,$(files)): %.elc: %.el + emacs -f batch-byte-compile $< +@end example + +@noindent +In this example the result of @samp{$(filter %.o,$(files))} is +@file{bar.o lose.o}, and the first static pattern rule causes each of +these object files to be updated by compiling the corresponding C source +file. The result of @w{@samp{$(filter %.elc,$(files))}} is +@file{foo.elc}, so that file is made from @file{foo.el}.@refill + +Another example shows how to use @code{$*} in static pattern rules: +@vindex $*@r{, and static pattern} + +@example +@group +bigoutput littleoutput : %output : text.g + generate text.g -$* > $@@ +@end group +@end example + +@noindent +When the @code{generate} command is run, @code{$*} will expand to the +stem, either @samp{big} or @samp{little}. + +@node Static versus Implicit, , Static Usage, Static Pattern +@subsection Static Pattern Rules versus Implicit Rules +@cindex rule, static pattern versus implicit +@cindex static pattern rule, versus implicit + +A static pattern rule has much in common with an implicit rule defined as a +pattern rule (@pxref{Pattern Rules, ,Defining and Redefining Pattern Rules}). +Both have a pattern for the target and patterns for constructing the +names of prerequisites. The difference is in how @code{make} decides +@emph{when} the rule applies. + +An implicit rule @emph{can} apply to any target that matches its pattern, +but it @emph{does} apply only when the target has no commands otherwise +specified, and only when the prerequisites can be found. If more than one +implicit rule appears applicable, only one applies; the choice depends on +the order of rules. + +By contrast, a static pattern rule applies to the precise list of targets +that you specify in the rule. It cannot apply to any other target and it +invariably does apply to each of the targets specified. If two conflicting +rules apply, and both have commands, that's an error. + +The static pattern rule can be better than an implicit rule for these +reasons: + +@itemize @bullet +@item +You may wish to override the usual implicit rule for a few +files whose names cannot be categorized syntactically but +can be given in an explicit list. + +@item +If you cannot be sure of the precise contents of the directories +you are using, you may not be sure which other irrelevant files +might lead @code{make} to use the wrong implicit rule. The choice +might depend on the order in which the implicit rule search is done. +With static pattern rules, there is no uncertainty: each rule applies +to precisely the targets specified. +@end itemize + +@node Double-Colon, Automatic Prerequisites, Static Pattern, Rules +@section Double-Colon Rules +@cindex double-colon rules +@cindex rule, double-colon (@code{::}) +@cindex multiple rules for one target (@code{::}) +@cindex @code{::} rules (double-colon) + +@dfn{Double-colon} rules are rules written with @samp{::} instead of +@samp{:} after the target names. They are handled differently from +ordinary rules when the same target appears in more than one rule. + +When a target appears in multiple rules, all the rules must be the same +type: all ordinary, or all double-colon. If they are double-colon, each +of them is independent of the others. Each double-colon rule's commands +are executed if the target is older than any prerequisites of that rule. +If there are no prerequisites for that rule, its commands are always +executed (even if the target already exists). This can result in +executing none, any, or all of the double-colon rules. + +Double-colon rules with the same target are in fact completely separate +from one another. Each double-colon rule is processed individually, just +as rules with different targets are processed. + +The double-colon rules for a target are executed in the order they appear +in the makefile. However, the cases where double-colon rules really make +sense are those where the order of executing the commands would not matter. + +Double-colon rules are somewhat obscure and not often very useful; they +provide a mechanism for cases in which the method used to update a target +differs depending on which prerequisite files caused the update, and such +cases are rare. + +Each double-colon rule should specify commands; if it does not, an +implicit rule will be used if one applies. +@xref{Implicit Rules, ,Using Implicit Rules}. + +@node Automatic Prerequisites, , Double-Colon, Rules +@section Generating Prerequisites Automatically +@cindex prerequisites, automatic generation +@cindex automatic generation of prerequisites +@cindex generating prerequisites automatically + +In the makefile for a program, many of the rules you need to write often +say only that some object file depends on some header +file. For example, if @file{main.c} uses @file{defs.h} via an +@code{#include}, you would write: + +@example +main.o: defs.h +@end example + +@noindent +You need this rule so that @code{make} knows that it must remake +@file{main.o} whenever @file{defs.h} changes. You can see that for a +large program you would have to write dozens of such rules in your +makefile. And, you must always be very careful to update the makefile +every time you add or remove an @code{#include}. +@cindex @code{#include} + +@cindex @code{-M} (to compiler) +To avoid this hassle, most modern C compilers can write these rules for +you, by looking at the @code{#include} lines in the source files. +Usually this is done with the @samp{-M} option to the compiler. +For example, the command: + +@example +cc -M main.c +@end example + +@noindent +generates the output: + +@example +main.o : main.c defs.h +@end example + +@noindent +Thus you no longer have to write all those rules yourself. +The compiler will do it for you. + +Note that such a prerequisite constitutes mentioning @file{main.o} in a +makefile, so it can never be considered an intermediate file by implicit +rule search. This means that @code{make} won't ever remove the file +after using it; @pxref{Chained Rules, ,Chains of Implicit Rules}. + +@cindex @code{make depend} +With old @code{make} programs, it was traditional practice to use this +compiler feature to generate prerequisites on demand with a command like +@samp{make depend}. That command would create a file @file{depend} +containing all the automatically-generated prerequisites; then the +makefile could use @code{include} to read them in (@pxref{Include}). + +In GNU @code{make}, the feature of remaking makefiles makes this +practice obsolete---you need never tell @code{make} explicitly to +regenerate the prerequisites, because it always regenerates any makefile +that is out of date. @xref{Remaking Makefiles}. + +The practice we recommend for automatic prerequisite generation is to have +one makefile corresponding to each source file. For each source file +@file{@var{name}.c} there is a makefile @file{@var{name}.d} which lists +what files the object file @file{@var{name}.o} depends on. That way +only the source files that have changed need to be rescanned to produce +the new prerequisites. + +Here is the pattern rule to generate a file of prerequisites (i.e., a makefile) +called @file{@var{name}.d} from a C source file called @file{@var{name}.c}: + +@smallexample +@group +%.d: %.c + @set -e; rm -f $@@; \ + $(CC) -M $(CPPFLAGS) $< > $@@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@@ : ,g' < $@@.$$$$ > $@@; \ + rm -f $@@.$$$$ +@end group +@end smallexample + +@noindent +@xref{Pattern Rules}, for information on defining pattern rules. The +@samp{-e} flag to the shell causes it to exit immediately if the +@code{$(CC)} command (or any other command) fails (exits with a +nonzero status). +@cindex @code{-e} (shell flag) + +@cindex @code{-MM} (to GNU compiler) +With the GNU C compiler, you may wish to use the @samp{-MM} flag instead +of @samp{-M}. This omits prerequisites on system header files. +@xref{Preprocessor Options, , Options Controlling the Preprocessor, +gcc.info, Using GNU CC}, for details. + +@cindex @code{sed} (shell command) +The purpose of the @code{sed} command is to translate (for example): + +@example +main.o : main.c defs.h +@end example + +@noindent +into: + +@example +main.o main.d : main.c defs.h +@end example + +@noindent +@cindex @code{.d} +This makes each @samp{.d} file depend on all the source and header files +that the corresponding @samp{.o} file depends on. @code{make} then +knows it must regenerate the prerequisites whenever any of the source or +header files changes. + +Once you've defined the rule to remake the @samp{.d} files, +you then use the @code{include} directive to read them all in. +@xref{Include}. For example: + +@example +@group +sources = foo.c bar.c + +include $(sources:.c=.d) +@end group +@end example + +@noindent +(This example uses a substitution variable reference to translate the +list of source files @samp{foo.c bar.c} into a list of prerequisite +makefiles, @samp{foo.d bar.d}. @xref{Substitution Refs}, for full +information on substitution references.) Since the @samp{.d} files are +makefiles like any others, @code{make} will remake them as necessary +with no further work from you. @xref{Remaking Makefiles}. + +Note that the @samp{.d} files contain target definitions; you should +be sure to place the @code{include} directive @emph{after} the first, +default target in your makefiles or run the risk of having a random +object file become the default target. +@xref{How Make Works}. + +@node Commands, Using Variables, Rules, Top +@chapter Writing the Commands in Rules +@cindex commands, how to write +@cindex rule commands +@cindex writing rule commands + +The commands of a rule consist of shell command lines to be executed one +by one. Each command line must start with a tab, except that the first +command line may be attached to the target-and-prerequisites line with a +semicolon in between. Blank lines and lines of just comments may appear +among the command lines; they are ignored. (But beware, an apparently +``blank'' line that begins with a tab is @emph{not} blank! It is an +empty command; @pxref{Empty Commands}.) + +Users use many different shell programs, but commands in makefiles are +always interpreted by @file{/bin/sh} unless the makefile specifies +otherwise. @xref{Execution, ,Command Execution}. + +@cindex comments, in commands +@cindex commands, comments in +@cindex @code{#} (comments), in commands +The shell that is in use determines whether comments can be written on +command lines, and what syntax they use. When the shell is +@file{/bin/sh}, a @samp{#} starts a comment that extends to the end of +the line. The @samp{#} does not have to be at the beginning of a line. +Text on a line before a @samp{#} is not part of the comment. + +@menu +* Echoing:: How to control when commands are echoed. +* Execution:: How commands are executed. +* Parallel:: How commands can be executed in parallel. +* Errors:: What happens after a command execution error. +* Interrupts:: What happens when a command is interrupted. +* Recursion:: Invoking @code{make} from makefiles. +* Sequences:: Defining canned sequences of commands. +* Empty Commands:: Defining useful, do-nothing commands. +@end menu + +@node Echoing, Execution, Commands, Commands +@section Command Echoing +@cindex echoing of commands +@cindex silent operation +@cindex @code{@@} (in commands) +@cindex commands, echoing +@cindex printing of commands + +Normally @code{make} prints each command line before it is executed. +We call this @dfn{echoing} because it gives the appearance that you +are typing the commands yourself. + +When a line starts with @samp{@@}, the echoing of that line is suppressed. +The @samp{@@} is discarded before the command is passed to the shell. +Typically you would use this for a command whose only effect is to print +something, such as an @code{echo} command to indicate progress through +the makefile: + +@example +@@echo About to make distribution files +@end example + +@cindex @code{-n} +@cindex @code{--just-print} +@cindex @code{--dry-run} +@cindex @code{--recon} +When @code{make} is given the flag @samp{-n} or @samp{--just-print} +it only echoes commands, it won't execute them. @xref{Options Summary, +,Summary of Options}. In this case and only this case, even the +commands starting with @samp{@@} are printed. This flag is useful for +finding out which commands @code{make} thinks are necessary without +actually doing them. + +@cindex @code{-s} +@cindex @code{--silent} +@cindex @code{--quiet} +@findex .SILENT +The @samp{-s} or @samp{--silent} +flag to @code{make} prevents all echoing, as if all commands +started with @samp{@@}. A rule in the makefile for the special target +@code{.SILENT} without prerequisites has the same effect +(@pxref{Special Targets, ,Special Built-in Target Names}). +@code{.SILENT} is essentially obsolete since @samp{@@} is more flexible.@refill + +@node Execution, Parallel, Echoing, Commands +@section Command Execution +@cindex commands, execution +@cindex execution, of commands +@cindex shell command, execution +@vindex SHELL @r{(command execution)} + +When it is time to execute commands to update a target, they are executed +by making a new subshell for each line. (In practice, @code{make} may +take shortcuts that do not affect the results.) + +@cindex @code{cd} (shell command) +@strong{Please note:} this implies that shell commands such as @code{cd} +that set variables local to each process will not affect the following +command lines. @footnote{On MS-DOS, the value of current working +directory is @strong{global}, so changing it @emph{will} affect the +following command lines on those systems.} If you want to use @code{cd} +to affect the next command, put the two on a single line with a +semicolon between them. Then @code{make} will consider them a single +command and pass them, together, to a shell which will execute them in +sequence. For example: + +@example +foo : bar/lose + cd bar; gobble lose > ../foo +@end example + +@cindex commands, backslash (@code{\}) in +@cindex commands, quoting newlines in +@cindex backslash (@code{\}), in commands +@cindex @code{\} (backslash), in commands +@cindex quoting newline, in commands +@cindex newline, quoting, in commands +If you would like to split a single shell command into multiple lines of +text, you must use a backslash at the end of all but the last subline. +Such a sequence of lines is combined into a single line, by deleting the +backslash-newline sequences, before passing it to the shell. Thus, the +following is equivalent to the preceding example: + +@example +@group +foo : bar/lose + cd bar; \ + gobble lose > ../foo +@end group +@end example + +@vindex SHELL +The program used as the shell is taken from the variable @code{SHELL}. +By default, the program @file{/bin/sh} is used. + +@vindex COMSPEC +On MS-DOS, if @code{SHELL} is not set, the value of the variable +@code{COMSPEC} (which is always set) is used instead. + +@cindex @code{SHELL}, MS-DOS specifics +The processing of lines that set the variable @code{SHELL} in Makefiles +is different on MS-DOS. The stock shell, @file{command.com}, is +ridiculously limited in its functionality and many users of @code{make} +tend to install a replacement shell. Therefore, on MS-DOS, @code{make} +examines the value of @code{SHELL}, and changes its behavior based on +whether it points to a Unix-style or DOS-style shell. This allows +reasonable functionality even if @code{SHELL} points to +@file{command.com}. + +If @code{SHELL} points to a Unix-style shell, @code{make} on MS-DOS +additionally checks whether that shell can indeed be found; if not, it +ignores the line that sets @code{SHELL}. In MS-DOS, GNU @code{make} +searches for the shell in the following places: + +@enumerate +@item +In the precise place pointed to by the value of @code{SHELL}. For +example, if the makefile specifies @samp{SHELL = /bin/sh}, @code{make} +will look in the directory @file{/bin} on the current drive. + +@item +In the current directory. + +@item +In each of the directories in the @code{PATH} variable, in order. + +@end enumerate + +In every directory it examines, @code{make} will first look for the +specific file (@file{sh} in the example above). If this is not found, +it will also look in that directory for that file with one of the known +extensions which identify executable files. For example @file{.exe}, +@file{.com}, @file{.bat}, @file{.btm}, @file{.sh}, and some others. + +If any of these attempts is successful, the value of @code{SHELL} will +be set to the full pathname of the shell as found. However, if none of +these is found, the value of @code{SHELL} will not be changed, and thus +the line that sets it will be effectively ignored. This is so +@code{make} will only support features specific to a Unix-style shell if +such a shell is actually installed on the system where @code{make} runs. + +Note that this extended search for the shell is limited to the cases +where @code{SHELL} is set from the Makefile; if it is set in the +environment or command line, you are expected to set it to the full +pathname of the shell, exactly as things are on Unix. + +The effect of the above DOS-specific processing is that a Makefile that +says @samp{SHELL = /bin/sh} (as many Unix makefiles do), will work +on MS-DOS unaltered if you have e.g. @file{sh.exe} installed in some +directory along your @code{PATH}. + +@cindex environment, @code{SHELL} in +Unlike most variables, the variable @code{SHELL} is never set from the +environment. This is because the @code{SHELL} environment variable is +used to specify your personal choice of shell program for interactive +use. It would be very bad for personal choices like this to affect the +functioning of makefiles. @xref{Environment, ,Variables from the +Environment}. However, on MS-DOS and MS-Windows the value of +@code{SHELL} in the environment @strong{is} used, since on those systems +most users do not set this variable, and therefore it is most likely set +specifically to be used by @code{make}. On MS-DOS, if the setting of +@code{SHELL} is not suitable for @code{make}, you can set the variable +@code{MAKESHELL} to the shell that @code{make} should use; this will +override the value of @code{SHELL}. + +@node Parallel, Errors, Execution, Commands +@section Parallel Execution +@cindex commands, execution in parallel +@cindex parallel execution +@cindex execution, in parallel +@cindex job slots +@cindex @code{-j} +@cindex @code{--jobs} + +GNU @code{make} knows how to execute several commands at once. +Normally, @code{make} will execute only one command at a time, waiting +for it to finish before executing the next. However, the @samp{-j} or +@samp{--jobs} option tells @code{make} to execute many commands +simultaneously.@refill + +On MS-DOS, the @samp{-j} option has no effect, since that system doesn't +support multi-processing. + +If the @samp{-j} option is followed by an integer, this is the number of +commands to execute at once; this is called the number of @dfn{job slots}. +If there is nothing looking like an integer after the @samp{-j} option, +there is no limit on the number of job slots. The default number of job +slots is one, which means serial execution (one thing at a time). + +One unpleasant consequence of running several commands simultaneously is +that output generated by the commands appears whenever each command +sends it, so messages from different commands may be interspersed. + +Another problem is that two processes cannot both take input from the +same device; so to make sure that only one command tries to take input +from the terminal at once, @code{make} will invalidate the standard +input streams of all but one running command. This means that +attempting to read from standard input will usually be a fatal error (a +@samp{Broken pipe} signal) for most child processes if there are +several. +@cindex broken pipe +@cindex standard input + +It is unpredictable which command will have a valid standard input stream +(which will come from the terminal, or wherever you redirect the standard +input of @code{make}). The first command run will always get it first, and +the first command started after that one finishes will get it next, and so +on. + +We will change how this aspect of @code{make} works if we find a better +alternative. In the mean time, you should not rely on any command using +standard input at all if you are using the parallel execution feature; but +if you are not using this feature, then standard input works normally in +all commands. + +Finally, handling recursive @code{make} invocations raises issues. For +more information on this, see +@ref{Options/Recursion, ,Communicating Options to a Sub-@code{make}}. + +If a command fails (is killed by a signal or exits with a nonzero +status), and errors are not ignored for that command +(@pxref{Errors, ,Errors in Commands}), +the remaining command lines to remake the same target will not be run. +If a command fails and the @samp{-k} or @samp{--keep-going} +option was not given +(@pxref{Options Summary, ,Summary of Options}), +@code{make} aborts execution. If make +terminates for any reason (including a signal) with child processes +running, it waits for them to finish before actually exiting.@refill + +@cindex load average +@cindex limiting jobs based on load +@cindex jobs, limiting based on load +@cindex @code{-l} (load average) +@cindex @code{--max-load} +@cindex @code{--load-average} +When the system is heavily loaded, you will probably want to run fewer jobs +than when it is lightly loaded. You can use the @samp{-l} option to tell +@code{make} to limit the number of jobs to run at once, based on the load +average. The @samp{-l} or @samp{--max-load} +option is followed by a floating-point number. For +example, + +@example +-l 2.5 +@end example + +@noindent +will not let @code{make} start more than one job if the load average is +above 2.5. The @samp{-l} option with no following number removes the +load limit, if one was given with a previous @samp{-l} option.@refill + +More precisely, when @code{make} goes to start up a job, and it already has +at least one job running, it checks the current load average; if it is not +lower than the limit given with @samp{-l}, @code{make} waits until the load +average goes below that limit, or until all the other jobs finish. + +By default, there is no load limit. + +@node Errors, Interrupts, Parallel, Commands +@section Errors in Commands +@cindex errors (in commands) +@cindex commands, errors in +@cindex exit status (errors) + +After each shell command returns, @code{make} looks at its exit status. +If the command completed successfully, the next command line is executed +in a new shell; after the last command line is finished, the rule is +finished. + +If there is an error (the exit status is nonzero), @code{make} gives up on +the current rule, and perhaps on all rules. + +Sometimes the failure of a certain command does not indicate a problem. +For example, you may use the @code{mkdir} command to ensure that a +directory exists. If the directory already exists, @code{mkdir} will +report an error, but you probably want @code{make} to continue regardless. + +@cindex @code{-} (in commands) +To ignore errors in a command line, write a @samp{-} at the beginning of +the line's text (after the initial tab). The @samp{-} is discarded before +the command is passed to the shell for execution. + +For example, + +@example +@group +clean: + -rm -f *.o +@end group +@end example +@cindex @code{rm} (shell command) + +@noindent +This causes @code{rm} to continue even if it is unable to remove a file. + +@cindex @code{-i} +@cindex @code{--ignore-errors} +@findex .IGNORE +When you run @code{make} with the @samp{-i} or @samp{--ignore-errors} +flag, errors are ignored in all commands of all rules. A rule in the +makefile for the special target @code{.IGNORE} has the same effect, if +there are no prerequisites. These ways of ignoring errors are obsolete +because @samp{-} is more flexible. + +When errors are to be ignored, because of either a @samp{-} or the +@samp{-i} flag, @code{make} treats an error return just like success, +except that it prints out a message that tells you the status code +the command exited with, and says that the error has been ignored. + +When an error happens that @code{make} has not been told to ignore, +it implies that the current target cannot be correctly remade, and neither +can any other that depends on it either directly or indirectly. No further +commands will be executed for these targets, since their preconditions +have not been achieved. + + +@cindex @code{-k} +@cindex @code{--keep-going} +Normally @code{make} gives up immediately in this circumstance, returning a +nonzero status. However, if the @samp{-k} or @samp{--keep-going} +flag is specified, @code{make} +continues to consider the other prerequisites of the pending targets, +remaking them if necessary, before it gives up and returns nonzero status. +For example, after an error in compiling one object file, @samp{make -k} +will continue compiling other object files even though it already knows +that linking them will be impossible. @xref{Options Summary, ,Summary of Options}. + +The usual behavior assumes that your purpose is to get the specified +targets up to date; once @code{make} learns that this is impossible, it +might as well report the failure immediately. The @samp{-k} option says +that the real purpose is to test as many of the changes made in the +program as possible, perhaps to find several independent problems so +that you can correct them all before the next attempt to compile. This +is why Emacs' @code{compile} command passes the @samp{-k} flag by +default. +@cindex Emacs (@code{M-x compile}) + +@findex .DELETE_ON_ERROR +@cindex deletion of target files +@cindex removal of target files +@cindex target, deleting on error +Usually when a command fails, if it has changed the target file at all, +the file is corrupted and cannot be used---or at least it is not +completely updated. Yet the file's time stamp says that it is now up to +date, so the next time @code{make} runs, it will not try to update that +file. The situation is just the same as when the command is killed by a +signal; @pxref{Interrupts}. So generally the right thing to do is to +delete the target file if the command fails after beginning to change +the file. @code{make} will do this if @code{.DELETE_ON_ERROR} appears +as a target. This is almost always what you want @code{make} to do, but +it is not historical practice; so for compatibility, you must explicitly +request it. + +@node Interrupts, Recursion, Errors, Commands +@section Interrupting or Killing @code{make} +@cindex interrupt +@cindex signal +@cindex deletion of target files +@cindex removal of target files +@cindex target, deleting on interrupt +@cindex killing (interruption) + +If @code{make} gets a fatal signal while a command is executing, it may +delete the target file that the command was supposed to update. This is +done if the target file's last-modification time has changed since +@code{make} first checked it. + +The purpose of deleting the target is to make sure that it is remade from +scratch when @code{make} is next run. Why is this? Suppose you type +@kbd{Ctrl-c} while a compiler is running, and it has begun to write an +object file @file{foo.o}. The @kbd{Ctrl-c} kills the compiler, resulting +in an incomplete file whose last-modification time is newer than the source +file @file{foo.c}. But @code{make} also receives the @kbd{Ctrl-c} signal +and deletes this incomplete file. If @code{make} did not do this, the next +invocation of @code{make} would think that @file{foo.o} did not require +updating---resulting in a strange error message from the linker when it +tries to link an object file half of which is missing. + +@findex .PRECIOUS +You can prevent the deletion of a target file in this way by making the +special target @code{.PRECIOUS} depend on it. Before remaking a target, +@code{make} checks to see whether it appears on the prerequisites of +@code{.PRECIOUS}, and thereby decides whether the target should be deleted +if a signal happens. Some reasons why you might do this are that the +target is updated in some atomic fashion, or exists only to record a +modification-time (its contents do not matter), or must exist at all +times to prevent other sorts of trouble. + +@node Recursion, Sequences, Interrupts, Commands +@section Recursive Use of @code{make} +@cindex recursion +@cindex subdirectories, recursion for + +Recursive use of @code{make} means using @code{make} as a command in a +makefile. This technique is useful when you want separate makefiles for +various subsystems that compose a larger system. For example, suppose you +have a subdirectory @file{subdir} which has its own makefile, and you would +like the containing directory's makefile to run @code{make} on the +subdirectory. You can do it by writing this: + +@example +subsystem: + cd subdir && $(MAKE) +@end example + +@noindent +or, equivalently, this (@pxref{Options Summary, ,Summary of Options}): + +@example +subsystem: + $(MAKE) -C subdir +@end example +@cindex @code{-C} +@cindex @code{--directory} + +You can write recursive @code{make} commands just by copying this example, +but there are many things to know about how they work and why, and about +how the sub-@code{make} relates to the top-level @code{make}. + +For your convenience, GNU @code{make} sets the variable @code{CURDIR} to +the pathname of the current working directory for you. If @code{-C} is +in effect, it will contain the path of the new directory, not the +original. The value has the same precedence it would have if it were +set in the makefile (by default, an environment variable @code{CURDIR} +will not override this value). Note that setting this variable has no +effect on the operation of @code{make} + +@menu +* MAKE Variable:: The special effects of using @samp{$(MAKE)}. +* Variables/Recursion:: How to communicate variables to a sub-@code{make}. +* Options/Recursion:: How to communicate options to a sub-@code{make}. +* -w Option:: How the @samp{-w} or @samp{--print-directory} option + helps debug use of recursive @code{make} commands. +@end menu + +@node MAKE Variable, Variables/Recursion, Recursion, Recursion +@subsection How the @code{MAKE} Variable Works +@vindex MAKE +@cindex recursion, and @code{MAKE} variable + +Recursive @code{make} commands should always use the variable @code{MAKE}, +not the explicit command name @samp{make}, as shown here: + +@example +@group +subsystem: + cd subdir && $(MAKE) +@end group +@end example + +The value of this variable is the file name with which @code{make} was +invoked. If this file name was @file{/bin/make}, then the command executed +is @samp{cd subdir && /bin/make}. If you use a special version of +@code{make} to run the top-level makefile, the same special version will be +executed for recursive invocations. +@cindex @code{cd} (shell command) + +As a special feature, using the variable @code{MAKE} in the commands of +a rule alters the effects of the @samp{-t} (@samp{--touch}), @samp{-n} +(@samp{--just-print}), or @samp{-q} (@w{@samp{--question}}) option. +Using the @code{MAKE} variable has the same effect as using a @samp{+} +character at the beginning of the command line. @xref{Instead of +Execution, ,Instead of Executing the Commands}.@refill + +Consider the command @samp{make -t} in the above example. (The +@samp{-t} option marks targets as up to date without actually running +any commands; see @ref{Instead of Execution}.) Following the usual +definition of @samp{-t}, a @samp{make -t} command in the example would +create a file named @file{subsystem} and do nothing else. What you +really want it to do is run @samp{@w{cd subdir &&} @w{make -t}}; but that would +require executing the command, and @samp{-t} says not to execute +commands.@refill +@cindex @code{-t}, and recursion +@cindex recursion, and @code{-t} +@cindex @code{--touch}, and recursion + +The special feature makes this do what you want: whenever a command +line of a rule contains the variable @code{MAKE}, the flags @samp{-t}, +@samp{-n} and @samp{-q} do not apply to that line. Command lines +containing @code{MAKE} are executed normally despite the presence of a +flag that causes most commands not to be run. The usual +@code{MAKEFLAGS} mechanism passes the flags to the sub-@code{make} +(@pxref{Options/Recursion, ,Communicating Options to a +Sub-@code{make}}), so your request to touch the files, or print the +commands, is propagated to the subsystem.@refill + +@node Variables/Recursion, Options/Recursion, MAKE Variable, Recursion +@subsection Communicating Variables to a Sub-@code{make} +@cindex sub-@code{make} +@cindex environment, and recursion +@cindex exporting variables +@cindex variables, environment +@cindex variables, exporting +@cindex recursion, and environment +@cindex recursion, and variables + +Variable values of the top-level @code{make} can be passed to the +sub-@code{make} through the environment by explicit request. These +variables are defined in the sub-@code{make} as defaults, but do not +override what is specified in the makefile used by the sub-@code{make} +makefile unless you use the @samp{-e} switch (@pxref{Options Summary, +,Summary of Options}).@refill + +To pass down, or @dfn{export}, a variable, @code{make} adds the variable +and its value to the environment for running each command. The +sub-@code{make}, in turn, uses the environment to initialize its table +of variable values. @xref{Environment, ,Variables from the +Environment}. + +Except by explicit request, @code{make} exports a variable only if it +is either defined in the environment initially or set on the command +line, and if its name consists only of letters, numbers, and underscores. +Some shells cannot cope with environment variable names consisting of +characters other than letters, numbers, and underscores. + +The special variables @code{SHELL} and @code{MAKEFLAGS} are always +exported (unless you unexport them). +@code{MAKEFILES} is exported if you set it to anything. + +@code{make} automatically passes down variable values that were defined +on the command line, by putting them in the @code{MAKEFLAGS} variable. +@iftex +See the next section. +@end iftex +@ifinfo +@xref{Options/Recursion}. +@end ifinfo + +Variables are @emph{not} normally passed down if they were created by +default by @code{make} (@pxref{Implicit Variables, ,Variables Used by +Implicit Rules}). The sub-@code{make} will define these for +itself.@refill + +@findex export +If you want to export specific variables to a sub-@code{make}, use the +@code{export} directive, like this: + +@example +export @var{variable} @dots{} +@end example + +@noindent +@findex unexport +If you want to @emph{prevent} a variable from being exported, use the +@code{unexport} directive, like this: + +@example +unexport @var{variable} @dots{} +@end example + +@noindent +As a convenience, you can define a variable and export it at the same +time by doing: + +@example +export @var{variable} = value +@end example + +@noindent +has the same result as: + +@example +@var{variable} = value +export @var{variable} +@end example + +@noindent +and + +@example +export @var{variable} := value +@end example + +@noindent +has the same result as: + +@example +@var{variable} := value +export @var{variable} +@end example + +Likewise, + +@example +export @var{variable} += value +@end example + +@noindent +is just like: + +@example +@var{variable} += value +export @var{variable} +@end example + +@noindent +@xref{Appending, ,Appending More Text to Variables}. + +You may notice that the @code{export} and @code{unexport} directives +work in @code{make} in the same way they work in the shell, @code{sh}. + +If you want all variables to be exported by default, you can use +@code{export} by itself: + +@example +export +@end example + +@noindent +This tells @code{make} that variables which are not explicitly mentioned +in an @code{export} or @code{unexport} directive should be exported. +Any variable given in an @code{unexport} directive will still @emph{not} +be exported. If you use @code{export} by itself to export variables by +default, variables whose names contain characters other than +alphanumerics and underscores will not be exported unless specifically +mentioned in an @code{export} directive.@refill + +@findex .EXPORT_ALL_VARIABLES +The behavior elicited by an @code{export} directive by itself was the +default in older versions of GNU @code{make}. If your makefiles depend +on this behavior and you want to be compatible with old versions of +@code{make}, you can write a rule for the special target +@code{.EXPORT_ALL_VARIABLES} instead of using the @code{export} directive. +This will be ignored by old @code{make}s, while the @code{export} +directive will cause a syntax error.@refill +@cindex compatibility in exporting + +Likewise, you can use @code{unexport} by itself to tell @code{make} +@emph{not} to export variables by default. Since this is the default +behavior, you would only need to do this if @code{export} had been used +by itself earlier (in an included makefile, perhaps). You +@strong{cannot} use @code{export} and @code{unexport} by themselves to +have variables exported for some commands and not for others. The last +@code{export} or @code{unexport} directive that appears by itself +determines the behavior for the entire run of @code{make}.@refill + +@vindex MAKELEVEL +@cindex recursion, level of +As a special feature, the variable @code{MAKELEVEL} is changed when it +is passed down from level to level. This variable's value is a string +which is the depth of the level as a decimal number. The value is +@samp{0} for the top-level @code{make}; @samp{1} for a sub-@code{make}, +@samp{2} for a sub-sub-@code{make}, and so on. The incrementation +happens when @code{make} sets up the environment for a command.@refill + +The main use of @code{MAKELEVEL} is to test it in a conditional +directive (@pxref{Conditionals, ,Conditional Parts of Makefiles}); this +way you can write a makefile that behaves one way if run recursively and +another way if run directly by you.@refill + +@vindex MAKEFILES +You can use the variable @code{MAKEFILES} to cause all sub-@code{make} +commands to use additional makefiles. The value of @code{MAKEFILES} is +a whitespace-separated list of file names. This variable, if defined in +the outer-level makefile, is passed down through the environment; then +it serves as a list of extra makefiles for the sub-@code{make} to read +before the usual or specified ones. @xref{MAKEFILES Variable, ,The +Variable @code{MAKEFILES}}.@refill + +@node Options/Recursion, -w Option, Variables/Recursion, Recursion +@subsection Communicating Options to a Sub-@code{make} +@cindex options, and recursion +@cindex recursion, and options + +@vindex MAKEFLAGS +Flags such as @samp{-s} and @samp{-k} are passed automatically to the +sub-@code{make} through the variable @code{MAKEFLAGS}. This variable is +set up automatically by @code{make} to contain the flag letters that +@code{make} received. Thus, if you do @w{@samp{make -ks}} then +@code{MAKEFLAGS} gets the value @samp{ks}.@refill + +As a consequence, every sub-@code{make} gets a value for @code{MAKEFLAGS} +in its environment. In response, it takes the flags from that value and +processes them as if they had been given as arguments. +@xref{Options Summary, ,Summary of Options}. + +@cindex command line variable definitions, and recursion +@cindex variables, command line, and recursion +@cindex recursion, and command line variable definitions +Likewise variables defined on the command line are passed to the +sub-@code{make} through @code{MAKEFLAGS}. Words in the value of +@code{MAKEFLAGS} that contain @samp{=}, @code{make} treats as variable +definitions just as if they appeared on the command line. +@xref{Overriding, ,Overriding Variables}. + +@cindex @code{-C}, and recursion +@cindex @code{-f}, and recursion +@cindex @code{-o}, and recursion +@cindex @code{-W}, and recursion +@cindex @code{--directory}, and recursion +@cindex @code{--file}, and recursion +@cindex @code{--old-file}, and recursion +@cindex @code{--assume-old}, and recursion +@cindex @code{--assume-new}, and recursion +@cindex @code{--new-file}, and recursion +@cindex recursion, and @code{-C} +@cindex recursion, and @code{-f} +@cindex recursion, and @code{-o} +@cindex recursion, and @code{-W} +The options @samp{-C}, @samp{-f}, @samp{-o}, and @samp{-W} are not put +into @code{MAKEFLAGS}; these options are not passed down.@refill + +@cindex @code{-j}, and recursion +@cindex @code{--jobs}, and recursion +@cindex recursion, and @code{-j} +@cindex job slots, and recursion +The @samp{-j} option is a special case (@pxref{Parallel, ,Parallel Execution}). +If you set it to some numeric value @samp{N} and your operating system +supports it (most any UNIX system will; others typically won't), the +parent @code{make} and all the sub-@code{make}s will communicate to +ensure that there are only @samp{N} jobs running at the same time +between them all. Note that any job that is marked recursive +(@pxref{Instead of Execution, ,Instead of Executing the Commands}) +doesn't count against the total jobs (otherwise we could get @samp{N} +sub-@code{make}s running and have no slots left over for any real work!) + +If your operating system doesn't support the above communication, then +@samp{-j 1} is always put into @code{MAKEFLAGS} instead of the value you +specified. This is because if the @w{@samp{-j}} option were passed down +to sub-@code{make}s, you would get many more jobs running in parallel +than you asked for. If you give @samp{-j} with no numeric argument, +meaning to run as many jobs as possible in parallel, this is passed +down, since multiple infinities are no more than one.@refill + +If you do not want to pass the other flags down, you must change the +value of @code{MAKEFLAGS}, like this: + +@example +subsystem: + cd subdir && $(MAKE) MAKEFLAGS= +@end example + +@vindex MAKEOVERRIDES +The command line variable definitions really appear in the variable +@code{MAKEOVERRIDES}, and @code{MAKEFLAGS} contains a reference to this +variable. If you do want to pass flags down normally, but don't want to +pass down the command line variable definitions, you can reset +@code{MAKEOVERRIDES} to empty, like this: + +@example +MAKEOVERRIDES = +@end example + +@noindent +@cindex Arg list too long +@cindex E2BIG +This is not usually useful to do. However, some systems have a small +fixed limit on the size of the environment, and putting so much +information into the value of @code{MAKEFLAGS} can exceed it. If you +see the error message @samp{Arg list too long}, this may be the problem. +@findex .POSIX +@cindex POSIX.2 +(For strict compliance with POSIX.2, changing @code{MAKEOVERRIDES} does +not affect @code{MAKEFLAGS} if the special target @samp{.POSIX} appears +in the makefile. You probably do not care about this.) + +@vindex MFLAGS +A similar variable @code{MFLAGS} exists also, for historical +compatibility. It has the same value as @code{MAKEFLAGS} except that it +does not contain the command line variable definitions, and it always +begins with a hyphen unless it is empty (@code{MAKEFLAGS} begins with a +hyphen only when it begins with an option that has no single-letter +version, such as @samp{--warn-undefined-variables}). @code{MFLAGS} was +traditionally used explicitly in the recursive @code{make} command, like +this: + +@example +subsystem: + cd subdir && $(MAKE) $(MFLAGS) +@end example + +@noindent +but now @code{MAKEFLAGS} makes this usage redundant. If you want your +makefiles to be compatible with old @code{make} programs, use this +technique; it will work fine with more modern @code{make} versions too. + +@cindex setting options from environment +@cindex options, setting from environment +@cindex setting options in makefiles +@cindex options, setting in makefiles +The @code{MAKEFLAGS} variable can also be useful if you want to have +certain options, such as @samp{-k} (@pxref{Options Summary, ,Summary of +Options}), set each time you run @code{make}. You simply put a value for +@code{MAKEFLAGS} in your environment. You can also set @code{MAKEFLAGS} in +a makefile, to specify additional flags that should also be in effect for +that makefile. (Note that you cannot use @code{MFLAGS} this way. That +variable is set only for compatibility; @code{make} does not interpret a +value you set for it in any way.) + +When @code{make} interprets the value of @code{MAKEFLAGS} (either from the +environment or from a makefile), it first prepends a hyphen if the value +does not already begin with one. Then it chops the value into words +separated by blanks, and parses these words as if they were options given +on the command line (except that @samp{-C}, @samp{-f}, @samp{-h}, +@samp{-o}, @samp{-W}, and their long-named versions are ignored; and there +is no error for an invalid option). + +If you do put @code{MAKEFLAGS} in your environment, you should be sure not +to include any options that will drastically affect the actions of +@code{make} and undermine the purpose of makefiles and of @code{make} +itself. For instance, the @samp{-t}, @samp{-n}, and @samp{-q} options, if +put in one of these variables, could have disastrous consequences and would +certainly have at least surprising and probably annoying effects.@refill + +@node -w Option, , Options/Recursion, Recursion +@subsection The @samp{--print-directory} Option +@cindex directories, printing them +@cindex printing directories +@cindex recursion, and printing directories + +If you use several levels of recursive @code{make} invocations, the +@samp{-w} or @w{@samp{--print-directory}} option can make the output a +lot easier to understand by showing each directory as @code{make} +starts processing it and as @code{make} finishes processing it. For +example, if @samp{make -w} is run in the directory @file{/u/gnu/make}, +@code{make} will print a line of the form:@refill + +@example +make: Entering directory `/u/gnu/make'. +@end example + +@noindent +before doing anything else, and a line of the form: + +@example +make: Leaving directory `/u/gnu/make'. +@end example + +@noindent +when processing is completed. + +@cindex @code{-C}, and @code{-w} +@cindex @code{--directory}, and @code{--print-directory} +@cindex recursion, and @code{-w} +@cindex @code{-w}, and @code{-C} +@cindex @code{-w}, and recursion +@cindex @code{--print-directory}, and @code{--directory} +@cindex @code{--print-directory}, and recursion +@cindex @code{--no-print-directory} +@cindex @code{--print-directory}, disabling +@cindex @code{-w}, disabling +Normally, you do not need to specify this option because @samp{make} +does it for you: @samp{-w} is turned on automatically when you use the +@samp{-C} option, and in sub-@code{make}s. @code{make} will not +automatically turn on @samp{-w} if you also use @samp{-s}, which says to +be silent, or if you use @samp{--no-print-directory} to explicitly +disable it. + +@node Sequences, Empty Commands, Recursion, Commands +@section Defining Canned Command Sequences +@cindex sequences of commands +@cindex commands, sequences of + +When the same sequence of commands is useful in making various targets, you +can define it as a canned sequence with the @code{define} directive, and +refer to the canned sequence from the rules for those targets. The canned +sequence is actually a variable, so the name must not conflict with other +variable names. + +Here is an example of defining a canned sequence of commands: + +@example +define run-yacc +yacc $(firstword $^) +mv y.tab.c $@@ +endef +@end example +@cindex @code{yacc} + +@noindent +Here @code{run-yacc} is the name of the variable being defined; +@code{endef} marks the end of the definition; the lines in between are the +commands. The @code{define} directive does not expand variable references +and function calls in the canned sequence; the @samp{$} characters, +parentheses, variable names, and so on, all become part of the value of the +variable you are defining. +@xref{Defining, ,Defining Variables Verbatim}, +for a complete explanation of @code{define}. + +The first command in this example runs Yacc on the first prerequisite of +whichever rule uses the canned sequence. The output file from Yacc is +always named @file{y.tab.c}. The second command moves the output to the +rule's target file name. + +To use the canned sequence, substitute the variable into the commands of a +rule. You can substitute it like any other variable +(@pxref{Reference, ,Basics of Variable References}). +Because variables defined by @code{define} are recursively expanded +variables, all the variable references you wrote inside the @code{define} +are expanded now. For example: + +@example +foo.c : foo.y + $(run-yacc) +@end example + +@noindent +@samp{foo.y} will be substituted for the variable @samp{$^} when it occurs in +@code{run-yacc}'s value, and @samp{foo.c} for @samp{$@@}.@refill + +This is a realistic example, but this particular one is not needed in +practice because @code{make} has an implicit rule to figure out these +commands based on the file names involved +(@pxref{Implicit Rules, ,Using Implicit Rules}). + +@cindex @@, and @code{define} +@cindex -, and @code{define} +@cindex +, and @code{define} +In command execution, each line of a canned sequence is treated just as +if the line appeared on its own in the rule, preceded by a tab. In +particular, @code{make} invokes a separate subshell for each line. You +can use the special prefix characters that affect command lines +(@samp{@@}, @samp{-}, and @samp{+}) on each line of a canned sequence. +@xref{Commands, ,Writing the Commands in Rules}. +For example, using this canned sequence: + +@example +define frobnicate +@@echo "frobnicating target $@@" +frob-step-1 $< -o $@@-step-1 +frob-step-2 $@@-step-1 -o $@@ +endef +@end example + +@noindent +@code{make} will not echo the first line, the @code{echo} command. +But it @emph{will} echo the following two command lines. + +On the other hand, prefix characters on the command line that refers to +a canned sequence apply to every line in the sequence. So the rule: + +@example +frob.out: frob.in + @@$(frobnicate) +@end example + +@noindent +does not echo @emph{any} commands. +(@xref{Echoing, ,Command Echoing}, for a full explanation of @samp{@@}.) + +@node Empty Commands, , Sequences, Commands +@section Using Empty Commands +@cindex empty commands +@cindex commands, empty + +It is sometimes useful to define commands which do nothing. This is done +simply by giving a command that consists of nothing but whitespace. For +example: + +@example +target: ; +@end example + +@noindent +defines an empty command string for @file{target}. You could also use a +line beginning with a tab character to define an empty command string, +but this would be confusing because such a line looks empty. + +@findex .DEFAULT@r{, and empty commands} +You may be wondering why you would want to define a command string that +does nothing. The only reason this is useful is to prevent a target +from getting implicit commands (from implicit rules or the +@code{.DEFAULT} special target; @pxref{Implicit Rules} and +@pxref{Last Resort, ,Defining Last-Resort Default Rules}).@refill + +@c !!! another reason is for canonical stamp files: +@ignore +foo: stamp-foo ; +stamp-foo: foo.in + create foo frm foo.in + touch $@ +@end ignore + +You may be inclined to define empty command strings for targets that are +not actual files, but only exist so that their prerequisites can be +remade. However, this is not the best way to do that, because the +prerequisites may not be remade properly if the target file actually does exist. +@xref{Phony Targets, ,Phony Targets}, for a better way to do this. + +@node Using Variables, Conditionals, Commands, Top +@chapter How to Use Variables +@cindex variable +@cindex value +@cindex recursive variable expansion +@cindex simple variable expansion + +A @dfn{variable} is a name defined in a makefile to represent a string +of text, called the variable's @dfn{value}. These values are +substituted by explicit request into targets, prerequisites, commands, +and other parts of the makefile. (In some other versions of @code{make}, +variables are called @dfn{macros}.) +@cindex macro + +Variables and functions in all parts of a makefile are expanded when +read, except for the shell commands in rules, the right-hand sides of +variable definitions using @samp{=}, and the bodies of variable +definitions using the @code{define} directive.@refill + +Variables can represent lists of file names, options to pass to compilers, +programs to run, directories to look in for source files, directories to +write output in, or anything else you can imagine. + +A variable name may be any sequence of characters not containing @samp{:}, +@samp{#}, @samp{=}, or leading or trailing whitespace. However, +variable names containing characters other than letters, numbers, and +underscores should be avoided, as they may be given special meanings in the +future, and with some shells they cannot be passed through the environment to a +sub-@code{make} +(@pxref{Variables/Recursion, ,Communicating Variables to a Sub-@code{make}}). + +Variable names are case-sensitive. The names @samp{foo}, @samp{FOO}, +and @samp{Foo} all refer to different variables. + +It is traditional to use upper case letters in variable names, but we +recommend using lower case letters for variable names that serve internal +purposes in the makefile, and reserving upper case for parameters that +control implicit rules or for parameters that the user should override with +command options (@pxref{Overriding, ,Overriding Variables}). + +A few variables have names that are a single punctuation character or +just a few characters. These are the @dfn{automatic variables}, and +they have particular specialized uses. @xref{Automatic, ,Automatic Variables}. + +@menu +* Reference:: How to use the value of a variable. +* Flavors:: Variables come in two flavors. +* Advanced:: Advanced features for referencing a variable. +* Values:: All the ways variables get their values. +* Setting:: How to set a variable in the makefile. +* Appending:: How to append more text to the old value + of a variable. +* Override Directive:: How to set a variable in the makefile even if + the user has set it with a command argument. +* Defining:: An alternate way to set a variable + to a verbatim string. +* Environment:: Variable values can come from the environment. +* Target-specific:: Variable values can be defined on a per-target + basis. +* Pattern-specific:: Target-specific variable values can be applied + to a group of targets that match a pattern. +@end menu + +@node Reference, Flavors, Using Variables, Using Variables +@section Basics of Variable References +@cindex variables, how to reference +@cindex reference to variables +@cindex @code{$}, in variable reference +@cindex dollar sign (@code{$}), in variable reference + +To substitute a variable's value, write a dollar sign followed by the name +of the variable in parentheses or braces: either @samp{$(foo)} or +@samp{$@{foo@}} is a valid reference to the variable @code{foo}. This +special significance of @samp{$} is why you must write @samp{$$} to have +the effect of a single dollar sign in a file name or command. + +Variable references can be used in any context: targets, prerequisites, +commands, most directives, and new variable values. Here is an +example of a common case, where a variable holds the names of all the +object files in a program: + +@example +@group +objects = program.o foo.o utils.o +program : $(objects) + cc -o program $(objects) + +$(objects) : defs.h +@end group +@end example + +Variable references work by strict textual substitution. Thus, the rule + +@example +@group +foo = c +prog.o : prog.$(foo) + $(foo)$(foo) -$(foo) prog.$(foo) +@end group +@end example + +@noindent +could be used to compile a C program @file{prog.c}. Since spaces before +the variable value are ignored in variable assignments, the value of +@code{foo} is precisely @samp{c}. (Don't actually write your makefiles +this way!) + +A dollar sign followed by a character other than a dollar sign, +open-parenthesis or open-brace treats that single character as the +variable name. Thus, you could reference the variable @code{x} with +@samp{$x}. However, this practice is strongly discouraged, except in +the case of the automatic variables (@pxref{Automatic, ,Automatic Variables}). + +@node Flavors, Advanced, Reference, Using Variables +@section The Two Flavors of Variables +@cindex flavors of variables +@cindex recursive variable expansion +@cindex variables, flavors +@cindex recursively expanded variables +@cindex variables, recursively expanded + +There are two ways that a variable in GNU @code{make} can have a value; +we call them the two @dfn{flavors} of variables. The two flavors are +distinguished in how they are defined and in what they do when expanded. + +@cindex = +The first flavor of variable is a @dfn{recursively expanded} variable. +Variables of this sort are defined by lines using @samp{=} +(@pxref{Setting, ,Setting Variables}) or by the @code{define} directive +(@pxref{Defining, ,Defining Variables Verbatim}). The value you specify +is installed verbatim; if it contains references to other variables, +these references are expanded whenever this variable is substituted (in +the course of expanding some other string). When this happens, it is +called @dfn{recursive expansion}.@refill + +For example, + +@example +foo = $(bar) +bar = $(ugh) +ugh = Huh? + +all:;echo $(foo) +@end example + +@noindent +will echo @samp{Huh?}: @samp{$(foo)} expands to @samp{$(bar)} which +expands to @samp{$(ugh)} which finally expands to @samp{Huh?}.@refill + +This flavor of variable is the only sort supported by other versions of +@code{make}. It has its advantages and its disadvantages. An advantage +(most would say) is that: + +@example +CFLAGS = $(include_dirs) -O +include_dirs = -Ifoo -Ibar +@end example + +@noindent +will do what was intended: when @samp{CFLAGS} is expanded in a command, +it will expand to @samp{-Ifoo -Ibar -O}. A major disadvantage is that you +cannot append something on the end of a variable, as in + +@example +CFLAGS = $(CFLAGS) -O +@end example + +@noindent +because it will cause an infinite loop in the variable expansion. +(Actually @code{make} detects the infinite loop and reports an error.) +@cindex loops in variable expansion +@cindex variables, loops in expansion + +Another disadvantage is that any functions +(@pxref{Functions, ,Functions for Transforming Text}) +referenced in the definition will be executed every time the variable is +expanded. This makes @code{make} run slower; worse, it causes the +@code{wildcard} and @code{shell} functions to give unpredictable results +because you cannot easily control when they are called, or even how many +times. + +To avoid all the problems and inconveniences of recursively expanded +variables, there is another flavor: simply expanded variables. + +@cindex simply expanded variables +@cindex variables, simply expanded +@cindex := +@dfn{Simply expanded variables} are defined by lines using @samp{:=} +(@pxref{Setting, ,Setting Variables}). +The value of a simply expanded variable is scanned +once and for all, expanding any references to other variables and +functions, when the variable is defined. The actual value of the simply +expanded variable is the result of expanding the text that you write. +It does not contain any references to other variables; it contains their +values @emph{as of the time this variable was defined}. Therefore, + +@example +x := foo +y := $(x) bar +x := later +@end example + +@noindent +is equivalent to + +@example +y := foo bar +x := later +@end example + +When a simply expanded variable is referenced, its value is substituted +verbatim. + +Here is a somewhat more complicated example, illustrating the use of +@samp{:=} in conjunction with the @code{shell} function. +(@xref{Shell Function, , The @code{shell} Function}.) This example +also shows use of the variable @code{MAKELEVEL}, which is changed +when it is passed down from level to level. +(@xref{Variables/Recursion, , Communicating Variables to a +Sub-@code{make}}, for information about @code{MAKELEVEL}.) + +@vindex MAKELEVEL +@vindex MAKE +@example +@group +ifeq (0,$@{MAKELEVEL@}) +cur-dir := $(shell pwd) +whoami := $(shell whoami) +host-type := $(shell arch) +MAKE := $@{MAKE@} host-type=$@{host-type@} whoami=$@{whoami@} +endif +@end group +@end example + +@noindent +An advantage of this use of @samp{:=} is that a typical +`descend into a directory' command then looks like this: + +@example +@group +$@{subdirs@}: + $@{MAKE@} cur-dir=$@{cur-dir@}/$@@ -C $@@ all +@end group +@end example + +Simply expanded variables generally make complicated makefile programming +more predictable because they work like variables in most programming +languages. They allow you to redefine a variable using its own value (or +its value processed in some way by one of the expansion functions) and to +use the expansion functions much more efficiently +(@pxref{Functions, ,Functions for Transforming Text}). + +@cindex spaces, in variable values +@cindex whitespace, in variable values +@cindex variables, spaces in values +You can also use them to introduce controlled leading whitespace into +variable values. Leading whitespace characters are discarded from your +input before substitution of variable references and function calls; +this means you can include leading spaces in a variable value by +protecting them with variable references, like this: + +@example +nullstring := +space := $(nullstring) # end of the line +@end example + +@noindent +Here the value of the variable @code{space} is precisely one space. The +comment @w{@samp{# end of the line}} is included here just for clarity. +Since trailing space characters are @emph{not} stripped from variable +values, just a space at the end of the line would have the same effect +(but be rather hard to read). If you put whitespace at the end of a +variable value, it is a good idea to put a comment like that at the end +of the line to make your intent clear. Conversely, if you do @emph{not} +want any whitespace characters at the end of your variable value, you +must remember not to put a random comment on the end of the line after +some whitespace, such as this: + +@example +dir := /foo/bar # directory to put the frobs in +@end example + +@noindent +Here the value of the variable @code{dir} is @w{@samp{/foo/bar }} +(with four trailing spaces), which was probably not the intention. +(Imagine something like @w{@samp{$(dir)/file}} with this definition!) + +@cindex conditional variable assignment +@cindex variables, conditional assignment +@cindex ?= +There is another assignment operator for variables, @samp{?=}. This +is called a conditional variable assignment operator, because it only +has an effect if the variable is not yet defined. This statement: + +@example +FOO ?= bar +@end example + +@noindent +is exactly equivalent to this +(@pxref{Origin Function, ,The @code{origin} Function}): + +@example +ifeq ($(origin FOO), undefined) + FOO = bar +endif +@end example + +Note that a variable set to an empty value is still defined, so +@samp{?=} will not set that variable. + +@node Advanced, Values, Flavors, Using Variables +@section Advanced Features for Reference to Variables +@cindex reference to variables + +This section describes some advanced features you can use to reference +variables in more flexible ways. + +@menu +* Substitution Refs:: Referencing a variable with + substitutions on the value. +* Computed Names:: Computing the name of the variable to refer to. +@end menu + +@node Substitution Refs, Computed Names, Advanced, Advanced +@subsection Substitution References +@cindex modified variable reference +@cindex substitution variable reference +@cindex variables, modified reference +@cindex variables, substitution reference + +@cindex variables, substituting suffix in +@cindex suffix, substituting in variables +A @dfn{substitution reference} substitutes the value of a variable with +alterations that you specify. It has the form +@samp{$(@var{var}:@var{a}=@var{b})} (or +@samp{$@{@var{var}:@var{a}=@var{b}@}}) and its meaning is to take the value +of the variable @var{var}, replace every @var{a} at the end of a word with +@var{b} in that value, and substitute the resulting string. + +When we say ``at the end of a word'', we mean that @var{a} must appear +either followed by whitespace or at the end of the value in order to be +replaced; other occurrences of @var{a} in the value are unaltered. For +example:@refill + +@example +foo := a.o b.o c.o +bar := $(foo:.o=.c) +@end example + +@noindent +sets @samp{bar} to @samp{a.c b.c c.c}. @xref{Setting, ,Setting Variables}. + +A substitution reference is actually an abbreviation for use of the +@code{patsubst} expansion function (@pxref{Text Functions, ,Functions for String Substitution and Analysis}). We provide +substitution references as well as @code{patsubst} for compatibility with +other implementations of @code{make}. + +@findex patsubst +Another type of substitution reference lets you use the full power of +the @code{patsubst} function. It has the same form +@samp{$(@var{var}:@var{a}=@var{b})} described above, except that now +@var{a} must contain a single @samp{%} character. This case is +equivalent to @samp{$(patsubst @var{a},@var{b},$(@var{var}))}. +@xref{Text Functions, ,Functions for String Substitution and Analysis}, +for a description of the @code{patsubst} function.@refill + +@example +@group +@exdent For example: + +foo := a.o b.o c.o +bar := $(foo:%.o=%.c) +@end group +@end example + +@noindent +sets @samp{bar} to @samp{a.c b.c c.c}. + +@node Computed Names, , Substitution Refs, Advanced +@subsection Computed Variable Names +@cindex nested variable reference +@cindex computed variable name +@cindex variables, computed names +@cindex variables, nested references +@cindex variables, @samp{$} in name +@cindex @code{$}, in variable name +@cindex dollar sign (@code{$}), in variable name + +Computed variable names are a complicated concept needed only for +sophisticated makefile programming. For most purposes you need not +consider them, except to know that making a variable with a dollar sign +in its name might have strange results. However, if you are the type +that wants to understand everything, or you are actually interested in +what they do, read on. + +Variables may be referenced inside the name of a variable. This is +called a @dfn{computed variable name} or a @dfn{nested variable +reference}. For example, + +@example +x = y +y = z +a := $($(x)) +@end example + +@noindent +defines @code{a} as @samp{z}: the @samp{$(x)} inside @samp{$($(x))} expands +to @samp{y}, so @samp{$($(x))} expands to @samp{$(y)} which in turn expands +to @samp{z}. Here the name of the variable to reference is not stated +explicitly; it is computed by expansion of @samp{$(x)}. The reference +@samp{$(x)} here is nested within the outer variable reference. + +The previous example shows two levels of nesting, but any number of levels +is possible. For example, here are three levels: + +@example +x = y +y = z +z = u +a := $($($(x))) +@end example + +@noindent +Here the innermost @samp{$(x)} expands to @samp{y}, so @samp{$($(x))} +expands to @samp{$(y)} which in turn expands to @samp{z}; now we have +@samp{$(z)}, which becomes @samp{u}. + +References to recursively-expanded variables within a variable name are +reexpanded in the usual fashion. For example: + +@example +x = $(y) +y = z +z = Hello +a := $($(x)) +@end example + +@noindent +defines @code{a} as @samp{Hello}: @samp{$($(x))} becomes @samp{$($(y))} +which becomes @samp{$(z)} which becomes @samp{Hello}. + +Nested variable references can also contain modified references and +function invocations (@pxref{Functions, ,Functions for Transforming Text}), +just like any other reference. +For example, using the @code{subst} function +(@pxref{Text Functions, ,Functions for String Substitution and Analysis}): + +@example +@group +x = variable1 +variable2 := Hello +y = $(subst 1,2,$(x)) +z = y +a := $($($(z))) +@end group +@end example + +@noindent +eventually defines @code{a} as @samp{Hello}. It is doubtful that anyone +would ever want to write a nested reference as convoluted as this one, but +it works: @samp{$($($(z)))} expands to @samp{$($(y))} which becomes +@samp{$($(subst 1,2,$(x)))}. This gets the value @samp{variable1} from +@code{x} and changes it by substitution to @samp{variable2}, so that the +entire string becomes @samp{$(variable2)}, a simple variable reference +whose value is @samp{Hello}.@refill + +A computed variable name need not consist entirely of a single variable +reference. It can contain several variable references, as well as some +invariant text. For example, + +@example +@group +a_dirs := dira dirb +1_dirs := dir1 dir2 +@end group + +@group +a_files := filea fileb +1_files := file1 file2 +@end group + +@group +ifeq "$(use_a)" "yes" +a1 := a +else +a1 := 1 +endif +@end group + +@group +ifeq "$(use_dirs)" "yes" +df := dirs +else +df := files +endif + +dirs := $($(a1)_$(df)) +@end group +@end example + +@noindent +will give @code{dirs} the same value as @code{a_dirs}, @code{1_dirs}, +@code{a_files} or @code{1_files} depending on the settings of @code{use_a} +and @code{use_dirs}.@refill + +Computed variable names can also be used in substitution references: + +@example +@group +a_objects := a.o b.o c.o +1_objects := 1.o 2.o 3.o + +sources := $($(a1)_objects:.o=.c) +@end group +@end example + +@noindent +defines @code{sources} as either @samp{a.c b.c c.c} or @samp{1.c 2.c 3.c}, +depending on the value of @code{a1}. + +The only restriction on this sort of use of nested variable references +is that they cannot specify part of the name of a function to be called. +This is because the test for a recognized function name is done before +the expansion of nested references. For example, + +@example +@group +ifdef do_sort +func := sort +else +func := strip +endif +@end group + +@group +bar := a d b g q c +@end group + +@group +foo := $($(func) $(bar)) +@end group +@end example + +@noindent +attempts to give @samp{foo} the value of the variable @samp{sort a d b g +q c} or @samp{strip a d b g q c}, rather than giving @samp{a d b g q c} +as the argument to either the @code{sort} or the @code{strip} function. +This restriction could be removed in the future if that change is shown +to be a good idea. + +You can also use computed variable names in the left-hand side of a +variable assignment, or in a @code{define} directive, as in: + +@example +dir = foo +$(dir)_sources := $(wildcard $(dir)/*.c) +define $(dir)_print +lpr $($(dir)_sources) +endef +@end example + +@noindent +This example defines the variables @samp{dir}, @samp{foo_sources}, and +@samp{foo_print}. + +Note that @dfn{nested variable references} are quite different from +@dfn{recursively expanded variables} +(@pxref{Flavors, ,The Two Flavors of Variables}), though both are +used together in complex ways when doing makefile programming.@refill + +@node Values, Setting, Advanced, Using Variables +@section How Variables Get Their Values +@cindex variables, how they get their values +@cindex value, how a variable gets it + +Variables can get values in several different ways: + +@itemize @bullet +@item +You can specify an overriding value when you run @code{make}. +@xref{Overriding, ,Overriding Variables}. + +@item +You can specify a value in the makefile, either +with an assignment (@pxref{Setting, ,Setting Variables}) or with a +verbatim definition (@pxref{Defining, ,Defining Variables Verbatim}).@refill + +@item +Variables in the environment become @code{make} variables. +@xref{Environment, ,Variables from the Environment}. + +@item +Several @dfn{automatic} variables are given new values for each rule. +Each of these has a single conventional use. +@xref{Automatic, ,Automatic Variables}. + +@item +Several variables have constant initial values. +@xref{Implicit Variables, ,Variables Used by Implicit Rules}. +@end itemize + +@node Setting, Appending, Values, Using Variables +@section Setting Variables +@cindex setting variables +@cindex variables, setting +@cindex = +@cindex := +@cindex ?= + +To set a variable from the makefile, write a line starting with the +variable name followed by @samp{=} or @samp{:=}. Whatever follows the +@samp{=} or @samp{:=} on the line becomes the value. For example, + +@example +objects = main.o foo.o bar.o utils.o +@end example + +@noindent +defines a variable named @code{objects}. Whitespace around the variable +name and immediately after the @samp{=} is ignored. + +Variables defined with @samp{=} are @dfn{recursively expanded} variables. +Variables defined with @samp{:=} are @dfn{simply expanded} variables; these +definitions can contain variable references which will be expanded before +the definition is made. @xref{Flavors, ,The Two Flavors of Variables}. + +The variable name may contain function and variable references, which +are expanded when the line is read to find the actual variable name to use. + +There is no limit on the length of the value of a variable except the +amount of swapping space on the computer. When a variable definition is +long, it is a good idea to break it into several lines by inserting +backslash-newline at convenient places in the definition. This will not +affect the functioning of @code{make}, but it will make the makefile easier +to read. + +Most variable names are considered to have the empty string as a value if +you have never set them. Several variables have built-in initial values +that are not empty, but you can set them in the usual ways +(@pxref{Implicit Variables, ,Variables Used by Implicit Rules}). +Several special variables are set +automatically to a new value for each rule; these are called the +@dfn{automatic} variables (@pxref{Automatic, ,Automatic Variables}). + +If you'd like a variable to be set to a value only if it's not already +set, then you can use the shorthand operator @samp{?=} instead of +@samp{=}. These two settings of the variable @samp{FOO} are identical +(@pxref{Origin Function, ,The @code{origin} Function}): + +@example +FOO ?= bar +@end example + +@noindent +and + +@example +ifeq ($(origin FOO), undefined) +FOO = bar +endif +@end example + +@node Appending, Override Directive, Setting, Using Variables +@section Appending More Text to Variables +@cindex += +@cindex appending to variables +@cindex variables, appending to + +Often it is useful to add more text to the value of a variable already defined. +You do this with a line containing @samp{+=}, like this: + +@example +objects += another.o +@end example + +@noindent +This takes the value of the variable @code{objects}, and adds the text +@samp{another.o} to it (preceded by a single space). Thus: + +@example +objects = main.o foo.o bar.o utils.o +objects += another.o +@end example + +@noindent +sets @code{objects} to @samp{main.o foo.o bar.o utils.o another.o}. + +Using @samp{+=} is similar to: + +@example +objects = main.o foo.o bar.o utils.o +objects := $(objects) another.o +@end example + +@noindent +but differs in ways that become important when you use more complex values. + +When the variable in question has not been defined before, @samp{+=} +acts just like normal @samp{=}: it defines a recursively-expanded +variable. However, when there @emph{is} a previous definition, exactly +what @samp{+=} does depends on what flavor of variable you defined +originally. @xref{Flavors, ,The Two Flavors of Variables}, for an +explanation of the two flavors of variables. + +When you add to a variable's value with @samp{+=}, @code{make} acts +essentially as if you had included the extra text in the initial +definition of the variable. If you defined it first with @samp{:=}, +making it a simply-expanded variable, @samp{+=} adds to that +simply-expanded definition, and expands the new text before appending it +to the old value just as @samp{:=} does +(@pxref{Setting, ,Setting Variables}, for a full explanation of @samp{:=}). +In fact, + +@example +variable := value +variable += more +@end example + +@noindent +is exactly equivalent to: + +@noindent +@example +variable := value +variable := $(variable) more +@end example + +On the other hand, when you use @samp{+=} with a variable that you defined +first to be recursively-expanded using plain @samp{=}, @code{make} does +something a bit different. Recall that when you define a +recursively-expanded variable, @code{make} does not expand the value you set +for variable and function references immediately. Instead it stores the text +verbatim, and saves these variable and function references to be expanded +later, when you refer to the new variable (@pxref{Flavors, ,The Two Flavors +of Variables}). When you use @samp{+=} on a recursively-expanded variable, +it is this unexpanded text to which @code{make} appends the new text you +specify. + +@example +@group +variable = value +variable += more +@end group +@end example + +@noindent +is roughly equivalent to: + +@example +@group +temp = value +variable = $(temp) more +@end group +@end example + +@noindent +except that of course it never defines a variable called @code{temp}. +The importance of this comes when the variable's old value contains +variable references. Take this common example: + +@example +CFLAGS = $(includes) -O +@dots{} +CFLAGS += -pg # enable profiling +@end example + +@noindent +The first line defines the @code{CFLAGS} variable with a reference to another +variable, @code{includes}. (@code{CFLAGS} is used by the rules for C +compilation; @pxref{Catalogue of Rules, ,Catalogue of Implicit Rules}.) +Using @samp{=} for the definition makes @code{CFLAGS} a recursively-expanded +variable, meaning @w{@samp{$(includes) -O}} is @emph{not} expanded when +@code{make} processes the definition of @code{CFLAGS}. Thus, @code{includes} +need not be defined yet for its value to take effect. It only has to be +defined before any reference to @code{CFLAGS}. If we tried to append to the +value of @code{CFLAGS} without using @samp{+=}, we might do it like this: + +@example +CFLAGS := $(CFLAGS) -pg # enable profiling +@end example + +@noindent +This is pretty close, but not quite what we want. Using @samp{:=} +redefines @code{CFLAGS} as a simply-expanded variable; this means +@code{make} expands the text @w{@samp{$(CFLAGS) -pg}} before setting the +variable. If @code{includes} is not yet defined, we get @w{@samp{ -O +-pg}}, and a later definition of @code{includes} will have no effect. +Conversely, by using @samp{+=} we set @code{CFLAGS} to the +@emph{unexpanded} value @w{@samp{$(includes) -O -pg}}. Thus we preserve +the reference to @code{includes}, so if that variable gets defined at +any later point, a reference like @samp{$(CFLAGS)} still uses its +value. + +@node Override Directive, Defining, Appending, Using Variables +@section The @code{override} Directive +@findex override +@cindex overriding with @code{override} +@cindex variables, overriding + +If a variable has been set with a command argument +(@pxref{Overriding, ,Overriding Variables}), +then ordinary assignments in the makefile are ignored. If you want to set +the variable in the makefile even though it was set with a command +argument, you can use an @code{override} directive, which is a line that +looks like this:@refill + +@example +override @var{variable} = @var{value} +@end example + +@noindent +or + +@example +override @var{variable} := @var{value} +@end example + +To append more text to a variable defined on the command line, use: + +@example +override @var{variable} += @var{more text} +@end example + +@noindent +@xref{Appending, ,Appending More Text to Variables}. + +The @code{override} directive was not invented for escalation in the war +between makefiles and command arguments. It was invented so you can alter +and add to values that the user specifies with command arguments. + +For example, suppose you always want the @samp{-g} switch when you run the +C compiler, but you would like to allow the user to specify the other +switches with a command argument just as usual. You could use this +@code{override} directive: + +@example +override CFLAGS += -g +@end example + +You can also use @code{override} directives with @code{define} directives. +This is done as you might expect: + +@example +override define foo +bar +endef +@end example + +@noindent +@iftex +See the next section for information about @code{define}. +@end iftex +@ifinfo +@xref{Defining, ,Defining Variables Verbatim}. +@end ifinfo + +@node Defining, Environment, Override Directive, Using Variables +@section Defining Variables Verbatim +@findex define +@findex endef +@cindex verbatim variable definition +@cindex defining variables verbatim +@cindex variables, defining verbatim + +Another way to set the value of a variable is to use the @code{define} +directive. This directive has an unusual syntax which allows newline +characters to be included in the value, which is convenient for defining +both canned sequences of commands +(@pxref{Sequences, ,Defining Canned Command Sequences}), and also +sections of makefile syntax to use with @code{eval} (@pxref{Eval Function}). + +The @code{define} directive is followed on the same line by the name of the +variable and nothing more. The value to give the variable appears on the +following lines. The end of the value is marked by a line containing just +the word @code{endef}. Aside from this difference in syntax, @code{define} +works just like @samp{=}: it creates a recursively-expanded variable +(@pxref{Flavors, ,The Two Flavors of Variables}). +The variable name may contain function and variable references, which +are expanded when the directive is read to find the actual variable name +to use. + +You may nest @code{define} directives: @code{make} will keep track of +nested directives and report an error if they are not all properly +closed with @code{endef}. Note that lines beginning with tab +characters are considered part of a command script, so any +@code{define} or @code{endef} strings appearing on such a line will +not be considered @code{make} operators. + +@example +define two-lines +echo foo +echo $(bar) +endef +@end example + +The value in an ordinary assignment cannot contain a newline; but the +newlines that separate the lines of the value in a @code{define} become +part of the variable's value (except for the final newline which precedes +the @code{endef} and is not considered part of the value).@refill + +@need 800 +When used in a command script, the previous example is functionally +equivalent to this: + +@example +two-lines = echo foo; echo $(bar) +@end example + +@noindent +since two commands separated by semicolon behave much like two separate +shell commands. However, note that using two separate lines means +@code{make} will invoke the shell twice, running an independent subshell +for each line. @xref{Execution, ,Command Execution}. + +If you want variable definitions made with @code{define} to take +precedence over command-line variable definitions, you can use the +@code{override} directive together with @code{define}: + +@example +override define two-lines +foo +$(bar) +endef +@end example + +@noindent +@xref{Override Directive, ,The @code{override} Directive}. + +@node Environment, Target-specific, Defining, Using Variables +@section Variables from the Environment + +@cindex variables, environment +@cindex environment +Variables in @code{make} can come from the environment in which +@code{make} is run. Every environment variable that @code{make} sees when +it starts up is transformed into a @code{make} variable with the same name +and value. But an explicit assignment in the makefile, or with a command +argument, overrides the environment. (If the @samp{-e} flag is specified, +then values from the environment override assignments in the makefile. +@xref{Options Summary, ,Summary of Options}. +But this is not recommended practice.) + +Thus, by setting the variable @code{CFLAGS} in your environment, you can +cause all C compilations in most makefiles to use the compiler switches you +prefer. This is safe for variables with standard or conventional meanings +because you know that no makefile will use them for other things. (But +this is not totally reliable; some makefiles set @code{CFLAGS} explicitly +and therefore are not affected by the value in the environment.) + +When @code{make} is invoked recursively, variables defined in the +outer invocation can be passed to inner invocations through the +environment (@pxref{Recursion, ,Recursive Use of @code{make}}). By +default, only variables that came from the environment or the command +line are passed to recursive invocations. You can use the +@code{export} directive to pass other variables. +@xref{Variables/Recursion, , Communicating Variables to a +Sub-@code{make}}, for full details. + +Other use of variables from the environment is not recommended. It is not +wise for makefiles to depend for their functioning on environment variables +set up outside their control, since this would cause different users to get +different results from the same makefile. This is against the whole +purpose of most makefiles. + +Such problems would be especially likely with the variable @code{SHELL}, +which is normally present in the environment to specify the user's choice +of interactive shell. It would be very undesirable for this choice to +affect @code{make}. So @code{make} ignores the environment value of +@code{SHELL} (except on MS-DOS and MS-Windows, where @code{SHELL} is +usually not set. @xref{Execution, ,Special handling of SHELL on +MS-DOS}.)@refill + +@node Target-specific, Pattern-specific, Environment, Using Variables +@section Target-specific Variable Values +@cindex target-specific variables +@cindex variables, target-specific + +Variable values in @code{make} are usually global; that is, they are the +same regardless of where they are evaluated (unless they're reset, of +course). One exception to that is automatic variables +(@pxref{Automatic, ,Automatic Variables}). + +The other exception is @dfn{target-specific variable values}. This +feature allows you to define different values for the same variable, +based on the target that @code{make} is currently building. As with +automatic variables, these values are only available within the context +of a target's command script (and in other target-specific assignments). + +Set a target-specific variable value like this: + +@example +@var{target} @dots{} : @var{variable-assignment} +@end example + +@noindent +or like this: + +@example +@var{target} @dots{} : override @var{variable-assignment} +@end example + +Multiple @var{target} values create a target-specific variable value for +each member of the target list individually. + +The @var{variable-assignment} can be any valid form of assignment; +recursive (@samp{=}), static (@samp{:=}), appending (@samp{+=}), or +conditional (@samp{?=}). All variables that appear within the +@var{variable-assignment} are evaluated within the context of the +target: thus, any previously-defined target-specific variable values +will be in effect. Note that this variable is actually distinct from +any ``global'' value: the two variables do not have to have the same +flavor (recursive vs. static). + +Target-specific variables have the same priority as any other makefile +variable. Variables provided on the command-line (and in the +environment if the @samp{-e} option is in force) will take precedence. +Specifying the @code{override} directive will allow the target-specific +variable value to be preferred. + +There is one more special feature of target-specific variables: when you +define a target-specific variable, that variable value is also in effect +for all prerequisites of this target (unless those prerequisites override +it with their own target-specific variable value). So, for example, a +statement like this: + +@example +prog : CFLAGS = -g +prog : prog.o foo.o bar.o +@end example + +@noindent +will set @code{CFLAGS} to @samp{-g} in the command script for +@file{prog}, but it will also set @code{CFLAGS} to @samp{-g} in the +command scripts that create @file{prog.o}, @file{foo.o}, and +@file{bar.o}, and any command scripts which create their prerequisites. + +@node Pattern-specific, , Target-specific, Using Variables +@section Pattern-specific Variable Values +@cindex pattern-specific variables +@cindex variables, pattern-specific + +In addition to target-specific variable values (@pxref{Target-specific, +,Target-specific Variable Values}), GNU @code{make} supports +pattern-specific variable values. In this form, a variable is defined +for any target that matches the pattern specified. Variables defined in +this way are searched after any target-specific variables defined +explicitly for that target, and before target-specific variables defined +for the parent target. + +Set a pattern-specific variable value like this: + +@example +@var{pattern} @dots{} : @var{variable-assignment} +@end example + +@noindent +or like this: + +@example +@var{pattern} @dots{} : override @var{variable-assignment} +@end example + +@noindent +where @var{pattern} is a %-pattern. As with target-specific variable +values, multiple @var{pattern} values create a pattern-specific variable +value for each pattern individually. The @var{variable-assignment} can +be any valid form of assignment. Any command-line variable setting will +take precedence, unless @code{override} is specified. + +For example: + +@example +%.o : CFLAGS = -O +@end example + +@noindent +will assign @code{CFLAGS} the value of @samp{-O} for all targets +matching the pattern @code{%.o}. + +@node Conditionals, Functions, Using Variables, Top +@chapter Conditional Parts of Makefiles + +@cindex conditionals +A @dfn{conditional} causes part of a makefile to be obeyed or ignored +depending on the values of variables. Conditionals can compare the +value of one variable to another, or the value of a variable to +a constant string. Conditionals control what @code{make} actually +``sees'' in the makefile, so they @emph{cannot} be used to control shell +commands at the time of execution.@refill + +@menu +* Conditional Example:: Example of a conditional +* Conditional Syntax:: The syntax of conditionals. +* Testing Flags:: Conditionals that test flags. +@end menu + +@node Conditional Example, Conditional Syntax, Conditionals, Conditionals +@section Example of a Conditional + +The following example of a conditional tells @code{make} to use one set +of libraries if the @code{CC} variable is @samp{gcc}, and a different +set of libraries otherwise. It works by controlling which of two +command lines will be used as the command for a rule. The result is +that @samp{CC=gcc} as an argument to @code{make} changes not only which +compiler is used but also which libraries are linked. + +@example +libs_for_gcc = -lgnu +normal_libs = + +foo: $(objects) +ifeq ($(CC),gcc) + $(CC) -o foo $(objects) $(libs_for_gcc) +else + $(CC) -o foo $(objects) $(normal_libs) +endif +@end example + +This conditional uses three directives: one @code{ifeq}, one @code{else} +and one @code{endif}. + +The @code{ifeq} directive begins the conditional, and specifies the +condition. It contains two arguments, separated by a comma and surrounded +by parentheses. Variable substitution is performed on both arguments and +then they are compared. The lines of the makefile following the +@code{ifeq} are obeyed if the two arguments match; otherwise they are +ignored. + +The @code{else} directive causes the following lines to be obeyed if the +previous conditional failed. In the example above, this means that the +second alternative linking command is used whenever the first alternative +is not used. It is optional to have an @code{else} in a conditional. + +The @code{endif} directive ends the conditional. Every conditional must +end with an @code{endif}. Unconditional makefile text follows. + +As this example illustrates, conditionals work at the textual level: +the lines of the conditional are treated as part of the makefile, or +ignored, according to the condition. This is why the larger syntactic +units of the makefile, such as rules, may cross the beginning or the +end of the conditional. + +When the variable @code{CC} has the value @samp{gcc}, the above example has +this effect: + +@example +foo: $(objects) + $(CC) -o foo $(objects) $(libs_for_gcc) +@end example + +@noindent +When the variable @code{CC} has any other value, the effect is this: + +@example +foo: $(objects) + $(CC) -o foo $(objects) $(normal_libs) +@end example + +Equivalent results can be obtained in another way by conditionalizing a +variable assignment and then using the variable unconditionally: + +@example +libs_for_gcc = -lgnu +normal_libs = + +ifeq ($(CC),gcc) + libs=$(libs_for_gcc) +else + libs=$(normal_libs) +endif + +foo: $(objects) + $(CC) -o foo $(objects) $(libs) +@end example + +@node Conditional Syntax, Testing Flags, Conditional Example, Conditionals +@section Syntax of Conditionals +@findex ifdef +@findex ifeq +@findex ifndef +@findex ifneq +@findex else +@findex endif + +The syntax of a simple conditional with no @code{else} is as follows: + +@example +@var{conditional-directive} +@var{text-if-true} +endif +@end example + +@noindent +The @var{text-if-true} may be any lines of text, to be considered as part +of the makefile if the condition is true. If the condition is false, no +text is used instead. + +The syntax of a complex conditional is as follows: + +@example +@var{conditional-directive} +@var{text-if-true} +else +@var{text-if-false} +endif +@end example + +@noindent +If the condition is true, @var{text-if-true} is used; otherwise, +@var{text-if-false} is used instead. The @var{text-if-false} can be any +number of lines of text. + +The syntax of the @var{conditional-directive} is the same whether the +conditional is simple or complex. There are four different directives that +test different conditions. Here is a table of them: + +@table @code +@item ifeq (@var{arg1}, @var{arg2}) +@itemx ifeq '@var{arg1}' '@var{arg2}' +@itemx ifeq "@var{arg1}" "@var{arg2}" +@itemx ifeq "@var{arg1}" '@var{arg2}' +@itemx ifeq '@var{arg1}' "@var{arg2}" +Expand all variable references in @var{arg1} and @var{arg2} and +compare them. If they are identical, the @var{text-if-true} is +effective; otherwise, the @var{text-if-false}, if any, is effective. + +Often you want to test if a variable has a non-empty value. When the +value results from complex expansions of variables and functions, +expansions you would consider empty may actually contain whitespace +characters and thus are not seen as empty. However, you can use the +@code{strip} function (@pxref{Text Functions}) to avoid interpreting +whitespace as a non-empty value. For example: + +@example +@group +ifeq ($(strip $(foo)),) +@var{text-if-empty} +endif +@end group +@end example + +@noindent +will evaluate @var{text-if-empty} even if the expansion of +@code{$(foo)} contains whitespace characters. + +@item ifneq (@var{arg1}, @var{arg2}) +@itemx ifneq '@var{arg1}' '@var{arg2}' +@itemx ifneq "@var{arg1}" "@var{arg2}" +@itemx ifneq "@var{arg1}" '@var{arg2}' +@itemx ifneq '@var{arg1}' "@var{arg2}" +Expand all variable references in @var{arg1} and @var{arg2} and +compare them. If they are different, the @var{text-if-true} is +effective; otherwise, the @var{text-if-false}, if any, is effective. + +@item ifdef @var{variable-name} +If the variable @var{variable-name} has a non-empty value, the +@var{text-if-true} is effective; otherwise, the @var{text-if-false}, +if any, is effective. Variables that have never been defined have an +empty value. + +Note that @code{ifdef} only tests whether a variable has a value. It +does not expand the variable to see if that value is nonempty. +Consequently, tests using @code{ifdef} return true for all definitions +except those like @code{foo =}. To test for an empty value, use +@w{@code{ifeq ($(foo),)}}. For example, + +@example +bar = +foo = $(bar) +ifdef foo +frobozz = yes +else +frobozz = no +endif +@end example + +@noindent +sets @samp{frobozz} to @samp{yes}, while: + +@example +foo = +ifdef foo +frobozz = yes +else +frobozz = no +endif +@end example + +@noindent +sets @samp{frobozz} to @samp{no}. + +@item ifndef @var{variable-name} +If the variable @var{variable-name} has an empty value, the +@var{text-if-true} is effective; otherwise, the @var{text-if-false}, +if any, is effective. +@end table + +Extra spaces are allowed and ignored at the beginning of the conditional +directive line, but a tab is not allowed. (If the line begins with a tab, +it will be considered a command for a rule.) Aside from this, extra spaces +or tabs may be inserted with no effect anywhere except within the directive +name or within an argument. A comment starting with @samp{#} may appear at +the end of the line. + +The other two directives that play a part in a conditional are @code{else} +and @code{endif}. Each of these directives is written as one word, with no +arguments. Extra spaces are allowed and ignored at the beginning of the +line, and spaces or tabs at the end. A comment starting with @samp{#} may +appear at the end of the line. + +Conditionals affect which lines of the makefile @code{make} uses. If +the condition is true, @code{make} reads the lines of the +@var{text-if-true} as part of the makefile; if the condition is false, +@code{make} ignores those lines completely. It follows that syntactic +units of the makefile, such as rules, may safely be split across the +beginning or the end of the conditional.@refill + +@code{make} evaluates conditionals when it reads a makefile. +Consequently, you cannot use automatic variables in the tests of +conditionals because they are not defined until commands are run +(@pxref{Automatic, , Automatic Variables}). + +To prevent intolerable confusion, it is not permitted to start a +conditional in one makefile and end it in another. However, you may +write an @code{include} directive within a conditional, provided you do +not attempt to terminate the conditional inside the included file. + +@node Testing Flags, , Conditional Syntax, Conditionals +@section Conditionals that Test Flags + +You can write a conditional that tests @code{make} command flags such as +@samp{-t} by using the variable @code{MAKEFLAGS} together with the +@code{findstring} function +(@pxref{Text Functions, , Functions for String Substitution and Analysis}). +This is useful when @code{touch} is not enough to make a file appear up +to date. + +The @code{findstring} function determines whether one string appears as a +substring of another. If you want to test for the @samp{-t} flag, +use @samp{t} as the first string and the value of @code{MAKEFLAGS} as +the other. + +For example, here is how to arrange to use @samp{ranlib -t} to finish +marking an archive file up to date: + +@example +archive.a: @dots{} +ifneq (,$(findstring t,$(MAKEFLAGS))) + +touch archive.a + +ranlib -t archive.a +else + ranlib archive.a +endif +@end example + +@noindent +The @samp{+} prefix marks those command lines as ``recursive'' so +that they will be executed despite use of the @samp{-t} flag. +@xref{Recursion, ,Recursive Use of @code{make}}. + +@node Functions, Running, Conditionals, Top +@chapter Functions for Transforming Text +@cindex functions + +@dfn{Functions} allow you to do text processing in the makefile to compute +the files to operate on or the commands to use. You use a function in a +@dfn{function call}, where you give the name of the function and some text +(the @dfn{arguments}) for the function to operate on. The result of the +function's processing is substituted into the makefile at the point of the +call, just as a variable might be substituted. + +@menu +* Syntax of Functions:: How to write a function call. +* Text Functions:: General-purpose text manipulation functions. +* File Name Functions:: Functions for manipulating file names. +* Foreach Function:: Repeat some text with controlled variation. +* If Function:: Conditionally expand a value. +* Call Function:: Expand a user-defined function. +* Value Function:: Return the un-expanded value of a variable. +* Eval Function:: Evaluate the arguments as makefile syntax. +* Origin Function:: Find where a variable got its value. +* Shell Function:: Substitute the output of a shell command. +* Make Control Functions:: Functions that control how make runs. +@end menu + +@node Syntax of Functions, Text Functions, Functions, Functions +@section Function Call Syntax +@cindex @code{$}, in function call +@cindex dollar sign (@code{$}), in function call +@cindex arguments of functions +@cindex functions, syntax of + +A function call resembles a variable reference. It looks like this: + +@example +$(@var{function} @var{arguments}) +@end example + +@noindent +or like this: + +@example +$@{@var{function} @var{arguments}@} +@end example + +Here @var{function} is a function name; one of a short list of names +that are part of @code{make}. You can also essentially create your own +functions by using the @code{call} builtin function. + +The @var{arguments} are the arguments of the function. They are +separated from the function name by one or more spaces or tabs, and if +there is more than one argument, then they are separated by commas. +Such whitespace and commas are not part of an argument's value. The +delimiters which you use to surround the function call, whether +parentheses or braces, can appear in an argument only in matching pairs; +the other kind of delimiters may appear singly. If the arguments +themselves contain other function calls or variable references, it is +wisest to use the same kind of delimiters for all the references; write +@w{@samp{$(subst a,b,$(x))}}, not @w{@samp{$(subst a,b,$@{x@})}}. This +is because it is clearer, and because only one type of delimiter is +matched to find the end of the reference. + +The text written for each argument is processed by substitution of +variables and function calls to produce the argument value, which +is the text on which the function acts. The substitution is done in the +order in which the arguments appear. + +Commas and unmatched parentheses or braces cannot appear in the text of an +argument as written; leading spaces cannot appear in the text of the first +argument as written. These characters can be put into the argument value +by variable substitution. First define variables @code{comma} and +@code{space} whose values are isolated comma and space characters, then +substitute these variables where such characters are wanted, like this: + +@example +@group +comma:= , +empty:= +space:= $(empty) $(empty) +foo:= a b c +bar:= $(subst $(space),$(comma),$(foo)) +# @r{bar is now `a,b,c'.} +@end group +@end example + +@noindent +Here the @code{subst} function replaces each space with a comma, through +the value of @code{foo}, and substitutes the result. + +@node Text Functions, File Name Functions, Syntax of Functions, Functions +@section Functions for String Substitution and Analysis +@cindex functions, for text + +Here are some functions that operate on strings: + +@table @code +@item $(subst @var{from},@var{to},@var{text}) +@findex subst +Performs a textual replacement on the text @var{text}: each occurrence +of @var{from} is replaced by @var{to}. The result is substituted for +the function call. For example, + +@example +$(subst ee,EE,feet on the street) +@end example + +substitutes the string @samp{fEEt on the strEEt}. + +@item $(patsubst @var{pattern},@var{replacement},@var{text}) +@findex patsubst +Finds whitespace-separated words in @var{text} that match +@var{pattern} and replaces them with @var{replacement}. Here +@var{pattern} may contain a @samp{%} which acts as a wildcard, +matching any number of any characters within a word. If +@var{replacement} also contains a @samp{%}, the @samp{%} is replaced +by the text that matched the @samp{%} in @var{pattern}. Only the first +@samp{%} in the @var{pattern} and @var{replacement} is treated this +way; any subsequent @samp{%} is unchanged.@refill + +@cindex @code{%}, quoting in @code{patsubst} +@cindex @code{%}, quoting with @code{\} (backslash) +@cindex @code{\} (backslash), to quote @code{%} +@cindex backslash (@code{\}), to quote @code{%} +@cindex quoting @code{%}, in @code{patsubst} +@samp{%} characters in @code{patsubst} function invocations can be +quoted with preceding backslashes (@samp{\}). Backslashes that would +otherwise quote @samp{%} characters can be quoted with more backslashes. +Backslashes that quote @samp{%} characters or other backslashes are +removed from the pattern before it is compared file names or has a stem +substituted into it. Backslashes that are not in danger of quoting +@samp{%} characters go unmolested. For example, the pattern +@file{the\%weird\\%pattern\\} has @samp{the%weird\} preceding the +operative @samp{%} character, and @samp{pattern\\} following it. The +final two backslashes are left alone because they cannot affect any +@samp{%} character.@refill + +Whitespace between words is folded into single space characters; +leading and trailing whitespace is discarded. + +For example, + +@example +$(patsubst %.c,%.o,x.c.c bar.c) +@end example + +@noindent +produces the value @samp{x.c.o bar.o}. + +Substitution references (@pxref{Substitution Refs, ,Substitution +References}) are a simpler way to get the effect of the @code{patsubst} +function: + +@example +$(@var{var}:@var{pattern}=@var{replacement}) +@end example + +@noindent +is equivalent to + +@example +$(patsubst @var{pattern},@var{replacement},$(@var{var})) +@end example + +The second shorthand simplifies one of the most common uses of +@code{patsubst}: replacing the suffix at the end of file names. + +@example +$(@var{var}:@var{suffix}=@var{replacement}) +@end example + +@noindent +is equivalent to + +@example +$(patsubst %@var{suffix},%@var{replacement},$(@var{var})) +@end example + +@noindent +For example, you might have a list of object files: + +@example +objects = foo.o bar.o baz.o +@end example + +@noindent +To get the list of corresponding source files, you could simply write: + +@example +$(objects:.o=.c) +@end example + +@noindent +instead of using the general form: + +@example +$(patsubst %.o,%.c,$(objects)) +@end example + +@item $(strip @var{string}) +@cindex stripping whitespace +@cindex whitespace, stripping +@cindex spaces, stripping +@findex strip +Removes leading and trailing whitespace from @var{string} and replaces +each internal sequence of one or more whitespace characters with a +single space. Thus, @samp{$(strip a b c )} results in @w{@samp{a b c}}. + +The function @code{strip} can be very useful when used in conjunction +with conditionals. When comparing something with the empty string +@samp{} using @code{ifeq} or @code{ifneq}, you usually want a string of +just whitespace to match the empty string (@pxref{Conditionals}). + +Thus, the following may fail to have the desired results: + +@example +.PHONY: all +ifneq "$(needs_made)" "" +all: $(needs_made) +else +all:;@@echo 'Nothing to make!' +endif +@end example + +@noindent +Replacing the variable reference @w{@samp{$(needs_made)}} with the +function call @w{@samp{$(strip $(needs_made))}} in the @code{ifneq} +directive would make it more robust.@refill + +@item $(findstring @var{find},@var{in}) +@findex findstring +@cindex searching for strings +@cindex finding strings +@cindex strings, searching for +Searches @var{in} for an occurrence of @var{find}. If it occurs, the +value is @var{find}; otherwise, the value is empty. You can use this +function in a conditional to test for the presence of a specific +substring in a given string. Thus, the two examples, + +@example +$(findstring a,a b c) +$(findstring a,b c) +@end example + +@noindent +produce the values @samp{a} and @samp{} (the empty string), +respectively. @xref{Testing Flags}, for a practical application of +@code{findstring}.@refill + +@need 750 +@findex filter +@cindex filtering words +@cindex words, filtering +@item $(filter @var{pattern}@dots{},@var{text}) +Returns all whitespace-separated words in @var{text} that @emph{do} match +any of the @var{pattern} words, removing any words that @emph{do not} +match. The patterns are written using @samp{%}, just like the patterns +used in the @code{patsubst} function above.@refill + +The @code{filter} function can be used to separate out different types +of strings (such as file names) in a variable. For example: + +@example +sources := foo.c bar.c baz.s ugh.h +foo: $(sources) + cc $(filter %.c %.s,$(sources)) -o foo +@end example + +@noindent +says that @file{foo} depends of @file{foo.c}, @file{bar.c}, +@file{baz.s} and @file{ugh.h} but only @file{foo.c}, @file{bar.c} and +@file{baz.s} should be specified in the command to the +compiler.@refill + +@item $(filter-out @var{pattern}@dots{},@var{text}) +@findex filter-out +@cindex filtering out words +@cindex words, filtering out +Returns all whitespace-separated words in @var{text} that @emph{do not} +match any of the @var{pattern} words, removing the words that @emph{do} +match one or more. This is the exact opposite of the @code{filter} +function.@refill + +For example, given: + +@example +@group +objects=main1.o foo.o main2.o bar.o +mains=main1.o main2.o +@end group +@end example + +@noindent +the following generates a list which contains all the object files not +in @samp{mains}: + +@example +$(filter-out $(mains),$(objects)) +@end example + +@need 1500 +@findex sort +@cindex sorting words +@item $(sort @var{list}) +Sorts the words of @var{list} in lexical order, removing duplicate +words. The output is a list of words separated by single spaces. +Thus, + +@example +$(sort foo bar lose) +@end example + +@noindent +returns the value @samp{bar foo lose}. + +@cindex removing duplicate words +@cindex duplicate words, removing +@cindex words, removing duplicates +Incidentally, since @code{sort} removes duplicate words, you can use +it for this purpose even if you don't care about the sort order. + +@item $(word @var{n},@var{text}) +@findex word +@cindex word, selecting a +@cindex selecting a word +Returns the @var{n}th word of @var{text}. The legitimate values of +@var{n} start from 1. If @var{n} is bigger than the number of words +in @var{text}, the value is empty. For example, + +@example +$(word 2, foo bar baz) +@end example + +@noindent +returns @samp{bar}. + +@item $(wordlist @var{s},@var{e},@var{text}) +@findex wordlist +@cindex words, selecting lists of +@cindex selecting word lists +Returns the list of words in @var{text} starting with word @var{s} and +ending with word @var{e} (inclusive). The legitimate values of @var{s} +and @var{e} start from 1. If @var{s} is bigger than the number of words +in @var{text}, the value is empty. If @var{e} is bigger than the number +of words in @var{text}, words up to the end of @var{text} are returned. +If @var{s} is greater than @var{e}, nothing is returned. For example, + +@example +$(wordlist 2, 3, foo bar baz) +@end example + +@noindent +returns @samp{bar baz}. + +@c Following item phrased to prevent overfull hbox. --RJC 17 Jul 92 +@item $(words @var{text}) +@findex words +@cindex words, finding number +Returns the number of words in @var{text}. +Thus, the last word of @var{text} is +@w{@code{$(word $(words @var{text}),@var{text})}}.@refill + +@item $(firstword @var{names}@dots{}) +@findex firstword +@cindex words, extracting first +The argument @var{names} is regarded as a series of names, separated +by whitespace. The value is the first name in the series. The rest +of the names are ignored. + +For example, + +@example +$(firstword foo bar) +@end example + +@noindent +produces the result @samp{foo}. Although @code{$(firstword +@var{text})} is the same as @code{$(word 1,@var{text})}, the +@code{firstword} function is retained for its simplicity.@refill +@end table + +Here is a realistic example of the use of @code{subst} and +@code{patsubst}. Suppose that a makefile uses the @code{VPATH} variable +to specify a list of directories that @code{make} should search for +prerequisite files +(@pxref{General Search, , @code{VPATH} Search Path for All Prerequisites}). +This example shows how to +tell the C compiler to search for header files in the same list of +directories.@refill + +The value of @code{VPATH} is a list of directories separated by colons, +such as @samp{src:../headers}. First, the @code{subst} function is used to +change the colons to spaces: + +@example +$(subst :, ,$(VPATH)) +@end example + +@noindent +This produces @samp{src ../headers}. Then @code{patsubst} is used to turn +each directory name into a @samp{-I} flag. These can be added to the +value of the variable @code{CFLAGS}, which is passed automatically to the C +compiler, like this: + +@example +override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH))) +@end example + +@noindent +The effect is to append the text @samp{-Isrc -I../headers} to the +previously given value of @code{CFLAGS}. The @code{override} directive is +used so that the new value is assigned even if the previous value of +@code{CFLAGS} was specified with a command argument (@pxref{Override +Directive, , The @code{override} Directive}). + +@node File Name Functions, Foreach Function, Text Functions, Functions +@section Functions for File Names +@cindex functions, for file names +@cindex file name functions + +Several of the built-in expansion functions relate specifically to +taking apart file names or lists of file names. + +Each of the following functions performs a specific transformation on a +file name. The argument of the function is regarded as a series of file +names, separated by whitespace. (Leading and trailing whitespace is +ignored.) Each file name in the series is transformed in the same way and +the results are concatenated with single spaces between them. + +@table @code +@item $(dir @var{names}@dots{}) +@findex dir +@cindex directory part +@cindex file name, directory part +Extracts the directory-part of each file name in @var{names}. The +directory-part of the file name is everything up through (and +including) the last slash in it. If the file name contains no slash, +the directory part is the string @samp{./}. For example, + +@example +$(dir src/foo.c hacks) +@end example + +@noindent +produces the result @samp{src/ ./}. + +@item $(notdir @var{names}@dots{}) +@findex notdir +@cindex file name, nondirectory part +@cindex nondirectory part +Extracts all but the directory-part of each file name in @var{names}. +If the file name contains no slash, it is left unchanged. Otherwise, +everything through the last slash is removed from it. + +A file name that ends with a slash becomes an empty string. This is +unfortunate, because it means that the result does not always have the +same number of whitespace-separated file names as the argument had; +but we do not see any other valid alternative. + +For example, + +@example +$(notdir src/foo.c hacks) +@end example + +@noindent +produces the result @samp{foo.c hacks}. + +@item $(suffix @var{names}@dots{}) +@findex suffix +@cindex suffix, function to find +@cindex file name suffix +Extracts the suffix of each file name in @var{names}. If the file name +contains a period, the suffix is everything starting with the last +period. Otherwise, the suffix is the empty string. This frequently +means that the result will be empty when @var{names} is not, and if +@var{names} contains multiple file names, the result may contain fewer +file names. + +For example, + +@example +$(suffix src/foo.c src-1.0/bar.c hacks) +@end example + +@noindent +produces the result @samp{.c .c}. + +@item $(basename @var{names}@dots{}) +@findex basename +@cindex basename +@cindex file name, basename of +Extracts all but the suffix of each file name in @var{names}. If the +file name contains a period, the basename is everything starting up to +(and not including) the last period. Periods in the directory part are +ignored. If there is no period, the basename is the entire file name. +For example, + +@example +$(basename src/foo.c src-1.0/bar hacks) +@end example + +@noindent +produces the result @samp{src/foo src-1.0/bar hacks}. + +@c plural convention with dots (be consistent) +@item $(addsuffix @var{suffix},@var{names}@dots{}) +@findex addsuffix +@cindex suffix, adding +@cindex file name suffix, adding +The argument @var{names} is regarded as a series of names, separated +by whitespace; @var{suffix} is used as a unit. The value of +@var{suffix} is appended to the end of each individual name and the +resulting larger names are concatenated with single spaces between +them. For example, + +@example +$(addsuffix .c,foo bar) +@end example + +@noindent +produces the result @samp{foo.c bar.c}. + +@item $(addprefix @var{prefix},@var{names}@dots{}) +@findex addprefix +@cindex prefix, adding +@cindex file name prefix, adding +The argument @var{names} is regarded as a series of names, separated +by whitespace; @var{prefix} is used as a unit. The value of +@var{prefix} is prepended to the front of each individual name and the +resulting larger names are concatenated with single spaces between +them. For example, + +@example +$(addprefix src/,foo bar) +@end example + +@noindent +produces the result @samp{src/foo src/bar}. + +@item $(join @var{list1},@var{list2}) +@findex join +@cindex joining lists of words +@cindex words, joining lists +Concatenates the two arguments word by word: the two first words (one +from each argument) concatenated form the first word of the result, the +two second words form the second word of the result, and so on. So the +@var{n}th word of the result comes from the @var{n}th word of each +argument. If one argument has more words that the other, the extra +words are copied unchanged into the result. + +For example, @samp{$(join a b,.c .o)} produces @samp{a.c b.o}. + +Whitespace between the words in the lists is not preserved; it is +replaced with a single space. + +This function can merge the results of the @code{dir} and +@code{notdir} functions, to produce the original list of files which +was given to those two functions.@refill + +@item $(wildcard @var{pattern}) +@findex wildcard +@cindex wildcard, function +The argument @var{pattern} is a file name pattern, typically containing +wildcard characters (as in shell file name patterns). The result of +@code{wildcard} is a space-separated list of the names of existing files +that match the pattern. +@xref{Wildcards, ,Using Wildcard Characters in File Names}. +@end table + +@node Foreach Function, If Function, File Name Functions, Functions +@section The @code{foreach} Function +@findex foreach +@cindex words, iterating over + +The @code{foreach} function is very different from other functions. It +causes one piece of text to be used repeatedly, each time with a different +substitution performed on it. It resembles the @code{for} command in the +shell @code{sh} and the @code{foreach} command in the C-shell @code{csh}. + +The syntax of the @code{foreach} function is: + +@example +$(foreach @var{var},@var{list},@var{text}) +@end example + +@noindent +The first two arguments, @var{var} and @var{list}, are expanded before +anything else is done; note that the last argument, @var{text}, is +@strong{not} expanded at the same time. Then for each word of the expanded +value of @var{list}, the variable named by the expanded value of @var{var} +is set to that word, and @var{text} is expanded. Presumably @var{text} +contains references to that variable, so its expansion will be different +each time. + +The result is that @var{text} is expanded as many times as there are +whitespace-separated words in @var{list}. The multiple expansions of +@var{text} are concatenated, with spaces between them, to make the result +of @code{foreach}. + +This simple example sets the variable @samp{files} to the list of all files +in the directories in the list @samp{dirs}: + +@example +dirs := a b c d +files := $(foreach dir,$(dirs),$(wildcard $(dir)/*)) +@end example + +Here @var{text} is @samp{$(wildcard $(dir)/*)}. The first repetition +finds the value @samp{a} for @code{dir}, so it produces the same result +as @samp{$(wildcard a/*)}; the second repetition produces the result +of @samp{$(wildcard b/*)}; and the third, that of @samp{$(wildcard c/*)}. + +This example has the same result (except for setting @samp{dirs}) as +the following example: + +@example +files := $(wildcard a/* b/* c/* d/*) +@end example + +When @var{text} is complicated, you can improve readability by giving it +a name, with an additional variable: + +@example +find_files = $(wildcard $(dir)/*) +dirs := a b c d +files := $(foreach dir,$(dirs),$(find_files)) +@end example + +@noindent +Here we use the variable @code{find_files} this way. We use plain @samp{=} +to define a recursively-expanding variable, so that its value contains an +actual function call to be reexpanded under the control of @code{foreach}; +a simply-expanded variable would not do, since @code{wildcard} would be +called only once at the time of defining @code{find_files}. + +The @code{foreach} function has no permanent effect on the variable +@var{var}; its value and flavor after the @code{foreach} function call are +the same as they were beforehand. The other values which are taken from +@var{list} are in effect only temporarily, during the execution of +@code{foreach}. The variable @var{var} is a simply-expanded variable +during the execution of @code{foreach}. If @var{var} was undefined +before the @code{foreach} function call, it is undefined after the call. +@xref{Flavors, ,The Two Flavors of Variables}.@refill + +You must take care when using complex variable expressions that result in +variable names because many strange things are valid variable names, but +are probably not what you intended. For example, + +@smallexample +files := $(foreach Esta escrito en espanol!,b c ch,$(find_files)) +@end smallexample + +@noindent +might be useful if the value of @code{find_files} references the variable +whose name is @samp{Esta escrito en espanol!} (es un nombre bastante largo, +no?), but it is more likely to be a mistake. + +@node If Function, Call Function, Foreach Function, Functions +@section The @code{if} Function +@findex if +@cindex conditional expansion + +The @code{if} function provides support for conditional expansion in a +functional context (as opposed to the GNU @code{make} makefile +conditionals such as @code{ifeq} (@pxref{Conditional Syntax, ,Syntax of +Conditionals}). + +An @code{if} function call can contain either two or three arguments: + +@example +$(if @var{condition},@var{then-part}[,@var{else-part}]) +@end example + +The first argument, @var{condition}, first has all preceding and +trailing whitespace stripped, then is expanded. If it expands to any +non-empty string, then the condition is considered to be true. If it +expands to an empty string, the condition is considered to be false. + +If the condition is true then the second argument, @var{then-part}, is +evaluated and this is used as the result of the evaluation of the entire +@code{if} function. + +If the condition is false then the third argument, @var{else-part}, is +evaluated and this is the result of the @code{if} function. If there is +no third argument, the @code{if} function evaluates to nothing (the +empty string). + +Note that only one of the @var{then-part} or the @var{else-part} will be +evaluated, never both. Thus, either can contain side-effects (such as +@code{shell} function calls, etc.) + +@node Call Function, Value Function, If Function, Functions +@section The @code{call} Function +@findex call +@cindex functions, user defined +@cindex user defined functions + +The @code{call} function is unique in that it can be used to create new +parameterized functions. You can write a complex expression as the +value of a variable, then use @code{call} to expand it with different +values. + +The syntax of the @code{call} function is: + +@example +$(call @var{variable},@var{param},@var{param},@dots{}) +@end example + +When @code{make} expands this function, it assigns each @var{param} to +temporary variables @code{$(1)}, @code{$(2)}, etc. The variable +@code{$(0)} will contain @var{variable}. There is no maximum number of +parameter arguments. There is no minimum, either, but it doesn't make +sense to use @code{call} with no parameters. + +Then @var{variable} is expanded as a @code{make} variable in the context +of these temporary assignments. Thus, any reference to @code{$(1)} in +the value of @var{variable} will resolve to the first @var{param} in the +invocation of @code{call}. + +Note that @var{variable} is the @emph{name} of a variable, not a +@emph{reference} to that variable. Therefore you would not normally use +a @samp{$} or parentheses when writing it. (You can, however, use a +variable reference in the name if you want the name not to be a +constant.) + +If @var{variable} is the name of a builtin function, the builtin function +is always invoked (even if a @code{make} variable by that name also +exists). + +The @code{call} function expands the @var{param} arguments before +assigning them to temporary variables. This means that @var{variable} +values containing references to builtin functions that have special +expansion rules, like @code{foreach} or @code{if}, may not work as you +expect. + +Some examples may make this clearer. + +This macro simply reverses its arguments: + +@smallexample +reverse = $(2) $(1) + +foo = $(call reverse,a,b) +@end smallexample + +@noindent +Here @var{foo} will contain @samp{b a}. + +This one is slightly more interesting: it defines a macro to search for +the first instance of a program in @code{PATH}: + +@smallexample +pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) + +LS := $(call pathsearch,ls) +@end smallexample + +@noindent +Now the variable LS contains @code{/bin/ls} or similar. + +The @code{call} function can be nested. Each recursive invocation gets +its own local values for @code{$(1)}, etc. that mask the values of +higher-level @code{call}. For example, here is an implementation of a +@dfn{map} function: + +@smallexample +map = $(foreach a,$(2),$(call $(1),$(a))) +@end smallexample + +Now you can @var{map} a function that normally takes only one argument, +such as @code{origin}, to multiple values in one step: + +@smallexample +o = $(call map,origin,o map MAKE) +@end smallexample + +and end up with @var{o} containing something like @samp{file file default}. + +A final caution: be careful when adding whitespace to the arguments to +@code{call}. As with other functions, any whitespace contained in the +second and subsequent arguments is kept; this can cause strange +effects. It's generally safest to remove all extraneous whitespace when +providing parameters to @code{call}. + +@node Value Function, Eval Function, Call Function, Functions +@comment node-name, next, previous, up +@section The @code{value} Function +@findex value +@cindex variables, unexpanded value + +The @code{value} function provides a way for you to use the value of a +variable @emph{without} having it expanded. Please note that this +does not undo expansions which have already occurred; for example if +you create a simply expanded variable its value is expanded during the +definition; in that case the @code{value} function will return the +same result as using the variable directly. + +The syntax of the @code{value} function is: + +@example +$(value @var{variable}) +@end example + +Note that @var{variable} is the @emph{name} of a variable; not a +@emph{reference} to that variable. Therefore you would not normally +use a @samp{$} or parentheses when writing it. (You can, however, use +a variable reference in the name if you want the name not to be a +constant.) + +The result of this function is a string containing the value of +@var{variable}, without any expansion occurring. For example, in this +makefile: + +@example +@group +FOO = $PATH + +all: + @@echo $(FOO) + @@echo $(value FOO) +@end group +@end example + +@noindent +The first output line would be @code{ATH}, since the ``$P'' would be +expanded as a @code{make} variable, while the second output line would +be the current value of your @code{$PATH} environment variable, since +the @code{value} function avoided the expansion. + +The @code{value} function is most often used in conjunction with the +@code{eval} function (@pxref{Eval Function}). + +@node Eval Function, Origin Function, Value Function, Functions +@comment node-name, next, previous, up +@section The @code{eval} Function +@findex eval +@cindex evaluating makefile syntax +@cindex makefile syntax, evaluating + +The @code{eval} function is very special: it allows you to define new +makefile constructs that are not constant; which are the result of +evaluating other variables and functions. The argument to the +@code{eval} function is expanded, then the results of that expansion +are parsed as makefile syntax. The expanded results can define new +@code{make} variables, targets, implicit or explicit rules, etc. + +The result of the @code{eval} function is always the empty string; +thus, it can be placed virtually anywhere in a makefile without +causing syntax errors. + +It's important to realize that the @code{eval} argument is expanded +@emph{twice}; first by the @code{eval} function, then the results of +that expansion are expanded again when they are parsed as makefile +syntax. This means you may need to provide extra levels of escaping +for ``$'' characters when using @code{eval}. The @code{value} +function (@pxref{Value Function}) can sometimes be useful in these +situations, to circumvent unwanted expansions. + +Here is an example of how @code{eval} can be used; this example +combines a number of concepts and other functions. Although it might +seem overly complex to use @code{eval} in this example, rather than +just writing out the rules, consider two things: first, the template +definition (in @code{PROGRAM_template}) could need to be much more +complex than it is here; and second, you might put the complex, +``generic'' part of this example into another makefile, then include +it in all the individual makefiles. Now your individual makefiles are +quite straightforward. + +@example +@group +PROGRAMS = server client + +server_OBJS = server.o server_priv.o server_access.o +server_LIBS = priv protocol + +client_OBJS = client.o client_api.o client_mem.o +client_LIBS = protocol + +# Everything after this is generic + +.PHONY: all +all: $(PROGRAMS) + +define PROGRAM_template + $(1): $$($(1)_OBJ) $$($(1)_LIBS:%=-l%) + ALL_OBJS += $$($(1)_OBJS) +endef + +$(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog)))) + +$(PROGRAMS): + $(LINK.o) $^ $(LDLIBS) -o $@@ + +clean: + rm -f $(ALL_OBJS) $(PROGRAMS) +@end group +@end example + +@node Origin Function, Shell Function, Eval Function, Functions +@section The @code{origin} Function +@findex origin +@cindex variables, origin of +@cindex origin of variable + +The @code{origin} function is unlike most other functions in that it does +not operate on the values of variables; it tells you something @emph{about} +a variable. Specifically, it tells you where it came from. + +The syntax of the @code{origin} function is: + +@example +$(origin @var{variable}) +@end example + +Note that @var{variable} is the @emph{name} of a variable to inquire about; +not a @emph{reference} to that variable. Therefore you would not normally +use a @samp{$} or parentheses when writing it. (You can, however, use a +variable reference in the name if you want the name not to be a constant.) + +The result of this function is a string telling you how the variable +@var{variable} was defined: + +@table @samp +@item undefined + +if @var{variable} was never defined. + +@item default + +if @var{variable} has a default definition, as is usual with @code{CC} +and so on. @xref{Implicit Variables, ,Variables Used by Implicit Rules}. +Note that if you have redefined a default variable, the @code{origin} +function will return the origin of the later definition. + +@item environment + +if @var{variable} was defined as an environment variable and the +@samp{-e} option is @emph{not} turned on (@pxref{Options Summary, ,Summary of Options}). + +@item environment override + +if @var{variable} was defined as an environment variable and the +@w{@samp{-e}} option @emph{is} turned on (@pxref{Options Summary, +,Summary of Options}).@refill + +@item file + +if @var{variable} was defined in a makefile. + +@item command line + +if @var{variable} was defined on the command line. + +@item override + +if @var{variable} was defined with an @code{override} directive in a +makefile (@pxref{Override Directive, ,The @code{override} Directive}). + +@item automatic + +if @var{variable} is an automatic variable defined for the +execution of the commands for each rule +(@pxref{Automatic, , Automatic Variables}). +@end table + +This information is primarily useful (other than for your curiosity) to +determine if you want to believe the value of a variable. For example, +suppose you have a makefile @file{foo} that includes another makefile +@file{bar}. You want a variable @code{bletch} to be defined in @file{bar} +if you run the command @w{@samp{make -f bar}}, even if the environment contains +a definition of @code{bletch}. However, if @file{foo} defined +@code{bletch} before including @file{bar}, you do not want to override that +definition. This could be done by using an @code{override} directive in +@file{foo}, giving that definition precedence over the later definition in +@file{bar}; unfortunately, the @code{override} directive would also +override any command line definitions. So, @file{bar} could +include:@refill + +@example +@group +ifdef bletch +ifeq "$(origin bletch)" "environment" +bletch = barf, gag, etc. +endif +endif +@end group +@end example + +@noindent +If @code{bletch} has been defined from the environment, this will redefine +it. + +If you want to override a previous definition of @code{bletch} if it came +from the environment, even under @samp{-e}, you could instead write: + +@example +@group +ifneq "$(findstring environment,$(origin bletch))" "" +bletch = barf, gag, etc. +endif +@end group +@end example + +Here the redefinition takes place if @samp{$(origin bletch)} returns either +@samp{environment} or @samp{environment override}. +@xref{Text Functions, , Functions for String Substitution and Analysis}. + +@node Shell Function, Make Control Functions, Origin Function, Functions +@section The @code{shell} Function +@findex shell +@cindex commands, expansion +@cindex backquotes +@cindex shell command, function for + +The @code{shell} function is unlike any other function except the +@code{wildcard} function +(@pxref{Wildcard Function, ,The Function @code{wildcard}}) in that it +communicates with the world outside of @code{make}. + +The @code{shell} function performs the same function that backquotes +(@samp{`}) perform in most shells: it does @dfn{command expansion}. This +means that it takes an argument that is a shell command and returns the +output of the command. The only processing @code{make} does on the result, +before substituting it into the surrounding text, is to convert each +newline or carriage-return / newline pair to a single space. It also +removes the trailing (carriage-return and) newline, if it's the last +thing in the result.@refill + +The commands run by calls to the @code{shell} function are run when the +function calls are expanded. In most cases, this is when the makefile is +read in. The exception is that function calls in the commands of the rules +are expanded when the commands are run, and this applies to @code{shell} +function calls like all others. + +Here are some examples of the use of the @code{shell} function: + +@example +contents := $(shell cat foo) +@end example + +@noindent +sets @code{contents} to the contents of the file @file{foo}, with a space +(rather than a newline) separating each line. + +@example +files := $(shell echo *.c) +@end example + +@noindent +sets @code{files} to the expansion of @samp{*.c}. Unless @code{make} is +using a very strange shell, this has the same result as +@w{@samp{$(wildcard *.c)}}.@refill + +@node Make Control Functions, , Shell Function, Functions +@section Functions That Control Make +@cindex functions, for controlling make +@cindex controlling make + +These functions control the way make runs. Generally, they are used to +provide information to the user of the makefile or to cause make to stop +if some sort of environmental error is detected. + +@table @code +@item $(error @var{text}@dots{}) +@findex error +@cindex error, stopping on +@cindex stopping make +Generates a fatal error where the message is @var{text}. Note that the +error is generated whenever this function is evaluated. So, if you put +it inside a command script or on the right side of a recursive variable +assignment, it won't be evaluated until later. The @var{text} will be +expanded before the error is generated. + +For example, + +@example +ifdef ERROR1 +$(error error is $(ERROR1)) +endif +@end example + +@noindent +will generate a fatal error during the read of the makefile if the +@code{make} variable @code{ERROR1} is defined. Or, + +@example +ERR = $(error found an error!) + +.PHONY: err +err: ; $(ERR) +@end example + +@noindent +will generate a fatal error while @code{make} is running, if the +@code{err} target is invoked. + +@item $(warning @var{text}@dots{}) +@findex warning +@cindex warnings, printing +@cindex printing user warnings +This function works similarly to the @code{error} function, above, +except that @code{make} doesn't exit. Instead, @var{text} is expanded +and the resulting message is displayed, but processing of the makefile +continues. + +The result of the expansion of this function is the empty string. +@end table + +@node Running, Implicit Rules, Functions, Top +@chapter How to Run @code{make} + +A makefile that says how to recompile a program can be used in more +than one way. The simplest use is to recompile every file that is out +of date. Usually, makefiles are written so that if you run +@code{make} with no arguments, it does just that. + +But you might want to update only some of the files; you might want to use +a different compiler or different compiler options; you might want just to +find out which files are out of date without changing them. + +By giving arguments when you run @code{make}, you can do any of these +things and many others. + +The exit status of @code{make} is always one of three values: +@table @code +@item 0 +The exit status is zero if @code{make} is successful. +@item 2 +The exit status is two if @code{make} encounters any errors. +It will print messages describing the particular errors. +@item 1 +The exit status is one if you use the @samp{-q} flag and @code{make} +determines that some target is not already up to date. +@xref{Instead of Execution, ,Instead of Executing the Commands}. +@end table + +@menu +* Makefile Arguments:: How to specify which makefile to use. +* Goals:: How to use goal arguments to specify which + parts of the makefile to use. +* Instead of Execution:: How to use mode flags to specify what + kind of thing to do with the commands + in the makefile other than simply + execute them. +* Avoiding Compilation:: How to avoid recompiling certain files. +* Overriding:: How to override a variable to specify + an alternate compiler and other things. +* Testing:: How to proceed past some errors, to + test compilation. +* Options Summary:: Summary of Options +@end menu + +@node Makefile Arguments, Goals, Running, Running +@section Arguments to Specify the Makefile +@cindex @code{--file} +@cindex @code{--makefile} +@cindex @code{-f} + +The way to specify the name of the makefile is with the @samp{-f} or +@samp{--file} option (@samp{--makefile} also works). For example, +@samp{-f altmake} says to use the file @file{altmake} as the makefile. + +If you use the @samp{-f} flag several times and follow each @samp{-f} +with an argument, all the specified files are used jointly as +makefiles. + +If you do not use the @samp{-f} or @samp{--file} flag, the default is +to try @file{GNUmakefile}, @file{makefile}, and @file{Makefile}, in +that order, and use the first of these three which exists or can be made +(@pxref{Makefiles, ,Writing Makefiles}).@refill + +@node Goals, Instead of Execution, Makefile Arguments, Running +@section Arguments to Specify the Goals +@cindex goal, how to specify + +The @dfn{goals} are the targets that @code{make} should strive ultimately +to update. Other targets are updated as well if they appear as +prerequisites of goals, or prerequisites of prerequisites of goals, etc. + +By default, the goal is the first target in the makefile (not counting +targets that start with a period). Therefore, makefiles are usually +written so that the first target is for compiling the entire program or +programs they describe. If the first rule in the makefile has several +targets, only the first target in the rule becomes the default goal, not +the whole list. + +You can specify a different goal or goals with arguments to @code{make}. +Use the name of the goal as an argument. If you specify several goals, +@code{make} processes each of them in turn, in the order you name them. + +Any target in the makefile may be specified as a goal (unless it +starts with @samp{-} or contains an @samp{=}, in which case it will be +parsed as a switch or variable definition, respectively). Even +targets not in the makefile may be specified, if @code{make} can find +implicit rules that say how to make them. + +@cindex @code{MAKECMDGOALS} +@vindex MAKECMDGOALS +@code{Make} will set the special variable @code{MAKECMDGOALS} to the +list of goals you specified on the command line. If no goals were given +on the command line, this variable is empty. Note that this variable +should be used only in special circumstances. + +An example of appropriate use is to avoid including @file{.d} files +during @code{clean} rules (@pxref{Automatic Prerequisites}), so +@code{make} won't create them only to immediately remove them +again:@refill + +@example +@group +sources = foo.c bar.c + +ifneq ($(MAKECMDGOALS),clean) +include $(sources:.c=.d) +endif +@end group +@end example + +One use of specifying a goal is if you want to compile only a part of +the program, or only one of several programs. Specify as a goal each +file that you wish to remake. For example, consider a directory containing +several programs, with a makefile that starts like this: + +@example +.PHONY: all +all: size nm ld ar as +@end example + +If you are working on the program @code{size}, you might want to say +@w{@samp{make size}} so that only the files of that program are recompiled. + +Another use of specifying a goal is to make files that are not normally +made. For example, there may be a file of debugging output, or a +version of the program that is compiled specially for testing, which has +a rule in the makefile but is not a prerequisite of the default goal. + +Another use of specifying a goal is to run the commands associated with +a phony target (@pxref{Phony Targets}) or empty target (@pxref{Empty +Targets, ,Empty Target Files to Record Events}). Many makefiles contain +a phony target named @file{clean} which deletes everything except source +files. Naturally, this is done only if you request it explicitly with +@w{@samp{make clean}}. Following is a list of typical phony and empty +target names. @xref{Standard Targets}, for a detailed list of all the +standard target names which GNU software packages use. + +@table @file +@item all +@cindex @code{all} @r{(standard target)} +Make all the top-level targets the makefile knows about. + +@item clean +@cindex @code{clean} @r{(standard target)} +Delete all files that are normally created by running @code{make}. + +@item mostlyclean +@cindex @code{mostlyclean} @r{(standard target)} +Like @samp{clean}, but may refrain from deleting a few files that people +normally don't want to recompile. For example, the @samp{mostlyclean} +target for GCC does not delete @file{libgcc.a}, because recompiling it +is rarely necessary and takes a lot of time. + +@item distclean +@cindex @code{distclean} @r{(standard target)} +@itemx realclean +@cindex @code{realclean} @r{(standard target)} +@itemx clobber +@cindex @code{clobber} @r{(standard target)} +Any of these targets might be defined to delete @emph{more} files than +@samp{clean} does. For example, this would delete configuration files +or links that you would normally create as preparation for compilation, +even if the makefile itself cannot create these files. + +@item install +@cindex @code{install} @r{(standard target)} +Copy the executable file into a directory that users typically search +for commands; copy any auxiliary files that the executable uses into +the directories where it will look for them. + +@item print +@cindex @code{print} @r{(standard target)} +Print listings of the source files that have changed. + +@item tar +@cindex @code{tar} @r{(standard target)} +Create a tar file of the source files. + +@item shar +@cindex @code{shar} @r{(standard target)} +Create a shell archive (shar file) of the source files. + +@item dist +@cindex @code{dist} @r{(standard target)} +Create a distribution file of the source files. This might +be a tar file, or a shar file, or a compressed version of one of the +above, or even more than one of the above. + +@item TAGS +@cindex @code{TAGS} @r{(standard target)} +Update a tags table for this program. + +@item check +@cindex @code{check} @r{(standard target)} +@itemx test +@cindex @code{test} @r{(standard target)} +Perform self tests on the program this makefile builds. +@end table + +@node Instead of Execution, Avoiding Compilation, Goals, Running +@section Instead of Executing the Commands +@cindex execution, instead of +@cindex commands, instead of executing + +The makefile tells @code{make} how to tell whether a target is up to date, +and how to update each target. But updating the targets is not always +what you want. Certain options specify other activities for @code{make}. + +@comment Extra blank lines make it print better. +@table @samp +@item -n +@itemx --just-print +@itemx --dry-run +@itemx --recon +@cindex @code{--just-print} +@cindex @code{--dry-run} +@cindex @code{--recon} +@cindex @code{-n} + +``No-op''. The activity is to print what commands would be used to make +the targets up to date, but not actually execute them. + +@item -t +@itemx --touch +@cindex @code{--touch} +@cindex touching files +@cindex target, touching +@cindex @code{-t} + +``Touch''. The activity is to mark the targets as up to date without +actually changing them. In other words, @code{make} pretends to compile +the targets but does not really change their contents. + +@item -q +@itemx --question +@cindex @code{--question} +@cindex @code{-q} +@cindex question mode + +``Question''. The activity is to find out silently whether the targets +are up to date already; but execute no commands in either case. In other +words, neither compilation nor output will occur. + +@item -W @var{file} +@itemx --what-if=@var{file} +@itemx --assume-new=@var{file} +@itemx --new-file=@var{file} +@cindex @code{--what-if} +@cindex @code{-W} +@cindex @code{--assume-new} +@cindex @code{--new-file} +@cindex what if +@cindex files, assuming new + +``What if''. Each @samp{-W} flag is followed by a file name. The given +files' modification times are recorded by @code{make} as being the present +time, although the actual modification times remain the same. +You can use the @samp{-W} flag in conjunction with the @samp{-n} flag +to see what would happen if you were to modify specific files.@refill +@end table + +With the @samp{-n} flag, @code{make} prints the commands that it would +normally execute but does not execute them. + +With the @samp{-t} flag, @code{make} ignores the commands in the rules +and uses (in effect) the command @code{touch} for each target that needs to +be remade. The @code{touch} command is also printed, unless @samp{-s} or +@code{.SILENT} is used. For speed, @code{make} does not actually invoke +the program @code{touch}. It does the work directly. + +With the @samp{-q} flag, @code{make} prints nothing and executes no +commands, but the exit status code it returns is zero if and only if the +targets to be considered are already up to date. If the exit status is +one, then some updating needs to be done. If @code{make} encounters an +error, the exit status is two, so you can distinguish an error from a +target that is not up to date. + +It is an error to use more than one of these three flags in the same +invocation of @code{make}. + +The @samp{-n}, @samp{-t}, and @samp{-q} options do not affect command +lines that begin with @samp{+} characters or contain the strings +@samp{$(MAKE)} or @samp{$@{MAKE@}}. Note that only the line containing +the @samp{+} character or the strings @samp{$(MAKE)} or @samp{$@{MAKE@}} +is run regardless of these options. Other lines in the same rule are +not run unless they too begin with @samp{+} or contain @samp{$(MAKE)} or +@samp{$@{MAKE@}} (@xref{MAKE Variable, ,How the @code{MAKE} Variable Works}.) + +The @samp{-W} flag provides two features: + +@itemize @bullet +@item +If you also use the @samp{-n} or @samp{-q} flag, you can see what +@code{make} would do if you were to modify some files. + +@item +Without the @samp{-n} or @samp{-q} flag, when @code{make} is actually +executing commands, the @samp{-W} flag can direct @code{make} to act +as if some files had been modified, without actually modifying the +files.@refill +@end itemize + +Note that the options @samp{-p} and @samp{-v} allow you to obtain other +information about @code{make} or about the makefiles in use +(@pxref{Options Summary, ,Summary of Options}).@refill + +@node Avoiding Compilation, Overriding, Instead of Execution, Running +@section Avoiding Recompilation of Some Files +@cindex @code{-o} +@cindex @code{--old-file} +@cindex @code{--assume-old} +@cindex files, assuming old +@cindex files, avoiding recompilation of +@cindex recompilation, avoiding + +Sometimes you may have changed a source file but you do not want to +recompile all the files that depend on it. For example, suppose you add +a macro or a declaration to a header file that many other files depend +on. Being conservative, @code{make} assumes that any change in the +header file requires recompilation of all dependent files, but you know +that they do not need to be recompiled and you would rather not waste +the time waiting for them to compile. + +If you anticipate the problem before changing the header file, you can +use the @samp{-t} flag. This flag tells @code{make} not to run the +commands in the rules, but rather to mark the target up to date by +changing its last-modification date. You would follow this procedure: + +@enumerate +@item +Use the command @samp{make} to recompile the source files that really +need recompilation, ensuring that the object files are up-to-date +before you begin. + +@item +Make the changes in the header files. + +@item +Use the command @samp{make -t} to mark all the object files as +up to date. The next time you run @code{make}, the changes in the +header files will not cause any recompilation. +@end enumerate + +If you have already changed the header file at a time when some files +do need recompilation, it is too late to do this. Instead, you can +use the @w{@samp{-o @var{file}}} flag, which marks a specified file as +``old'' (@pxref{Options Summary, ,Summary of Options}). This means +that the file itself will not be remade, and nothing else will be +remade on its account. Follow this procedure: + +@enumerate +@item +Recompile the source files that need compilation for reasons independent +of the particular header file, with @samp{make -o @var{headerfile}}. +If several header files are involved, use a separate @samp{-o} option +for each header file. + +@item +Touch all the object files with @samp{make -t}. +@end enumerate + +@node Overriding, Testing, Avoiding Compilation, Running +@section Overriding Variables +@cindex overriding variables with arguments +@cindex variables, overriding with arguments +@cindex command line variables +@cindex variables, command line + +An argument that contains @samp{=} specifies the value of a variable: +@samp{@var{v}=@var{x}} sets the value of the variable @var{v} to @var{x}. +If you specify a value in this way, all ordinary assignments of the same +variable in the makefile are ignored; we say they have been +@dfn{overridden} by the command line argument. + +The most common way to use this facility is to pass extra flags to +compilers. For example, in a properly written makefile, the variable +@code{CFLAGS} is included in each command that runs the C compiler, so a +file @file{foo.c} would be compiled something like this: + +@example +cc -c $(CFLAGS) foo.c +@end example + +Thus, whatever value you set for @code{CFLAGS} affects each compilation +that occurs. The makefile probably specifies the usual value for +@code{CFLAGS}, like this: + +@example +CFLAGS=-g +@end example + +Each time you run @code{make}, you can override this value if you +wish. For example, if you say @samp{make CFLAGS='-g -O'}, each C +compilation will be done with @samp{cc -c -g -O}. (This also +illustrates how you can use quoting in the shell to enclose spaces and +other special characters in the value of a variable when you override +it.) + +The variable @code{CFLAGS} is only one of many standard variables that +exist just so that you can change them this way. @xref{Implicit +Variables, , Variables Used by Implicit Rules}, for a complete list. + +You can also program the makefile to look at additional variables of your +own, giving the user the ability to control other aspects of how the +makefile works by changing the variables. + +When you override a variable with a command argument, you can define either +a recursively-expanded variable or a simply-expanded variable. The +examples shown above make a recursively-expanded variable; to make a +simply-expanded variable, write @samp{:=} instead of @samp{=}. But, unless +you want to include a variable reference or function call in the +@emph{value} that you specify, it makes no difference which kind of +variable you create. + +There is one way that the makefile can change a variable that you have +overridden. This is to use the @code{override} directive, which is a line +that looks like this: @samp{override @var{variable} = @var{value}} +(@pxref{Override Directive, ,The @code{override} Directive}). + +@node Testing, Options Summary, Overriding, Running +@section Testing the Compilation of a Program +@cindex testing compilation +@cindex compilation, testing + +Normally, when an error happens in executing a shell command, @code{make} +gives up immediately, returning a nonzero status. No further commands are +executed for any target. The error implies that the goal cannot be +correctly remade, and @code{make} reports this as soon as it knows. + +When you are compiling a program that you have just changed, this is not +what you want. Instead, you would rather that @code{make} try compiling +every file that can be tried, to show you as many compilation errors +as possible. + +@cindex @code{-k} +@cindex @code{--keep-going} +On these occasions, you should use the @samp{-k} or +@samp{--keep-going} flag. This tells @code{make} to continue to +consider the other prerequisites of the pending targets, remaking them +if necessary, before it gives up and returns nonzero status. For +example, after an error in compiling one object file, @samp{make -k} +will continue compiling other object files even though it already +knows that linking them will be impossible. In addition to continuing +after failed shell commands, @samp{make -k} will continue as much as +possible after discovering that it does not know how to make a target +or prerequisite file. This will always cause an error message, but +without @samp{-k}, it is a fatal error (@pxref{Options Summary, +,Summary of Options}).@refill + +The usual behavior of @code{make} assumes that your purpose is to get the +goals up to date; once @code{make} learns that this is impossible, it might +as well report the failure immediately. The @samp{-k} flag says that the +real purpose is to test as much as possible of the changes made in the +program, perhaps to find several independent problems so that you can +correct them all before the next attempt to compile. This is why Emacs' +@kbd{M-x compile} command passes the @samp{-k} flag by default. + +@node Options Summary, , Testing, Running +@section Summary of Options +@cindex options +@cindex flags +@cindex switches + +Here is a table of all the options @code{make} understands: + +@table @samp +@item -b +@cindex @code{-b} +@itemx -m +@cindex @code{-m} +These options are ignored for compatibility with other versions of @code{make}. + +@item -C @var{dir} +@cindex @code{-C} +@itemx --directory=@var{dir} +@cindex @code{--directory} +Change to directory @var{dir} before reading the makefiles. If multiple +@samp{-C} options are specified, each is interpreted relative to the +previous one: @samp{-C / -C etc} is equivalent to @samp{-C /etc}. +This is typically used with recursive invocations of @code{make} +(@pxref{Recursion, ,Recursive Use of @code{make}}). + +@item -d +@cindex @code{-d} +@c Extra blank line here makes the table look better. + +Print debugging information in addition to normal processing. The +debugging information says which files are being considered for +remaking, which file-times are being compared and with what results, +which files actually need to be remade, which implicit rules are +considered and which are applied---everything interesting about how +@code{make} decides what to do. The @code{-d} option is equivalent to +@samp{--debug=a} (see below). + +@item --debug[=@var{options}] +@cindex @code{--debug} +@c Extra blank line here makes the table look better. + +Print debugging information in addition to normal processing. Various +levels and types of output can be chosen. With no arguments, print the +``basic'' level of debugging. Possible arguments are below; only the +first character is considered, and values must be comma- or +space-separated. + +@table @code +@item a (@i{all}) +All types of debugging output are enabled. This is equivalent to using +@samp{-d}. + +@item b (@i{basic}) +Basic debugging prints each target that was found to be out-of-date, and +whether the build was successful or not. + +@item v (@i{verbose}) +A level above @samp{basic}; includes messages about which makefiles were +parsed, prerequisites that did not need to be rebuilt, etc. This option +also enables @samp{basic} messages. + +@item i (@i{implicit}) +Prints messages describing the implicit rule searches for each target. +This option also enables @samp{basic} messages. + +@item j (@i{jobs}) +Prints messages giving details on the invocation of specific subcommands. + +@item m (@i{makefile}) +By default, the above messages are not enabled while trying to remake +the makefiles. This option enables messages while rebuilding makefiles, +too. Note that the @samp{all} option does enable this option. This +option also enables @samp{basic} messages. +@end table + +@item -e +@cindex @code{-e} +@itemx --environment-overrides +@cindex @code{--environment-overrides} +Give variables taken from the environment precedence +over variables from makefiles. +@xref{Environment, ,Variables from the Environment}. + +@item -f @var{file} +@cindex @code{-f} +@itemx --file=@var{file} +@cindex @code{--file} +@itemx --makefile=@var{file} +@cindex @code{--makefile} +Read the file named @var{file} as a makefile. +@xref{Makefiles, ,Writing Makefiles}. + +@item -h +@cindex @code{-h} +@itemx --help +@cindex @code{--help} +@c Extra blank line here makes the table look better. + +Remind you of the options that @code{make} understands and then exit. + +@item -i +@cindex @code{-i} +@itemx --ignore-errors +@cindex @code{--ignore-errors} +Ignore all errors in commands executed to remake files. +@xref{Errors, ,Errors in Commands}. + +@item -I @var{dir} +@cindex @code{-I} +@itemx --include-dir=@var{dir} +@cindex @code{--include-dir} +Specifies a directory @var{dir} to search for included makefiles. +@xref{Include, ,Including Other Makefiles}. If several @samp{-I} +options are used to specify several directories, the directories are +searched in the order specified. + +@item -j [@var{jobs}] +@cindex @code{-j} +@itemx --jobs[=@var{jobs}] +@cindex @code{--jobs} +Specifies the number of jobs (commands) to run simultaneously. With no +argument, @code{make} runs as many jobs simultaneously as possible. If +there is more than one @samp{-j} option, the last one is effective. +@xref{Parallel, ,Parallel Execution}, +for more information on how commands are run. +Note that this option is ignored on MS-DOS. + +@item -k +@cindex @code{-k} +@itemx --keep-going +@cindex @code{--keep-going} +Continue as much as possible after an error. While the target that +failed, and those that depend on it, cannot be remade, the other +prerequisites of these targets can be processed all the same. +@xref{Testing, ,Testing the Compilation of a Program}. + +@item -l [@var{load}] +@cindex @code{-l} +@itemx --load-average[=@var{load}] +@cindex @code{--load-average} +@itemx --max-load[=@var{load}] +@cindex @code{--max-load} +Specifies that no new jobs (commands) should be started if there are +other jobs running and the load average is at least @var{load} (a +floating-point number). With no argument, removes a previous load +limit. @xref{Parallel, ,Parallel Execution}. + +@item -n +@cindex @code{-n} +@itemx --just-print +@cindex @code{--just-print} +@itemx --dry-run +@cindex @code{--dry-run} +@itemx --recon +@cindex @code{--recon} +@c Extra blank line here makes the table look better. + +Print the commands that would be executed, but do not execute them. +@xref{Instead of Execution, ,Instead of Executing the Commands}. + +@item -o @var{file} +@cindex @code{-o} +@itemx --old-file=@var{file} +@cindex @code{--old-file} +@itemx --assume-old=@var{file} +@cindex @code{--assume-old} +Do not remake the file @var{file} even if it is older than its +prerequisites, and do not remake anything on account of changes in +@var{file}. Essentially the file is treated as very old and its rules +are ignored. @xref{Avoiding Compilation, ,Avoiding Recompilation of +Some Files}.@refill + +@item -p +@cindex @code{-p} +@itemx --print-data-base +@cindex @code{--print-data-base} +@cindex data base of @code{make} rules +@cindex predefined rules and variables, printing +Print the data base (rules and variable values) that results from +reading the makefiles; then execute as usual or as otherwise specified. +This also prints the version information given by the @samp{-v} switch +(see below). To print the data base without trying to remake any files, +use @w{@samp{make -qp}}. To print the data base of predefined rules and +variables, use @w{@samp{make -p -f /dev/null}}. The data base output +contains filename and linenumber information for command and variable +definitions, so it can be a useful debugging tool in complex environments. + +@item -q +@cindex @code{-q} +@itemx --question +@cindex @code{--question} +``Question mode''. Do not run any commands, or print anything; just +return an exit status that is zero if the specified targets are already +up to date, one if any remaking is required, or two if an error is +encountered. @xref{Instead of Execution, ,Instead of Executing the +Commands}.@refill + +@item -r +@cindex @code{-r} +@itemx --no-builtin-rules +@cindex @code{--no-builtin-rules} +Eliminate use of the built-in implicit rules (@pxref{Implicit Rules, +,Using Implicit Rules}). You can still define your own by writing +pattern rules (@pxref{Pattern Rules, ,Defining and Redefining Pattern +Rules}). The @samp{-r} option also clears out the default list of +suffixes for suffix rules (@pxref{Suffix Rules, ,Old-Fashioned Suffix +Rules}). But you can still define your own suffixes with a rule for +@code{.SUFFIXES}, and then define your own suffix rules. Note that only +@emph{rules} are affected by the @code{-r} option; default variables +remain in effect (@pxref{Implicit Variables, ,Variables Used by Implicit +Rules}); see the @samp{-R} option below. + +@item -R +@cindex @code{-R} +@itemx --no-builtin-variables +@cindex @code{--no-builtin-variables} +Eliminate use of the built-in rule-specific variables (@pxref{Implicit +Variables, ,Variables Used by Implicit Rules}). You can still define +your own, of course. The @samp{-R} option also automatically enables +the @samp{-r} option (see above), since it doesn't make sense to have +implicit rules without any definitions for the variables that they use. + +@item -s +@cindex @code{-s} +@itemx --silent +@cindex @code{--silent} +@itemx --quiet +@cindex @code{--quiet} +@c Extra blank line here makes the table look better. + +Silent operation; do not print the commands as they are executed. +@xref{Echoing, ,Command Echoing}. + +@item -S +@cindex @code{-S} +@itemx --no-keep-going +@cindex @code{--no-keep-going} +@itemx --stop +@cindex @code{--stop} +@c Extra blank line here makes the table look better. + +Cancel the effect of the @samp{-k} option. This is never necessary +except in a recursive @code{make} where @samp{-k} might be inherited +from the top-level @code{make} via @code{MAKEFLAGS} +(@pxref{Recursion, ,Recursive Use of @code{make}}) +or if you set @samp{-k} in @code{MAKEFLAGS} in your environment.@refill + +@item -t +@cindex @code{-t} +@itemx --touch +@cindex @code{--touch} +@c Extra blank line here makes the table look better. + +Touch files (mark them up to date without really changing them) +instead of running their commands. This is used to pretend that the +commands were done, in order to fool future invocations of +@code{make}. @xref{Instead of Execution, ,Instead of Executing the Commands}. + +@item -v +@cindex @code{-v} +@itemx --version +@cindex @code{--version} +Print the version of the @code{make} program plus a copyright, a list +of authors, and a notice that there is no warranty; then exit. + +@item -w +@cindex @code{-w} +@itemx --print-directory +@cindex @code{--print-directory} +Print a message containing the working directory both before and after +executing the makefile. This may be useful for tracking down errors +from complicated nests of recursive @code{make} commands. +@xref{Recursion, ,Recursive Use of @code{make}}. (In practice, you +rarely need to specify this option since @samp{make} does it for you; +see @ref{-w Option, ,The @samp{--print-directory} Option}.) + +@itemx --no-print-directory +@cindex @code{--no-print-directory} +Disable printing of the working directory under @code{-w}. +This option is useful when @code{-w} is turned on automatically, +but you do not want to see the extra messages. +@xref{-w Option, ,The @samp{--print-directory} Option}. + +@item -W @var{file} +@cindex @code{-W} +@itemx --what-if=@var{file} +@cindex @code{--what-if} +@itemx --new-file=@var{file} +@cindex @code{--new-file} +@itemx --assume-new=@var{file} +@cindex @code{--assume-new} +Pretend that the target @var{file} has just been modified. When used +with the @samp{-n} flag, this shows you what would happen if you were +to modify that file. Without @samp{-n}, it is almost the same as +running a @code{touch} command on the given file before running +@code{make}, except that the modification time is changed only in the +imagination of @code{make}. +@xref{Instead of Execution, ,Instead of Executing the Commands}. + +@item --warn-undefined-variables +@cindex @code{--warn-undefined-variables} +@cindex variables, warning for undefined +@cindex undefined variables, warning message +Issue a warning message whenever @code{make} sees a reference to an +undefined variable. This can be helpful when you are trying to debug +makefiles which use variables in complex ways. +@end table + +@node Implicit Rules, Archives, Running, Top +@chapter Using Implicit Rules +@cindex implicit rule +@cindex rule, implicit + +Certain standard ways of remaking target files are used very often. For +example, one customary way to make an object file is from a C source file +using the C compiler, @code{cc}. + +@dfn{Implicit rules} tell @code{make} how to use customary techniques so +that you do not have to specify them in detail when you want to use +them. For example, there is an implicit rule for C compilation. File +names determine which implicit rules are run. For example, C +compilation typically takes a @file{.c} file and makes a @file{.o} file. +So @code{make} applies the implicit rule for C compilation when it sees +this combination of file name endings.@refill + +A chain of implicit rules can apply in sequence; for example, @code{make} +will remake a @file{.o} file from a @file{.y} file by way of a @file{.c} file. +@iftex +@xref{Chained Rules, ,Chains of Implicit Rules}. +@end iftex + +The built-in implicit rules use several variables in their commands so +that, by changing the values of the variables, you can change the way the +implicit rule works. For example, the variable @code{CFLAGS} controls the +flags given to the C compiler by the implicit rule for C compilation. +@iftex +@xref{Implicit Variables, ,Variables Used by Implicit Rules}. +@end iftex + +You can define your own implicit rules by writing @dfn{pattern rules}. +@iftex +@xref{Pattern Rules, ,Defining and Redefining Pattern Rules}. +@end iftex + +@dfn{Suffix rules} are a more limited way to define implicit rules. +Pattern rules are more general and clearer, but suffix rules are +retained for compatibility. +@iftex +@xref{Suffix Rules, ,Old-Fashioned Suffix Rules}. +@end iftex + +@menu +* Using Implicit:: How to use an existing implicit rule + to get the commands for updating a file. +* Catalogue of Rules:: A list of built-in implicit rules. +* Implicit Variables:: How to change what predefined rules do. +* Chained Rules:: How to use a chain of implicit rules. +* Pattern Rules:: How to define new implicit rules. +* Last Resort:: How to defining commands for rules + which cannot find any. +* Suffix Rules:: The old-fashioned style of implicit rule. +* Implicit Rule Search:: The precise algorithm for applying + implicit rules. +@end menu + +@node Using Implicit, Catalogue of Rules, Implicit Rules, Implicit Rules +@section Using Implicit Rules +@cindex implicit rule, how to use +@cindex rule, implicit, how to use + +To allow @code{make} to find a customary method for updating a target file, +all you have to do is refrain from specifying commands yourself. Either +write a rule with no command lines, or don't write a rule at all. Then +@code{make} will figure out which implicit rule to use based on which +kind of source file exists or can be made. + +For example, suppose the makefile looks like this: + +@example +foo : foo.o bar.o + cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS) +@end example + +@noindent +Because you mention @file{foo.o} but do not give a rule for it, @code{make} +will automatically look for an implicit rule that tells how to update it. +This happens whether or not the file @file{foo.o} currently exists. + +If an implicit rule is found, it can supply both commands and one or +more prerequisites (the source files). You would want to write a rule +for @file{foo.o} with no command lines if you need to specify additional +prerequisites, such as header files, that the implicit rule cannot +supply. + +Each implicit rule has a target pattern and prerequisite patterns. There may +be many implicit rules with the same target pattern. For example, numerous +rules make @samp{.o} files: one, from a @samp{.c} file with the C compiler; +another, from a @samp{.p} file with the Pascal compiler; and so on. The rule +that actually applies is the one whose prerequisites exist or can be made. +So, if you have a file @file{foo.c}, @code{make} will run the C compiler; +otherwise, if you have a file @file{foo.p}, @code{make} will run the Pascal +compiler; and so on. + +Of course, when you write the makefile, you know which implicit rule you +want @code{make} to use, and you know it will choose that one because you +know which possible prerequisite files are supposed to exist. +@xref{Catalogue of Rules, ,Catalogue of Implicit Rules}, +for a catalogue of all the predefined implicit rules. + +Above, we said an implicit rule applies if the required prerequisites ``exist +or can be made''. A file ``can be made'' if it is mentioned explicitly in +the makefile as a target or a prerequisite, or if an implicit rule can be +recursively found for how to make it. When an implicit prerequisite is the +result of another implicit rule, we say that @dfn{chaining} is occurring. +@xref{Chained Rules, ,Chains of Implicit Rules}. + +In general, @code{make} searches for an implicit rule for each target, and +for each double-colon rule, that has no commands. A file that is mentioned +only as a prerequisite is considered a target whose rule specifies nothing, +so implicit rule search happens for it. @xref{Implicit Rule Search, ,Implicit Rule Search Algorithm}, for the +details of how the search is done. + +Note that explicit prerequisites do not influence implicit rule search. +For example, consider this explicit rule: + +@example +foo.o: foo.p +@end example + +@noindent +The prerequisite on @file{foo.p} does not necessarily mean that +@code{make} will remake @file{foo.o} according to the implicit rule to +make an object file, a @file{.o} file, from a Pascal source file, a +@file{.p} file. For example, if @file{foo.c} also exists, the implicit +rule to make an object file from a C source file is used instead, +because it appears before the Pascal rule in the list of predefined +implicit rules (@pxref{Catalogue of Rules, , Catalogue of Implicit +Rules}). + +If you do not want an implicit rule to be used for a target that has no +commands, you can give that target empty commands by writing a semicolon +(@pxref{Empty Commands, ,Defining Empty Commands}). + +@node Catalogue of Rules, Implicit Variables, Using Implicit, Implicit Rules +@section Catalogue of Implicit Rules +@cindex implicit rule, predefined +@cindex rule, implicit, predefined + +Here is a catalogue of predefined implicit rules which are always +available unless the makefile explicitly overrides or cancels them. +@xref{Canceling Rules, ,Canceling Implicit Rules}, for information on +canceling or overriding an implicit rule. The @samp{-r} or +@samp{--no-builtin-rules} option cancels all predefined rules. + +Not all of these rules will always be defined, even when the @samp{-r} +option is not given. Many of the predefined implicit rules are +implemented in @code{make} as suffix rules, so which ones will be +defined depends on the @dfn{suffix list} (the list of prerequisites of +the special target @code{.SUFFIXES}). The default suffix list is: +@code{.out}, @code{.a}, @code{.ln}, @code{.o}, @code{.c}, @code{.cc}, +@code{.C}, @code{.p}, @code{.f}, @code{.F}, @code{.r}, @code{.y}, +@code{.l}, @code{.s}, @code{.S}, @code{.mod}, @code{.sym}, @code{.def}, +@code{.h}, @code{.info}, @code{.dvi}, @code{.tex}, @code{.texinfo}, +@code{.texi}, @code{.txinfo}, @code{.w}, @code{.ch} @code{.web}, +@code{.sh}, @code{.elc}, @code{.el}. All of the implicit rules +described below whose prerequisites have one of these suffixes are +actually suffix rules. If you modify the suffix list, the only +predefined suffix rules in effect will be those named by one or two of +the suffixes that are on the list you specify; rules whose suffixes fail +to be on the list are disabled. @xref{Suffix Rules, ,Old-Fashioned +Suffix Rules}, for full details on suffix rules. + +@table @asis +@item Compiling C programs +@cindex C, rule to compile +@pindex cc +@pindex gcc +@pindex .o +@pindex .c +@file{@var{n}.o} is made automatically from @file{@var{n}.c} with +a command of the form @samp{$(CC) -c $(CPPFLAGS) $(CFLAGS)}.@refill + +@item Compiling C++ programs +@cindex C++, rule to compile +@pindex g++ +@pindex .C +@pindex .cc +@file{@var{n}.o} is made automatically from @file{@var{n}.cc} or +@file{@var{n}.C} with a command of the form @samp{$(CXX) -c $(CPPFLAGS) +$(CXXFLAGS)}. We encourage you to use the suffix @samp{.cc} for C++ +source files instead of @samp{.C}.@refill + +@item Compiling Pascal programs +@cindex Pascal, rule to compile +@pindex pc +@pindex .p +@file{@var{n}.o} is made automatically from @file{@var{n}.p} +with the command @samp{$(PC) -c $(PFLAGS)}.@refill + +@item Compiling Fortran and Ratfor programs +@cindex Fortran, rule to compile +@cindex Ratfor, rule to compile +@pindex f77 +@pindex .f +@pindex .r +@pindex .F +@file{@var{n}.o} is made automatically from @file{@var{n}.r}, +@file{@var{n}.F} or @file{@var{n}.f} by running the +Fortran compiler. The precise command used is as follows:@refill + +@table @samp +@item .f +@samp{$(FC) -c $(FFLAGS)}. +@item .F +@samp{$(FC) -c $(FFLAGS) $(CPPFLAGS)}. +@item .r +@samp{$(FC) -c $(FFLAGS) $(RFLAGS)}. +@end table + +@item Preprocessing Fortran and Ratfor programs +@file{@var{n}.f} is made automatically from @file{@var{n}.r} or +@file{@var{n}.F}. This rule runs just the preprocessor to convert a +Ratfor or preprocessable Fortran program into a strict Fortran +program. The precise command used is as follows:@refill + +@table @samp +@item .F +@samp{$(FC) -F $(CPPFLAGS) $(FFLAGS)}. +@item .r +@samp{$(FC) -F $(FFLAGS) $(RFLAGS)}. +@end table + +@item Compiling Modula-2 programs +@cindex Modula-2, rule to compile +@pindex m2c +@pindex .sym +@pindex .def +@pindex .mod +@file{@var{n}.sym} is made from @file{@var{n}.def} with a command +of the form @samp{$(M2C) $(M2FLAGS) $(DEFFLAGS)}. @file{@var{n}.o} +is made from @file{@var{n}.mod}; the form is: +@w{@samp{$(M2C) $(M2FLAGS) $(MODFLAGS)}}.@refill + +@need 1200 +@item Assembling and preprocessing assembler programs +@cindex assembly, rule to compile +@pindex as +@pindex .s +@file{@var{n}.o} is made automatically from @file{@var{n}.s} by +running the assembler, @code{as}. The precise command is +@samp{$(AS) $(ASFLAGS)}.@refill + +@pindex .S +@file{@var{n}.s} is made automatically from @file{@var{n}.S} by +running the C preprocessor, @code{cpp}. The precise command is +@w{@samp{$(CPP) $(CPPFLAGS)}}. + +@item Linking a single object file +@cindex linking, predefined rule for +@pindex ld +@pindex .o +@file{@var{n}} is made automatically from @file{@var{n}.o} by running +the linker (usually called @code{ld}) via the C compiler. The precise +command used is @w{@samp{$(CC) $(LDFLAGS) @var{n}.o $(LOADLIBES) $(LDLIBS)}}. + +This rule does the right thing for a simple program with only one +source file. It will also do the right thing if there are multiple +object files (presumably coming from various other source files), one +of which has a name matching that of the executable file. Thus, + +@example +x: y.o z.o +@end example + +@noindent +when @file{x.c}, @file{y.c} and @file{z.c} all exist will execute: + +@example +@group +cc -c x.c -o x.o +cc -c y.c -o y.o +cc -c z.c -o z.o +cc x.o y.o z.o -o x +rm -f x.o +rm -f y.o +rm -f z.o +@end group +@end example + +@noindent +In more complicated cases, such as when there is no object file whose +name derives from the executable file name, you must write an explicit +command for linking. + +Each kind of file automatically made into @samp{.o} object files will +be automatically linked by using the compiler (@samp{$(CC)}, +@samp{$(FC)} or @samp{$(PC)}; the C compiler @samp{$(CC)} is used to +assemble @samp{.s} files) without the @samp{-c} option. This could be +done by using the @samp{.o} object files as intermediates, but it is +faster to do the compiling and linking in one step, so that's how it's +done.@refill + +@item Yacc for C programs +@pindex yacc +@cindex Yacc, rule to run +@pindex .y +@file{@var{n}.c} is made automatically from @file{@var{n}.y} by +running Yacc with the command @samp{$(YACC) $(YFLAGS)}. + +@item Lex for C programs +@pindex lex +@cindex Lex, rule to run +@pindex .l +@file{@var{n}.c} is made automatically from @file{@var{n}.l} by +running Lex. The actual command is @samp{$(LEX) $(LFLAGS)}. + +@item Lex for Ratfor programs +@file{@var{n}.r} is made automatically from @file{@var{n}.l} by +running Lex. The actual command is @samp{$(LEX) $(LFLAGS)}. + +The convention of using the same suffix @samp{.l} for all Lex files +regardless of whether they produce C code or Ratfor code makes it +impossible for @code{make} to determine automatically which of the two +languages you are using in any particular case. If @code{make} is +called upon to remake an object file from a @samp{.l} file, it must +guess which compiler to use. It will guess the C compiler, because +that is more common. If you are using Ratfor, make sure @code{make} +knows this by mentioning @file{@var{n}.r} in the makefile. Or, if you +are using Ratfor exclusively, with no C files, remove @samp{.c} from +the list of implicit rule suffixes with:@refill + +@example +@group +.SUFFIXES: +.SUFFIXES: .o .r .f .l @dots{} +@end group +@end example + +@item Making Lint Libraries from C, Yacc, or Lex programs +@pindex lint +@cindex @code{lint}, rule to run +@pindex .ln +@file{@var{n}.ln} is made from @file{@var{n}.c} by running @code{lint}. +The precise command is @w{@samp{$(LINT) $(LINTFLAGS) $(CPPFLAGS) -i}}. +The same command is used on the C code produced from +@file{@var{n}.y} or @file{@var{n}.l}.@refill + +@item @TeX{} and Web +@cindex @TeX{}, rule to run +@cindex Web, rule to run +@pindex tex +@pindex cweave +@pindex weave +@pindex tangle +@pindex ctangle +@pindex .dvi +@pindex .tex +@pindex .web +@pindex .w +@pindex .ch +@file{@var{n}.dvi} is made from @file{@var{n}.tex} with the command +@samp{$(TEX)}. @file{@var{n}.tex} is made from @file{@var{n}.web} with +@samp{$(WEAVE)}, or from @file{@var{n}.w} (and from @file{@var{n}.ch} if +it exists or can be made) with @samp{$(CWEAVE)}. @file{@var{n}.p} is +made from @file{@var{n}.web} with @samp{$(TANGLE)} and @file{@var{n}.c} +is made from @file{@var{n}.w} (and from @file{@var{n}.ch} if it exists +or can be made) with @samp{$(CTANGLE)}.@refill + +@item Texinfo and Info +@cindex Texinfo, rule to format +@cindex Info, rule to format +@pindex texi2dvi +@pindex makeinfo +@pindex .texinfo +@pindex .info +@pindex .texi +@pindex .txinfo +@file{@var{n}.dvi} is made from @file{@var{n}.texinfo}, +@file{@var{n}.texi}, or @file{@var{n}.txinfo}, with the command +@w{@samp{$(TEXI2DVI) $(TEXI2DVI_FLAGS)}}. @file{@var{n}.info} is made from +@file{@var{n}.texinfo}, @file{@var{n}.texi}, or @file{@var{n}.txinfo}, with +the command @w{@samp{$(MAKEINFO) $(MAKEINFO_FLAGS)}}. + +@item RCS +@cindex RCS, rule to extract from +@pindex co +@pindex ,v @r{(RCS file extension)} +Any file @file{@var{n}} is extracted if necessary from an RCS file +named either @file{@var{n},v} or @file{RCS/@var{n},v}. The precise +command used is @w{@samp{$(CO) $(COFLAGS)}}. @file{@var{n}} will not be +extracted from RCS if it already exists, even if the RCS file is +newer. The rules for RCS are terminal +(@pxref{Match-Anything Rules, ,Match-Anything Pattern Rules}), +so RCS files cannot be generated from another source; they must +actually exist.@refill + +@item SCCS +@cindex SCCS, rule to extract from +@pindex get +@pindex s. @r{(SCCS file prefix)} +Any file @file{@var{n}} is extracted if necessary from an SCCS file +named either @file{s.@var{n}} or @file{SCCS/s.@var{n}}. The precise +command used is @w{@samp{$(GET) $(GFLAGS)}}. The rules for SCCS are +terminal (@pxref{Match-Anything Rules, ,Match-Anything Pattern Rules}), +so SCCS files cannot be generated from another source; they must +actually exist.@refill + +@pindex .sh +For the benefit of SCCS, a file @file{@var{n}} is copied from +@file{@var{n}.sh} and made executable (by everyone). This is for +shell scripts that are checked into SCCS. Since RCS preserves the +execution permission of a file, you do not need to use this feature +with RCS.@refill + +We recommend that you avoid using of SCCS. RCS is widely held to be +superior, and is also free. By choosing free software in place of +comparable (or inferior) proprietary software, you support the free +software movement. +@end table + +Usually, you want to change only the variables listed in the table +above, which are documented in the following section. + +However, the commands in built-in implicit rules actually use +variables such as @code{COMPILE.c}, @code{LINK.p}, and +@code{PREPROCESS.S}, whose values contain the commands listed above. + +@code{make} follows the convention that the rule to compile a +@file{.@var{x}} source file uses the variable @code{COMPILE.@var{x}}. +Similarly, the rule to produce an executable from a @file{.@var{x}} +file uses @code{LINK.@var{x}}; and the rule to preprocess a +@file{.@var{x}} file uses @code{PREPROCESS.@var{x}}. + +@vindex OUTPUT_OPTION +Every rule that produces an object file uses the variable +@code{OUTPUT_OPTION}. @code{make} defines this variable either to +contain @samp{-o $@@}, or to be empty, depending on a compile-time +option. You need the @samp{-o} option to ensure that the output goes +into the right file when the source file is in a different directory, +as when using @code{VPATH} (@pxref{Directory Search}). However, +compilers on some systems do not accept a @samp{-o} switch for object +files. If you use such a system, and use @code{VPATH}, some +compilations will put their output in the wrong place. +A possible workaround for this problem is to give @code{OUTPUT_OPTION} +the value @w{@samp{; mv $*.o $@@}}. + +@node Implicit Variables, Chained Rules, Catalogue of Rules, Implicit Rules +@section Variables Used by Implicit Rules +@cindex flags for compilers + +The commands in built-in implicit rules make liberal use of certain +predefined variables. You can alter these variables in the makefile, +with arguments to @code{make}, or in the environment to alter how the +implicit rules work without redefining the rules themselves. You can +cancel all variables used by implicit rules with the @samp{-R} or +@samp{--no-builtin-variables} option. + +For example, the command used to compile a C source file actually says +@samp{$(CC) -c $(CFLAGS) $(CPPFLAGS)}. The default values of the variables +used are @samp{cc} and nothing, resulting in the command @samp{cc -c}. By +redefining @samp{CC} to @samp{ncc}, you could cause @samp{ncc} to be +used for all C compilations performed by the implicit rule. By redefining +@samp{CFLAGS} to be @samp{-g}, you could pass the @samp{-g} option to +each compilation. @emph{All} implicit rules that do C compilation use +@samp{$(CC)} to get the program name for the compiler and @emph{all} +include @samp{$(CFLAGS)} among the arguments given to the compiler.@refill + +The variables used in implicit rules fall into two classes: those that are +names of programs (like @code{CC}) and those that contain arguments for the +programs (like @code{CFLAGS}). (The ``name of a program'' may also contain +some command arguments, but it must start with an actual executable program +name.) If a variable value contains more than one argument, separate them +with spaces. + +Here is a table of variables used as names of programs in built-in rules: + +@table @code +@item AR +@vindex AR +Archive-maintaining program; default @samp{ar}. +@pindex ar + +@item AS +@vindex AS +Program for doing assembly; default @samp{as}. +@pindex as + +@item CC +@vindex CC +Program for compiling C programs; default @samp{cc}. +@pindex cc + +@item CXX +@vindex CXX +Program for compiling C++ programs; default @samp{g++}. +@pindex g++ + +@item CO +@vindex CO +Program for extracting a file from RCS; default @samp{co}. +@pindex co + +@item CPP +@vindex CPP +Program for running the C preprocessor, with results to standard output; +default @samp{$(CC) -E}. + +@item FC +@vindex FC +Program for compiling or preprocessing Fortran and Ratfor programs; +default @samp{f77}. +@pindex f77 + +@item GET +@vindex GET +Program for extracting a file from SCCS; default @samp{get}. +@pindex get + +@item LEX +@vindex LEX +Program to use to turn Lex grammars into C programs or Ratfor programs; +default @samp{lex}. +@pindex lex + +@item PC +@vindex PC +Program for compiling Pascal programs; default @samp{pc}. +@pindex pc + +@item YACC +@vindex YACC +Program to use to turn Yacc grammars into C programs; default @samp{yacc}. +@pindex yacc + +@item YACCR +@vindex YACCR +Program to use to turn Yacc grammars into Ratfor +programs; default @samp{yacc -r}. + +@item MAKEINFO +@vindex MAKEINFO +Program to convert a Texinfo source file into an Info file; default +@samp{makeinfo}. +@pindex makeinfo + +@item TEX +@vindex TEX +Program to make @TeX{} @sc{dvi} files from @TeX{} source; +default @samp{tex}. +@pindex tex + +@item TEXI2DVI +@vindex TEXI2DVI +Program to make @TeX{} @sc{dvi} files from Texinfo source; +default @samp{texi2dvi}. +@pindex texi2dvi + +@item WEAVE +@vindex WEAVE +Program to translate Web into @TeX{}; default @samp{weave}. +@pindex weave + +@item CWEAVE +@vindex CWEAVE +Program to translate C Web into @TeX{}; default @samp{cweave}. +@pindex cweave + +@item TANGLE +@vindex TANGLE +Program to translate Web into Pascal; default @samp{tangle}. +@pindex tangle + +@item CTANGLE +@vindex CTANGLE +Program to translate C Web into C; default @samp{ctangle}. +@pindex ctangle + +@item RM +@vindex RM +Command to remove a file; default @samp{rm -f}. +@pindex rm +@end table + +Here is a table of variables whose values are additional arguments for the +programs above. The default values for all of these is the empty +string, unless otherwise noted. + +@table @code +@item ARFLAGS +@vindex ARFLAGS +Flags to give the archive-maintaining program; default @samp{rv}. + +@item ASFLAGS +@vindex ASFLAGS +Extra flags to give to the assembler (when explicitly +invoked on a @samp{.s} or @samp{.S} file). + +@item CFLAGS +@vindex CFLAGS +Extra flags to give to the C compiler. + +@item CXXFLAGS +@vindex CXXFLAGS +Extra flags to give to the C++ compiler. + +@item COFLAGS +@vindex COFLAGS +Extra flags to give to the RCS @code{co} program. + +@item CPPFLAGS +@vindex CPPFLAGS +Extra flags to give to the C preprocessor and programs +that use it (the C and Fortran compilers). + +@item FFLAGS +@vindex FFLAGS +Extra flags to give to the Fortran compiler. + +@item GFLAGS +@vindex GFLAGS +Extra flags to give to the SCCS @code{get} program. + +@item LDFLAGS +@vindex LDFLAGS +Extra flags to give to compilers when they are +supposed to invoke the linker, @samp{ld}. + +@item LFLAGS +@vindex LFLAGS +Extra flags to give to Lex. + +@item PFLAGS +@vindex PFLAGS +Extra flags to give to the Pascal compiler. + +@item RFLAGS +@vindex RFLAGS +Extra flags to give to the Fortran compiler for Ratfor programs. + +@item YFLAGS +@vindex YFLAGS +Extra flags to give to Yacc. +@end table + +@node Chained Rules, Pattern Rules, Implicit Variables, Implicit Rules +@section Chains of Implicit Rules + +@cindex chains of rules +@cindex rule, implicit, chains of +Sometimes a file can be made by a sequence of implicit rules. For example, +a file @file{@var{n}.o} could be made from @file{@var{n}.y} by running +first Yacc and then @code{cc}. Such a sequence is called a @dfn{chain}. + +If the file @file{@var{n}.c} exists, or is mentioned in the makefile, no +special searching is required: @code{make} finds that the object file can +be made by C compilation from @file{@var{n}.c}; later on, when considering +how to make @file{@var{n}.c}, the rule for running Yacc is +used. Ultimately both @file{@var{n}.c} and @file{@var{n}.o} are +updated.@refill + +@cindex intermediate files +@cindex files, intermediate +However, even if @file{@var{n}.c} does not exist and is not mentioned, +@code{make} knows how to envision it as the missing link between +@file{@var{n}.o} and @file{@var{n}.y}! In this case, @file{@var{n}.c} is +called an @dfn{intermediate file}. Once @code{make} has decided to use the +intermediate file, it is entered in the data base as if it had been +mentioned in the makefile, along with the implicit rule that says how to +create it.@refill + +Intermediate files are remade using their rules just like all other +files. But intermediate files are treated differently in two ways. + +The first difference is what happens if the intermediate file does not +exist. If an ordinary file @var{b} does not exist, and @code{make} +considers a target that depends on @var{b}, it invariably creates +@var{b} and then updates the target from @var{b}. But if @var{b} is an +intermediate file, then @code{make} can leave well enough alone. It +won't bother updating @var{b}, or the ultimate target, unless some +prerequisite of @var{b} is newer than that target or there is some other +reason to update that target. + +The second difference is that if @code{make} @emph{does} create @var{b} +in order to update something else, it deletes @var{b} later on after it +is no longer needed. Therefore, an intermediate file which did not +exist before @code{make} also does not exist after @code{make}. +@code{make} reports the deletion to you by printing a @samp{rm -f} +command showing which file it is deleting. + +Ordinarily, a file cannot be intermediate if it is mentioned in the +makefile as a target or prerequisite. However, you can explicitly mark a +file as intermediate by listing it as a prerequisite of the special target +@code{.INTERMEDIATE}. This takes effect even if the file is mentioned +explicitly in some other way. + +@cindex intermediate files, preserving +@cindex preserving intermediate files +@cindex secondary files +You can prevent automatic deletion of an intermediate file by marking it +as a @dfn{secondary} file. To do this, list it as a prerequisite of the +special target @code{.SECONDARY}. When a file is secondary, @code{make} +will not create the file merely because it does not already exist, but +@code{make} does not automatically delete the file. Marking a file as +secondary also marks it as intermediate. + +You can list the target pattern of an implicit rule (such as @samp{%.o}) +as a prerequisite of the special target @code{.PRECIOUS} to preserve +intermediate files made by implicit rules whose target patterns match +that file's name; see @ref{Interrupts}.@refill +@cindex preserving with @code{.PRECIOUS} +@cindex @code{.PRECIOUS} intermediate files + +A chain can involve more than two implicit rules. For example, it is +possible to make a file @file{foo} from @file{RCS/foo.y,v} by running RCS, +Yacc and @code{cc}. Then both @file{foo.y} and @file{foo.c} are +intermediate files that are deleted at the end.@refill + +No single implicit rule can appear more than once in a chain. This means +that @code{make} will not even consider such a ridiculous thing as making +@file{foo} from @file{foo.o.o} by running the linker twice. This +constraint has the added benefit of preventing any infinite loop in the +search for an implicit rule chain. + +There are some special implicit rules to optimize certain cases that would +otherwise be handled by rule chains. For example, making @file{foo} from +@file{foo.c} could be handled by compiling and linking with separate +chained rules, using @file{foo.o} as an intermediate file. But what +actually happens is that a special rule for this case does the compilation +and linking with a single @code{cc} command. The optimized rule is used in +preference to the step-by-step chain because it comes earlier in the +ordering of rules. + +@node Pattern Rules, Last Resort, Chained Rules, Implicit Rules +@section Defining and Redefining Pattern Rules + +You define an implicit rule by writing a @dfn{pattern rule}. A pattern +rule looks like an ordinary rule, except that its target contains the +character @samp{%} (exactly one of them). The target is considered a +pattern for matching file names; the @samp{%} can match any nonempty +substring, while other characters match only themselves. The prerequisites +likewise use @samp{%} to show how their names relate to the target name. + +Thus, a pattern rule @samp{%.o : %.c} says how to make any file +@file{@var{stem}.o} from another file @file{@var{stem}.c}.@refill + +Note that expansion using @samp{%} in pattern rules occurs +@strong{after} any variable or function expansions, which take place +when the makefile is read. @xref{Using Variables, , How to Use +Variables}, and @ref{Functions, ,Functions for Transforming Text}. + +@menu +* Pattern Intro:: An introduction to pattern rules. +* Pattern Examples:: Examples of pattern rules. +* Automatic:: How to use automatic variables in the + commands of implicit rules. +* Pattern Match:: How patterns match. +* Match-Anything Rules:: Precautions you should take prior to + defining rules that can match any + target file whatever. +* Canceling Rules:: How to override or cancel built-in rules. +@end menu + +@node Pattern Intro, Pattern Examples, Pattern Rules, Pattern Rules +@subsection Introduction to Pattern Rules +@cindex pattern rule +@cindex rule, pattern + +A pattern rule contains the character @samp{%} (exactly one of them) +in the target; otherwise, it looks exactly like an ordinary rule. The +target is a pattern for matching file names; the @samp{%} matches any +nonempty substring, while other characters match only themselves. +@cindex target pattern, implicit +@cindex @code{%}, in pattern rules + +For example, @samp{%.c} as a pattern matches any file name that ends in +@samp{.c}. @samp{s.%.c} as a pattern matches any file name that starts +with @samp{s.}, ends in @samp{.c} and is at least five characters long. +(There must be at least one character to match the @samp{%}.) The substring +that the @samp{%} matches is called the @dfn{stem}.@refill + +@samp{%} in a prerequisite of a pattern rule stands for the same stem +that was matched by the @samp{%} in the target. In order for +the pattern rule to apply, its target pattern must match the file name +under consideration, and its prerequisite patterns must name files that +exist or can be made. These files become prerequisites of the target. +@cindex prerequisite pattern, implicit + +Thus, a rule of the form + +@example +%.o : %.c ; @var{command}@dots{} +@end example + +@noindent +specifies how to make a file @file{@var{n}.o}, with another file +@file{@var{n}.c} as its prerequisite, provided that @file{@var{n}.c} +exists or can be made. + +There may also be prerequisites that do not use @samp{%}; such a prerequisite +attaches to every file made by this pattern rule. These unvarying +prerequisites are useful occasionally. + +A pattern rule need not have any prerequisites that contain @samp{%}, or +in fact any prerequisites at all. Such a rule is effectively a general +wildcard. It provides a way to make any file that matches the target +pattern. @xref{Last Resort}. + +@c !!! The end of of this paragraph should be rewritten. --bob +Pattern rules may have more than one target. Unlike normal rules, this +does not act as many different rules with the same prerequisites and +commands. If a pattern rule has multiple targets, @code{make} knows that +the rule's commands are responsible for making all of the targets. The +commands are executed only once to make all the targets. When searching +for a pattern rule to match a target, the target patterns of a rule other +than the one that matches the target in need of a rule are incidental: +@code{make} worries only about giving commands and prerequisites to the file +presently in question. However, when this file's commands are run, the +other targets are marked as having been updated themselves. +@cindex multiple targets, in pattern rule +@cindex target, multiple in pattern rule + +The order in which pattern rules appear in the makefile is important +since this is the order in which they are considered. +Of equally applicable +rules, only the first one found is used. The rules you write take precedence +over those that are built in. Note however, that a rule whose +prerequisites actually exist or are mentioned always takes priority over a +rule with prerequisites that must be made by chaining other implicit rules. +@cindex pattern rules, order of +@cindex order of pattern rules + +@node Pattern Examples, Automatic, Pattern Intro, Pattern Rules +@subsection Pattern Rule Examples + +Here are some examples of pattern rules actually predefined in +@code{make}. First, the rule that compiles @samp{.c} files into @samp{.o} +files:@refill + +@example +%.o : %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ +@end example + +@noindent +defines a rule that can make any file @file{@var{x}.o} from +@file{@var{x}.c}. The command uses the automatic variables @samp{$@@} and +@samp{$<} to substitute the names of the target file and the source file +in each case where the rule applies (@pxref{Automatic, ,Automatic Variables}).@refill + +Here is a second built-in rule: + +@example +% :: RCS/%,v + $(CO) $(COFLAGS) $< +@end example + +@noindent +defines a rule that can make any file @file{@var{x}} whatsoever from a +corresponding file @file{@var{x},v} in the subdirectory @file{RCS}. Since +the target is @samp{%}, this rule will apply to any file whatever, provided +the appropriate prerequisite file exists. The double colon makes the rule +@dfn{terminal}, which means that its prerequisite may not be an intermediate +file (@pxref{Match-Anything Rules, ,Match-Anything Pattern Rules}).@refill + +@need 500 +This pattern rule has two targets: + +@example +@group +%.tab.c %.tab.h: %.y + bison -d $< +@end group +@end example + +@noindent +@c The following paragraph is rewritten to avoid overfull hboxes +This tells @code{make} that the command @samp{bison -d @var{x}.y} will +make both @file{@var{x}.tab.c} and @file{@var{x}.tab.h}. If the file +@file{foo} depends on the files @file{parse.tab.o} and @file{scan.o} +and the file @file{scan.o} depends on the file @file{parse.tab.h}, +when @file{parse.y} is changed, the command @samp{bison -d parse.y} +will be executed only once, and the prerequisites of both +@file{parse.tab.o} and @file{scan.o} will be satisfied. (Presumably +the file @file{parse.tab.o} will be recompiled from @file{parse.tab.c} +and the file @file{scan.o} from @file{scan.c}, while @file{foo} is +linked from @file{parse.tab.o}, @file{scan.o}, and its other +prerequisites, and it will execute happily ever after.)@refill + +@node Automatic, Pattern Match, Pattern Examples, Pattern Rules +@subsection Automatic Variables +@cindex automatic variables +@cindex variables, automatic +@cindex variables, and implicit rule + +Suppose you are writing a pattern rule to compile a @samp{.c} file into a +@samp{.o} file: how do you write the @samp{cc} command so that it operates +on the right source file name? You cannot write the name in the command, +because the name is different each time the implicit rule is applied. + +What you do is use a special feature of @code{make}, the @dfn{automatic +variables}. These variables have values computed afresh for each rule that +is executed, based on the target and prerequisites of the rule. In this +example, you would use @samp{$@@} for the object file name and @samp{$<} +for the source file name. + +Here is a table of automatic variables: + +@table @code +@vindex $@@ +@vindex @@ @r{(automatic variable)} +@item $@@ +The file name of the target of the rule. If the target is an archive +member, then @samp{$@@} is the name of the archive file. In a pattern +rule that has multiple targets (@pxref{Pattern Intro, ,Introduction to +Pattern Rules}), @samp{$@@} is the name of whichever target caused the +rule's commands to be run. + +@vindex $% +@vindex % @r{(automatic variable)} +@item $% +The target member name, when the target is an archive member. +@xref{Archives}. For example, if the target is @file{foo.a(bar.o)} then +@samp{$%} is @file{bar.o} and @samp{$@@} is @file{foo.a}. @samp{$%} is +empty when the target is not an archive member. + +@vindex $< +@vindex < @r{(automatic variable)} +@item $< +The name of the first prerequisite. If the target got its commands from +an implicit rule, this will be the first prerequisite added by the +implicit rule (@pxref{Implicit Rules}). + +@vindex $? +@vindex ? @r{(automatic variable)} +@item $? +The names of all the prerequisites that are newer than the target, with +spaces between them. For prerequisites which are archive members, only +the member named is used (@pxref{Archives}). +@cindex prerequisites, list of changed +@cindex list of changed prerequisites + +@vindex $^ +@vindex ^ @r{(automatic variable)} +@item $^ +The names of all the prerequisites, with spaces between them. For +prerequisites which are archive members, only the member named is used +(@pxref{Archives}). A target has only one prerequisite on each other file +it depends on, no matter how many times each file is listed as a +prerequisite. So if you list a prerequisite more than once for a target, +the value of @code{$^} contains just one copy of the name. +@cindex prerequisites, list of all +@cindex list of all prerequisites + +@vindex $+ +@vindex + @r{(automatic variable)} +@item $+ +This is like @samp{$^}, but prerequisites listed more than once are +duplicated in the order they were listed in the makefile. This is +primarily useful for use in linking commands where it is meaningful to +repeat library file names in a particular order. + +@vindex $* +@vindex * @r{(automatic variable)} +@item $* +The stem with which an implicit rule matches (@pxref{Pattern Match, ,How +Patterns Match}). If the target is @file{dir/a.foo.b} and the target +pattern is @file{a.%.b} then the stem is @file{dir/foo}. The stem is +useful for constructing names of related files.@refill +@cindex stem, variable for + +In a static pattern rule, the stem is part of the file name that matched +the @samp{%} in the target pattern. + +In an explicit rule, there is no stem; so @samp{$*} cannot be determined +in that way. Instead, if the target name ends with a recognized suffix +(@pxref{Suffix Rules, ,Old-Fashioned Suffix Rules}), @samp{$*} is set to +the target name minus the suffix. For example, if the target name is +@samp{foo.c}, then @samp{$*} is set to @samp{foo}, since @samp{.c} is a +suffix. GNU @code{make} does this bizarre thing only for compatibility +with other implementations of @code{make}. You should generally avoid +using @samp{$*} except in implicit rules or static pattern rules.@refill + +If the target name in an explicit rule does not end with a recognized +suffix, @samp{$*} is set to the empty string for that rule. +@end table + +@samp{$?} is useful even in explicit rules when you wish to operate on only +the prerequisites that have changed. For example, suppose that an archive +named @file{lib} is supposed to contain copies of several object files. +This rule copies just the changed object files into the archive: + +@example +@group +lib: foo.o bar.o lose.o win.o + ar r lib $? +@end group +@end example + +Of the variables listed above, four have values that are single file +names, and three have values that are lists of file names. These seven +have variants that get just the file's directory name or just the file +name within the directory. The variant variables' names are formed by +appending @samp{D} or @samp{F}, respectively. These variants are +semi-obsolete in GNU @code{make} since the functions @code{dir} and +@code{notdir} can be used to get a similar effect (@pxref{File Name +Functions, , Functions for File Names}). Note, however, that the +@samp{D} variants all omit the trailing slash which always appears in +the output of the @code{dir} function. Here is a table of the variants: + +@table @samp +@vindex $(@@D) +@vindex @@D @r{(automatic variable)} +@item $(@@D) +The directory part of the file name of the target, with the trailing +slash removed. If the value of @samp{$@@} is @file{dir/foo.o} then +@samp{$(@@D)} is @file{dir}. This value is @file{.} if @samp{$@@} does +not contain a slash. + +@vindex $(@@F) +@vindex @@F @r{(automatic variable)} +@item $(@@F) +The file-within-directory part of the file name of the target. If the +value of @samp{$@@} is @file{dir/foo.o} then @samp{$(@@F)} is +@file{foo.o}. @samp{$(@@F)} is equivalent to @samp{$(notdir $@@)}. + +@vindex $(*D) +@vindex *D @r{(automatic variable)} +@item $(*D) +@vindex $(*F) +@vindex *F @r{(automatic variable)} +@itemx $(*F) +The directory part and the file-within-directory +part of the stem; @file{dir} and @file{foo} in this example. + +@vindex $(%D) +@vindex %D @r{(automatic variable)} +@item $(%D) +@vindex $(%F) +@vindex %F @r{(automatic variable)} +@itemx $(%F) +The directory part and the file-within-directory part of the target +archive member name. This makes sense only for archive member targets +of the form @file{@var{archive}(@var{member})} and is useful only when +@var{member} may contain a directory name. (@xref{Archive Members, +,Archive Members as Targets}.) + +@vindex $( tar-`sed -e '/version_string/!d' \ + -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ + -e q + version.c`.shar.Z +@end group + +@group +dist: $(SRCS) $(AUX) + echo tar-`sed \ + -e '/version_string/!d' \ + -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ + -e q + version.c` > .fname + -rm -rf `cat .fname` + mkdir `cat .fname` + ln $(SRCS) $(AUX) `cat .fname` + tar chZf `cat .fname`.tar.Z `cat .fname` + -rm -rf `cat .fname` .fname +@end group + +@group +tar.zoo: $(SRCS) $(AUX) + -rm -rf tmp.dir + -mkdir tmp.dir + -rm tar.zoo + for X in $(SRCS) $(AUX) ; do \ + echo $$X ; \ + sed 's/$$/^M/' $$X \ + > tmp.dir/$$X ; done + cd tmp.dir ; zoo aM ../tar.zoo * + -rm -rf tmp.dir +@end group +@end example + +@raisesections +@include fdl.texi +@lowersections + +@node Concept Index, Name Index, GNU Free Documentation License, Top +@unnumbered Index of Concepts + +@printindex cp + +@node Name Index, , Concept Index, Top +@unnumbered Index of Functions, Variables, & Directives + +@printindex fn + +@summarycontents +@contents +@bye diff --git a/function.c b/function.c index e314ee4..889caa8 100644 --- a/function.c +++ b/function.c @@ -1140,6 +1140,42 @@ func_wildcard (o, argv, funcname) return o; } +/* + $(eval ) + + Always resolves to the empty string. + + Treat the arguments as a segment of makefile, and parse them. +*/ + +static char * +func_eval (o, argv, funcname) + char *o; + char **argv; + const char *funcname; +{ + eval_buffer (argv[0]); + + return o; +} + + +static char * +func_value (o, argv, funcname) + char *o; + char **argv; + const char *funcname; +{ + /* Look up the variable. */ + struct variable *v = lookup_variable (argv[0], strlen (argv[0])); + + /* Copy its value into the output buffer without expanding it. */ + if (v) + o = variable_buffer_output (o, v->value, strlen(v->value)); + + return o; +} + /* \r is replaced on UNIX as well. Is this desirable? */ @@ -1618,8 +1654,6 @@ func_not (char* o, char **argv, char *funcname) #endif -#define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1) - /* Lookup table for builtin functions. This doesn't have to be sorted; we use a straight lookup. We might gain @@ -1664,6 +1698,8 @@ static struct function_table_entry function_table[] = { STRING_SIZE_TUPLE("error"), 0, 1, 1, func_error}, { STRING_SIZE_TUPLE("warning"), 0, 1, 1, func_error}, { STRING_SIZE_TUPLE("if"), 2, 3, 0, func_if}, + { STRING_SIZE_TUPLE("value"), 0, 1, 1, func_value}, + { STRING_SIZE_TUPLE("eval"), 0, 1, 1, func_eval}, #ifdef EXPERIMENTAL { STRING_SIZE_TUPLE("eq"), 2, 2, 1, func_eq}, { STRING_SIZE_TUPLE("not"), 0, 1, 1, func_not}, diff --git a/gpl.texinfo b/gpl.texinfo deleted file mode 100755 index a2f8db9..0000000 --- a/gpl.texinfo +++ /dev/null @@ -1,396 +0,0 @@ -@setfilename gpl.info - -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -@item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) -@end enumerate - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -@enumerate a -@item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -@item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -@item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) -@end enumerate - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -@item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -@item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the ``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and an idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@smallexample -@group -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end group -@end smallexample - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/implicit.c b/implicit.c index cce1795..05eaa7f 100644 --- a/implicit.c +++ b/implicit.c @@ -100,7 +100,7 @@ pattern_search (file, archive, depth, recursions) /* List of dependencies found recursively. */ struct file **intermediate_files - = (struct file **) alloca (max_pattern_deps * sizeof (struct file *)); + = (struct file **) xmalloc (max_pattern_deps * sizeof (struct file *)); /* List of the patterns used to find intermediate files. */ char **intermediate_patterns @@ -121,8 +121,8 @@ pattern_search (file, archive, depth, recursions) /* Buffer in which we store all the rules that are possibly applicable. */ struct rule **tryrules - = (struct rule **) alloca (num_pattern_rules * max_pattern_targets - * sizeof (struct rule *)); + = (struct rule **) xmalloc (num_pattern_rules * max_pattern_targets + * sizeof (struct rule *)); /* Number of valid elements in TRYRULES. */ unsigned int nrules; @@ -495,7 +495,7 @@ pattern_search (file, archive, depth, recursions) /* RULE is nil if the loop went all the way through the list and everything failed. */ if (rule == 0) - return 0; + goto done; foundrule = i; @@ -624,6 +624,9 @@ pattern_search (file, archive, depth, recursions) file->also_make = new; } + done: + free (intermediate_files); + free (tryrules); - return 1; + return rule != 0; } diff --git a/main.c b/main.c index 790bc43..798bde9 100644 --- a/main.c +++ b/main.c @@ -904,12 +904,26 @@ int main (int argc, char ** argv) /* Make sure stdout is line-buffered. */ +#ifdef HAVE_SETVBUF +# ifndef SETVBUF_REVERSED + setvbuf (stdout, _IOLBF, xmalloc (BUFSIZ), BUFSIZ); +_WAIT_NOHANG +# if defined SIGCHLD + (void) bsd_signal (SIGCHLD, SIG_DFL); +# endif +# if defined SIGCLD && SIGCLD != SIGCHLD + (void) bsd_signal (SIGCLD, SIG_DFL); +# endif +#endif + + /* Make sure stdout is line-buffered. */ + #ifdef HAVE_SETVBUF # ifdef SETVBUF_REVERSED - setvbuf (stdout, (char *) 0, _IOLBF, BUFSIZ); + setvbuf (stdout, _IOLBF, xmalloc (BUFSIZ), BUFSIZ); # else /* setvbuf not reversed. */ /* Some buggy systems lose if we pass 0 instead of allocating ourselves. */ - setvbuf (stdout, _IOLBF, xmalloc (BUFSIZ), BUFSIZ); + setvbuf (stdout, (char *) 0, _IOLBF, BUFSIZ); # endif /* setvbuf reversed. */ #elif HAVE_SETLINEBUF setlinebuf (stdout); @@ -2074,6 +2088,7 @@ static void print_usage (bad) int bad; { + extern char *make_host; register const struct command_switch *cs; FILE *usageto; @@ -2165,7 +2180,10 @@ print_usage (bad) buf, gettext (cs->description)); } - fprintf (usageto, _("\nReport bugs to .\n")); + fprintf (usageto, _("\nBuilt for %s"), make_host); + if (remote_description != 0 && *remote_description != '\0') + fprintf (usageto, " (%s)", remote_description); + fprintf (usageto, _("\nReport bugs to \n")); } /* Decode switches from ARGC and ARGV. @@ -2697,7 +2715,6 @@ define_makeflags (all, makefile) static void print_version () { - extern char *make_host; static int printed_version = 0; char *precede = print_data_base_flag ? "# " : ""; @@ -2706,19 +2723,19 @@ print_version () /* Do it only once. */ return; - printf ("%sGNU Make version %s", precede, version_string); - if (remote_description != 0 && *remote_description != '\0') - printf ("-%s", remote_description); + /* Print this untranslated. The coding standards recommend translating the + (C) to the copyright symbol, but this string is going to change every + year, and none of the rest of it should be translated (including the + word "Copyright", so it hardly seems worth it. */ + + printf ("%sGNU Make %s\n\ +%sCopyright (C) 2002 Free Software Foundation, Inc.\n", + precede, version_string, precede); - printf (_(", by Richard Stallman and Roland McGrath.\n\ -%sBuilt for %s\n\ -%sCopyright (C) 2002 Free Software Foundation, Inc.\n\ -%sThis is free software; see the source for copying conditions.\n\ + printf (_("%sThis is free software; see the source for copying conditions.\n\ %sThere is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\ -%sPARTICULAR PURPOSE.\n\n\ -%sReport bugs to .\n\n"), - precede, make_host, - precede, precede, precede, precede, precede); +%sPARTICULAR PURPOSE.\n"), + precede, precede, precede); printed_version = 1; diff --git a/maintMakefile b/maintMakefile index a2c9cc7..a499972 100644 --- a/maintMakefile +++ b/maintMakefile @@ -88,3 +88,105 @@ TARFILE := $(distdir).tar.gz alpha: $(ALPHA) $(TARFILE) @rm -f $(ALPHA)/$(TARFILE) cp -p $(TARFILE) $(ALPHA) + + +# ---------------------------------------------------------------------- +# +# The sections below were stolen from the Makefile.maint used by fileutils, +# sh-utils, textutils, CPPI, Bison, and Autoconf. + + +## ---------------- ## +## Updating files. ## +## ---------------- ## + +WGET = wget --passive-ftp --non-verbose +ftp-gnu = ftp://ftp.gnu.org/gnu + +move_if_change = if test -r $(target) && cmp -s $(target).t $(target); then \ + echo $(target) is unchanged; rm -f $(target).t; \ + else \ + mv $(target).t $(target); \ + fi + +# ------------------- # +# Updating PO files. # +# ------------------- # + +po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE) +.PHONY: do-po-update po-update +do-po-update: + tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\ + rm -rf $$tmppo && \ + mkdir $$tmppo && \ + (cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\ + cp $$tmppo/*.po po + cd po && $(MAKE) update-po + $(MAKE) po-check + +po-update: + if test -d "po"; then \ + $(MAKE) do-po-update; \ + fi + +# -------------------------- # +# Updating GNU build tools. # +# -------------------------- # + +# The following pseudo table associates a local directory and a URL +# with each of the files that belongs to some other package and is +# regularly updated from the specified URL. +# $(srcdir)/src/ansi2knr.c + + +wget_files ?= $(srcdir)/config/config.guess $(srcdir)/config/config.sub \ + $(srcdir)/doc/texinfo.tex $(srcdir)/doc/make-stds.texi \ + $(srcdir)/doc/fdl.texi + +wget-targets = $(patsubst %, get-%, $(wget_files)) + +config.guess-url_prefix = $(ftp-gnu)/config/ +config.sub-url_prefix = $(ftp-gnu)/config/ + +ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/ + +texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/ + +standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/ +make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/ +fdl.texi-url_prefix = $(ftp-gnu)/GNUinfo/ + +target = $(patsubst get-%,%,$@) +url = $($(notdir $(target))-url_prefix)$(notdir $(target)) + +.PHONY: $(wget-targets) +$(wget-targets): + @echo $(WGET) $(url) -O $(target) \ + && $(WGET) $(url) -O $(target).t \ + && $(move_if_change) + +.PHONY: wget-update +wget-update: $(wget-targets) + + +# Updating tools via CVS. +cvs_files ?= depcomp missing +cvs-targets = $(patsubst %, get-%, $(cvs_files)) + +automake_repo = :pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake +.PHONY: $(cvs-targets) +$(cvs-targets): + $(CVS) -d $(automake_repo) co -p automake/lib/$(notdir $(target)) \ + >$(target).t \ + && $(move_if_change) + +.PHONY: cvs-update +cvs-update: $(cvs-targets) + + +# --------------------- # +# Updating everything. # +# --------------------- # + +.PHONY: update +update: wget-update cvs-update po-update diff --git a/make-stds.texi b/make-stds.texi deleted file mode 100644 index c7c71ad..0000000 --- a/make-stds.texi +++ /dev/null @@ -1,916 +0,0 @@ -@comment This file is included by both standards.texi and make.texinfo. -@comment It was broken out of standards.texi on 1/6/93 by roland. - -@node Makefile Conventions -@chapter Makefile Conventions -@comment standards.texi does not print an index, but make.texinfo does. -@cindex makefile, conventions for -@cindex conventions for makefiles -@cindex standards for makefiles - -This -@ifinfo -node -@end ifinfo -@iftex -@ifset CODESTD -section -@end ifset -@ifclear CODESTD -chapter -@end ifclear -@end iftex -describes conventions for writing the Makefiles for GNU programs. -Using Automake will help you write a Makefile that follows these -conventions. - -@menu -* Makefile Basics:: General Conventions for Makefiles -* Utilities in Makefiles:: Utilities in Makefiles -* Command Variables:: Variables for Specifying Commands -* Directory Variables:: Variables for Installation Directories -* Standard Targets:: Standard Targets for Users -* Install Command Categories:: Three categories of commands in the `install' - rule: normal, pre-install and post-install. -@end menu - -@node Makefile Basics -@section General Conventions for Makefiles - -Every Makefile should contain this line: - -@example -SHELL = /bin/sh -@end example - -@noindent -to avoid trouble on systems where the @code{SHELL} variable might be -inherited from the environment. (This is never a problem with GNU -@code{make}.) - -Different @code{make} programs have incompatible suffix lists and -implicit rules, and this sometimes creates confusion or misbehavior. So -it is a good idea to set the suffix list explicitly using only the -suffixes you need in the particular Makefile, like this: - -@example -.SUFFIXES: -.SUFFIXES: .c .o -@end example - -@noindent -The first line clears out the suffix list, the second introduces all -suffixes which may be subject to implicit rules in this Makefile. - -Don't assume that @file{.} is in the path for command execution. When -you need to run programs that are a part of your package during the -make, please make sure that it uses @file{./} if the program is built as -part of the make or @file{$(srcdir)/} if the file is an unchanging part -of the source code. Without one of these prefixes, the current search -path is used. - -The distinction between @file{./} (the @dfn{build directory}) and -@file{$(srcdir)/} (the @dfn{source directory}) is important because -users can build in a separate directory using the @samp{--srcdir} option -to @file{configure}. A rule of the form: - -@smallexample -foo.1 : foo.man sedscript - sed -e sedscript foo.man > foo.1 -@end smallexample - -@noindent -will fail when the build directory is not the source directory, because -@file{foo.man} and @file{sedscript} are in the the source directory. - -When using GNU @code{make}, relying on @samp{VPATH} to find the source -file will work in the case where there is a single dependency file, -since the @code{make} automatic variable @samp{$<} will represent the -source file wherever it is. (Many versions of @code{make} set @samp{$<} -only in implicit rules.) A Makefile target like - -@smallexample -foo.o : bar.c - $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o -@end smallexample - -@noindent -should instead be written as - -@smallexample -foo.o : bar.c - $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@@ -@end smallexample - -@noindent -in order to allow @samp{VPATH} to work correctly. When the target has -multiple dependencies, using an explicit @samp{$(srcdir)} is the easiest -way to make the rule work well. For example, the target above for -@file{foo.1} is best written as: - -@smallexample -foo.1 : foo.man sedscript - sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@@ -@end smallexample - -GNU distributions usually contain some files which are not source -files---for example, Info files, and the output from Autoconf, Automake, -Bison or Flex. Since these files normally appear in the source -directory, they should always appear in the source directory, not in the -build directory. So Makefile rules to update them should put the -updated files in the source directory. - -However, if a file does not appear in the distribution, then the -Makefile should not put it in the source directory, because building a -program in ordinary circumstances should not modify the source directory -in any way. - -Try to make the build and installation targets, at least (and all their -subtargets) work correctly with a parallel @code{make}. - -@node Utilities in Makefiles -@section Utilities in Makefiles - -Write the Makefile commands (and any shell scripts, such as -@code{configure}) to run in @code{sh}, not in @code{csh}. Don't use any -special features of @code{ksh} or @code{bash}. - -The @code{configure} script and the Makefile rules for building and -installation should not use any utilities directly except these: - -@c dd find -@c gunzip gzip md5sum -@c mkfifo mknod tee uname - -@example -cat cmp cp diff echo egrep expr false grep install-info -ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true -@end example - -The compression program @code{gzip} can be used in the @code{dist} rule. - -Stick to the generally supported options for these programs. For -example, don't use @samp{mkdir -p}, convenient as it may be, because -most systems don't support it. - -It is a good idea to avoid creating symbolic links in makefiles, since a -few systems don't support them. - -The Makefile rules for building and installation can also use compilers -and related programs, but should do so via @code{make} variables so that the -user can substitute alternatives. Here are some of the programs we -mean: - -@example -ar bison cc flex install ld ldconfig lex -make makeinfo ranlib texi2dvi yacc -@end example - -Use the following @code{make} variables to run those programs: - -@example -$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX) -$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC) -@end example - -When you use @code{ranlib} or @code{ldconfig}, you should make sure -nothing bad happens if the system does not have the program in question. -Arrange to ignore an error from that command, and print a message before -the command to tell the user that failure of this command does not mean -a problem. (The Autoconf @samp{AC_PROG_RANLIB} macro can help with -this.) - -If you use symbolic links, you should implement a fallback for systems -that don't have symbolic links. - -Additional utilities that can be used via Make variables are: - -@example -chgrp chmod chown mknod -@end example - -It is ok to use other utilities in Makefile portions (or scripts) -intended only for particular systems where you know those utilities -exist. - -@node Command Variables -@section Variables for Specifying Commands - -Makefiles should provide variables for overriding certain commands, options, -and so on. - -In particular, you should run most utility programs via variables. -Thus, if you use Bison, have a variable named @code{BISON} whose default -value is set with @samp{BISON = bison}, and refer to it with -@code{$(BISON)} whenever you need to use Bison. - -File management utilities such as @code{ln}, @code{rm}, @code{mv}, and -so on, need not be referred to through variables in this way, since users -don't need to replace them with other programs. - -Each program-name variable should come with an options variable that is -used to supply options to the program. Append @samp{FLAGS} to the -program-name variable name to get the options variable name---for -example, @code{BISONFLAGS}. (The names @code{CFLAGS} for the C -compiler, @code{YFLAGS} for yacc, and @code{LFLAGS} for lex, are -exceptions to this rule, but we keep them because they are standard.) -Use @code{CPPFLAGS} in any compilation command that runs the -preprocessor, and use @code{LDFLAGS} in any compilation command that -does linking as well as in any direct use of @code{ld}. - -If there are C compiler options that @emph{must} be used for proper -compilation of certain files, do not include them in @code{CFLAGS}. -Users expect to be able to specify @code{CFLAGS} freely themselves. -Instead, arrange to pass the necessary options to the C compiler -independently of @code{CFLAGS}, by writing them explicitly in the -compilation commands or by defining an implicit rule, like this: - -@smallexample -CFLAGS = -g -ALL_CFLAGS = -I. $(CFLAGS) -.c.o: - $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< -@end smallexample - -Do include the @samp{-g} option in @code{CFLAGS}, because that is not -@emph{required} for proper compilation. You can consider it a default -that is only recommended. If the package is set up so that it is -compiled with GCC by default, then you might as well include @samp{-O} -in the default value of @code{CFLAGS} as well. - -Put @code{CFLAGS} last in the compilation command, after other variables -containing compiler options, so the user can use @code{CFLAGS} to -override the others. - -@code{CFLAGS} should be used in every invocation of the C compiler, -both those which do compilation and those which do linking. - -Every Makefile should define the variable @code{INSTALL}, which is the -basic command for installing a file into the system. - -Every Makefile should also define the variables @code{INSTALL_PROGRAM} -and @code{INSTALL_DATA}. (The default for each of these should be -@code{$(INSTALL)}.) Then it should use those variables as the commands -for actual installation, for executables and nonexecutables -respectively. Use these variables as follows: - -@example -$(INSTALL_PROGRAM) foo $(bindir)/foo -$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a -@end example - -Optionally, you may prepend the value of @code{DESTDIR} to the target -filename. Doing this allows the installer to create a snapshot of the -installation to be copied onto the real target filesystem later. Do not -set the value of @code{DESTDIR} in your Makefile, and do not include it -in any installed files. With support for @code{DESTDIR}, the above -examples become: - -@example -$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo -$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a -@end example - -@noindent -Always use a file name, not a directory name, as the second argument of -the installation commands. Use a separate command for each file to be -installed. - -@node Directory Variables -@section Variables for Installation Directories - -Installation directories should always be named by variables, so it is -easy to install in a nonstandard place. The standard names for these -variables are described below. They are based on a standard filesystem -layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and -other modern operating systems. - -These two variables set the root for the installation. All the other -installation directories should be subdirectories of one of these two, -and nothing should be directly installed into these two directories. - -@table @samp -@item prefix -A prefix used in constructing the default values of the variables listed -below. The default value of @code{prefix} should be @file{/usr/local}. -When building the complete GNU system, the prefix will be empty and -@file{/usr} will be a symbolic link to @file{/}. -(If you are using Autoconf, write it as @samp{@@prefix@@}.) - -Running @samp{make install} with a different value of @code{prefix} -from the one used to build the program should @var{not} recompile -the program. - -@item exec_prefix -A prefix used in constructing the default values of some of the -variables listed below. The default value of @code{exec_prefix} should -be @code{$(prefix)}. -(If you are using Autoconf, write it as @samp{@@exec_prefix@@}.) - -Generally, @code{$(exec_prefix)} is used for directories that contain -machine-specific files (such as executables and subroutine libraries), -while @code{$(prefix)} is used directly for other directories. - -Running @samp{make install} with a different value of @code{exec_prefix} -from the one used to build the program should @var{not} recompile the -program. -@end table - -Executable programs are installed in one of the following directories. - -@table @samp -@item bindir -The directory for installing executable programs that users can run. -This should normally be @file{/usr/local/bin}, but write it as -@file{$(exec_prefix)/bin}. -(If you are using Autoconf, write it as @samp{@@bindir@@}.) - -@item sbindir -The directory for installing executable programs that can be run from -the shell, but are only generally useful to system administrators. This -should normally be @file{/usr/local/sbin}, but write it as -@file{$(exec_prefix)/sbin}. -(If you are using Autoconf, write it as @samp{@@sbindir@@}.) - -@item libexecdir -@comment This paragraph adjusted to avoid overfull hbox --roland 5jul94 -The directory for installing executable programs to be run by other -programs rather than by users. This directory should normally be -@file{/usr/local/libexec}, but write it as @file{$(exec_prefix)/libexec}. -(If you are using Autoconf, write it as @samp{@@libexecdir@@}.) -@end table - -Data files used by the program during its execution are divided into -categories in two ways. - -@itemize @bullet -@item -Some files are normally modified by programs; others are never normally -modified (though users may edit some of these). - -@item -Some files are architecture-independent and can be shared by all -machines at a site; some are architecture-dependent and can be shared -only by machines of the same kind and operating system; others may never -be shared between two machines. -@end itemize - -This makes for six different possibilities. However, we want to -discourage the use of architecture-dependent files, aside from object -files and libraries. It is much cleaner to make other data files -architecture-independent, and it is generally not hard. - -Therefore, here are the variables Makefiles should use to specify -directories: - -@table @samp -@item datadir -The directory for installing read-only architecture independent data -files. This should normally be @file{/usr/local/share}, but write it as -@file{$(prefix)/share}. -(If you are using Autoconf, write it as @samp{@@datadir@@}.) -As a special exception, see @file{$(infodir)} -and @file{$(includedir)} below. - -@item sysconfdir -The directory for installing read-only data files that pertain to a -single machine--that is to say, files for configuring a host. Mailer -and network configuration files, @file{/etc/passwd}, and so forth belong -here. All the files in this directory should be ordinary ASCII text -files. This directory should normally be @file{/usr/local/etc}, but -write it as @file{$(prefix)/etc}. -(If you are using Autoconf, write it as @samp{@@sysconfdir@@}.) - -Do not install executables here in this directory (they probably belong -in @file{$(libexecdir)} or @file{$(sbindir)}). Also do not install -files that are modified in the normal course of their use (programs -whose purpose is to change the configuration of the system excluded). -Those probably belong in @file{$(localstatedir)}. - -@item sharedstatedir -The directory for installing architecture-independent data files which -the programs modify while they run. This should normally be -@file{/usr/local/com}, but write it as @file{$(prefix)/com}. -(If you are using Autoconf, write it as @samp{@@sharedstatedir@@}.) - -@item localstatedir -The directory for installing data files which the programs modify while -they run, and that pertain to one specific machine. Users should never -need to modify files in this directory to configure the package's -operation; put such configuration information in separate files that go -in @file{$(datadir)} or @file{$(sysconfdir)}. @file{$(localstatedir)} -should normally be @file{/usr/local/var}, but write it as -@file{$(prefix)/var}. -(If you are using Autoconf, write it as @samp{@@localstatedir@@}.) - -@item libdir -The directory for object files and libraries of object code. Do not -install executables here, they probably ought to go in @file{$(libexecdir)} -instead. The value of @code{libdir} should normally be -@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}. -(If you are using Autoconf, write it as @samp{@@libdir@@}.) - -@item infodir -The directory for installing the Info files for this package. By -default, it should be @file{/usr/local/info}, but it should be written -as @file{$(prefix)/info}. -(If you are using Autoconf, write it as @samp{@@infodir@@}.) - -@item lispdir -The directory for installing any Emacs Lisp files in this package. By -default, it should be @file{/usr/local/share/emacs/site-lisp}, but it -should be written as @file{$(prefix)/share/emacs/site-lisp}. - -If you are using Autoconf, write the default as @samp{@@lispdir@@}. -In order to make @samp{@@lispdir@@} work, you need the following lines -in your @file{configure.in} file: - -@example -lispdir='$@{datadir@}/emacs/site-lisp' -AC_SUBST(lispdir) -@end example - -@item includedir -@c rewritten to avoid overfull hbox --roland -The directory for installing header files to be included by user -programs with the C @samp{#include} preprocessor directive. This -should normally be @file{/usr/local/include}, but write it as -@file{$(prefix)/include}. -(If you are using Autoconf, write it as @samp{@@includedir@@}.) - -Most compilers other than GCC do not look for header files in directory -@file{/usr/local/include}. So installing the header files this way is -only useful with GCC. Sometimes this is not a problem because some -libraries are only really intended to work with GCC. But some libraries -are intended to work with other compilers. They should install their -header files in two places, one specified by @code{includedir} and one -specified by @code{oldincludedir}. - -@item oldincludedir -The directory for installing @samp{#include} header files for use with -compilers other than GCC. This should normally be @file{/usr/include}. -(If you are using Autoconf, you can write it as @samp{@@oldincludedir@@}.) - -The Makefile commands should check whether the value of -@code{oldincludedir} is empty. If it is, they should not try to use -it; they should cancel the second installation of the header files. - -A package should not replace an existing header in this directory unless -the header came from the same package. Thus, if your Foo package -provides a header file @file{foo.h}, then it should install the header -file in the @code{oldincludedir} directory if either (1) there is no -@file{foo.h} there or (2) the @file{foo.h} that exists came from the Foo -package. - -To tell whether @file{foo.h} came from the Foo package, put a magic -string in the file---part of a comment---and @code{grep} for that string. -@end table - -Unix-style man pages are installed in one of the following: - -@table @samp -@item mandir -The top-level directory for installing the man pages (if any) for this -package. It will normally be @file{/usr/local/man}, but you should -write it as @file{$(prefix)/man}. -(If you are using Autoconf, write it as @samp{@@mandir@@}.) - -@item man1dir -The directory for installing section 1 man pages. Write it as -@file{$(mandir)/man1}. -@item man2dir -The directory for installing section 2 man pages. Write it as -@file{$(mandir)/man2} -@item @dots{} - -@strong{Don't make the primary documentation for any GNU software be a -man page. Write a manual in Texinfo instead. Man pages are just for -the sake of people running GNU software on Unix, which is a secondary -application only.} - -@item manext -The file name extension for the installed man page. This should contain -a period followed by the appropriate digit; it should normally be @samp{.1}. - -@item man1ext -The file name extension for installed section 1 man pages. -@item man2ext -The file name extension for installed section 2 man pages. -@item @dots{} -Use these names instead of @samp{manext} if the package needs to install man -pages in more than one section of the manual. -@end table - -And finally, you should set the following variable: - -@table @samp -@item srcdir -The directory for the sources being compiled. The value of this -variable is normally inserted by the @code{configure} shell script. -(If you are using Autconf, use @samp{srcdir = @@srcdir@@}.) -@end table - -For example: - -@smallexample -@c I have changed some of the comments here slightly to fix an overfull -@c hbox, so the make manual can format correctly. --roland -# Common prefix for installation directories. -# NOTE: This directory must exist when you start the install. -prefix = /usr/local -exec_prefix = $(prefix) -# Where to put the executable for the command `gcc'. -bindir = $(exec_prefix)/bin -# Where to put the directories used by the compiler. -libexecdir = $(exec_prefix)/libexec -# Where to put the Info files. -infodir = $(prefix)/info -@end smallexample - -If your program installs a large number of files into one of the -standard user-specified directories, it might be useful to group them -into a subdirectory particular to that program. If you do this, you -should write the @code{install} rule to create these subdirectories. - -Do not expect the user to include the subdirectory name in the value of -any of the variables listed above. The idea of having a uniform set of -variable names for installation directories is to enable the user to -specify the exact same values for several different GNU packages. In -order for this to be useful, all the packages must be designed so that -they will work sensibly when the user does so. - -@node Standard Targets -@section Standard Targets for Users - -All GNU programs should have the following targets in their Makefiles: - -@table @samp -@item all -Compile the entire program. This should be the default target. This -target need not rebuild any documentation files; Info files should -normally be included in the distribution, and DVI files should be made -only when explicitly asked for. - -By default, the Make rules should compile and link with @samp{-g}, so -that executable programs have debugging symbols. Users who don't mind -being helpless can strip the executables later if they wish. - -@item install -Compile the program and copy the executables, libraries, and so on to -the file names where they should reside for actual use. If there is a -simple test to verify that a program is properly installed, this target -should run that test. - -Do not strip executables when installing them. Devil-may-care users can -use the @code{install-strip} target to do that. - -If possible, write the @code{install} target rule so that it does not -modify anything in the directory where the program was built, provided -@samp{make all} has just been done. This is convenient for building the -program under one user name and installing it under another. - -The commands should create all the directories in which files are to be -installed, if they don't already exist. This includes the directories -specified as the values of the variables @code{prefix} and -@code{exec_prefix}, as well as all subdirectories that are needed. -One way to do this is by means of an @code{installdirs} target -as described below. - -Use @samp{-} before any command for installing a man page, so that -@code{make} will ignore any errors. This is in case there are systems -that don't have the Unix man page documentation system installed. - -The way to install Info files is to copy them into @file{$(infodir)} -with @code{$(INSTALL_DATA)} (@pxref{Command Variables}), and then run -the @code{install-info} program if it is present. @code{install-info} -is a program that edits the Info @file{dir} file to add or update the -menu entry for the given Info file; it is part of the Texinfo package. -Here is a sample rule to install an Info file: - -@comment This example has been carefully formatted for the Make manual. -@comment Please do not reformat it without talking to roland@gnu.ai.mit.edu. -@smallexample -$(DESTDIR)$(infodir)/foo.info: foo.info - $(POST_INSTALL) -# There may be a newer info file in . than in srcdir. - -if test -f foo.info; then d=.; \ - else d=$(srcdir); fi; \ - $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@@; \ -# Run install-info only if it exists. -# Use `if' instead of just prepending `-' to the -# line so we notice real errors from install-info. -# We use `$(SHELL) -c' because some shells do not -# fail gracefully when there is an unknown command. - if $(SHELL) -c 'install-info --version' \ - >/dev/null 2>&1; then \ - install-info --dir-file=$(DESTDIR)$(infodir)/dir \ - $(DESTDIR)$(infodir)/foo.info; \ - else true; fi -@end smallexample - -When writing the @code{install} target, you must classify all the -commands into three categories: normal ones, @dfn{pre-installation} -commands and @dfn{post-installation} commands. @xref{Install Command -Categories}. - -@item uninstall -Delete all the installed files---the copies that the @samp{install} -target creates. - -This rule should not modify the directories where compilation is done, -only the directories where files are installed. - -The uninstallation commands are divided into three categories, just like -the installation commands. @xref{Install Command Categories}. - -@item install-strip -Like @code{install}, but strip the executable files while installing -them. In many cases, the definition of this target can be very simple: - -@smallexample -install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ - install -@end smallexample - -Normally we do not recommend stripping an executable unless you are sure -the program has no bugs. However, it can be reasonable to install a -stripped executable for actual execution while saving the unstripped -executable elsewhere in case there is a bug. - -@comment The gratuitous blank line here is to make the table look better -@comment in the printed Make manual. Please leave it in. -@item clean - -Delete all files from the current directory that are normally created by -building the program. Don't delete the files that record the -configuration. Also preserve files that could be made by building, but -normally aren't because the distribution comes with them. - -Delete @file{.dvi} files here if they are not part of the distribution. - -@item distclean -Delete all files from the current directory that are created by -configuring or building the program. If you have unpacked the source -and built the program without creating any other files, @samp{make -distclean} should leave only the files that were in the distribution. - -@item mostlyclean -Like @samp{clean}, but may refrain from deleting a few files that people -normally don't want to recompile. For example, the @samp{mostlyclean} -target for GCC does not delete @file{libgcc.a}, because recompiling it -is rarely necessary and takes a lot of time. - -@item maintainer-clean -Delete almost everything from the current directory that can be -reconstructed with this Makefile. This typically includes everything -deleted by @code{distclean}, plus more: C source files produced by -Bison, tags tables, Info files, and so on. - -The reason we say ``almost everything'' is that running the command -@samp{make maintainer-clean} should not delete @file{configure} even if -@file{configure} can be remade using a rule in the Makefile. More generally, -@samp{make maintainer-clean} should not delete anything that needs to -exist in order to run @file{configure} and then begin to build the -program. This is the only exception; @code{maintainer-clean} should -delete everything else that can be rebuilt. - -The @samp{maintainer-clean} target is intended to be used by a maintainer of -the package, not by ordinary users. You may need special tools to -reconstruct some of the files that @samp{make maintainer-clean} deletes. -Since these files are normally included in the distribution, we don't -take care to make them easy to reconstruct. If you find you need to -unpack the full distribution again, don't blame us. - -To help make users aware of this, the commands for the special -@code{maintainer-clean} target should start with these two: - -@smallexample -@@echo 'This command is intended for maintainers to use; it' -@@echo 'deletes files that may need special tools to rebuild.' -@end smallexample - -@item TAGS -Update a tags table for this program. -@c ADR: how? - -@item info -Generate any Info files needed. The best way to write the rules is as -follows: - -@smallexample -info: foo.info - -foo.info: foo.texi chap1.texi chap2.texi - $(MAKEINFO) $(srcdir)/foo.texi -@end smallexample - -@noindent -You must define the variable @code{MAKEINFO} in the Makefile. It should -run the @code{makeinfo} program, which is part of the Texinfo -distribution. - -Normally a GNU distribution comes with Info files, and that means the -Info files are present in the source directory. Therefore, the Make -rule for an info file should update it in the source directory. When -users build the package, ordinarily Make will not update the Info files -because they will already be up to date. - -@item dvi -Generate DVI files for all Texinfo documentation. -For example: - -@smallexample -dvi: foo.dvi - -foo.dvi: foo.texi chap1.texi chap2.texi - $(TEXI2DVI) $(srcdir)/foo.texi -@end smallexample - -@noindent -You must define the variable @code{TEXI2DVI} in the Makefile. It should -run the program @code{texi2dvi}, which is part of the Texinfo -distribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real work -of formatting. @TeX{} is not distributed with Texinfo.} Alternatively, -write just the dependencies, and allow GNU @code{make} to provide the command. - -@item dist -Create a distribution tar file for this program. The tar file should be -set up so that the file names in the tar file start with a subdirectory -name which is the name of the package it is a distribution for. This -name can include the version number. - -For example, the distribution tar file of GCC version 1.40 unpacks into -a subdirectory named @file{gcc-1.40}. - -The easiest way to do this is to create a subdirectory appropriately -named, use @code{ln} or @code{cp} to install the proper files in it, and -then @code{tar} that subdirectory. - -Compress the tar file file with @code{gzip}. For example, the actual -distribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}. - -The @code{dist} target should explicitly depend on all non-source files -that are in the distribution, to make sure they are up to date in the -distribution. -@ifset CODESTD -@xref{Releases, , Making Releases}. -@end ifset -@ifclear CODESTD -@xref{Releases, , Making Releases, standards, GNU Coding Standards}. -@end ifclear - -@item check -Perform self-tests (if any). The user must build the program before -running the tests, but need not install the program; you should write -the self-tests so that they work when the program is built but not -installed. -@end table - -The following targets are suggested as conventional names, for programs -in which they are useful. - -@table @code -@item installcheck -Perform installation tests (if any). The user must build and install -the program before running the tests. You should not assume that -@file{$(bindir)} is in the search path. - -@item installdirs -It's useful to add a target named @samp{installdirs} to create the -directories where files are installed, and their parent directories. -There is a script called @file{mkinstalldirs} which is convenient for -this; you can find it in the Texinfo package. -@c It's in /gd/gnu/lib/mkinstalldirs. -You can use a rule like this: - -@comment This has been carefully formatted to look decent in the Make manual. -@comment Please be sure not to make it extend any further to the right.--roland -@smallexample -# Make sure all installation directories (e.g. $(bindir)) -# actually exist by making them if necessary. -installdirs: mkinstalldirs - $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ - $(libdir) $(infodir) \ - $(mandir) -@end smallexample - -This rule should not modify the directories where compilation is done. -It should do nothing but create installation directories. -@end table - -@node Install Command Categories -@section Install Command Categories - -@cindex pre-installation commands -@cindex post-installation commands -When writing the @code{install} target, you must classify all the -commands into three categories: normal ones, @dfn{pre-installation} -commands and @dfn{post-installation} commands. - -Normal commands move files into their proper places, and set their -modes. They may not alter any files except the ones that come entirely -from the package they belong to. - -Pre-installation and post-installation commands may alter other files; -in particular, they can edit global configuration files or data bases. - -Pre-installation commands are typically executed before the normal -commands, and post-installation commands are typically run after the -normal commands. - -The most common use for a post-installation command is to run -@code{install-info}. This cannot be done with a normal command, since -it alters a file (the Info directory) which does not come entirely and -solely from the package being installed. It is a post-installation -command because it needs to be done after the normal command which -installs the package's Info files. - -Most programs don't need any pre-installation commands, but we have the -feature just in case it is needed. - -To classify the commands in the @code{install} rule into these three -categories, insert @dfn{category lines} among them. A category line -specifies the category for the commands that follow. - -A category line consists of a tab and a reference to a special Make -variable, plus an optional comment at the end. There are three -variables you can use, one for each category; the variable name -specifies the category. Category lines are no-ops in ordinary execution -because these three Make variables are normally undefined (and you -@emph{should not} define them in the makefile). - -Here are the three possible category lines, each with a comment that -explains what it means: - -@smallexample - $(PRE_INSTALL) # @r{Pre-install commands follow.} - $(POST_INSTALL) # @r{Post-install commands follow.} - $(NORMAL_INSTALL) # @r{Normal commands follow.} -@end smallexample - -If you don't use a category line at the beginning of the @code{install} -rule, all the commands are classified as normal until the first category -line. If you don't use any category lines, all the commands are -classified as normal. - -These are the category lines for @code{uninstall}: - -@smallexample - $(PRE_UNINSTALL) # @r{Pre-uninstall commands follow.} - $(POST_UNINSTALL) # @r{Post-uninstall commands follow.} - $(NORMAL_UNINSTALL) # @r{Normal commands follow.} -@end smallexample - -Typically, a pre-uninstall command would be used for deleting entries -from the Info directory. - -If the @code{install} or @code{uninstall} target has any dependencies -which act as subroutines of installation, then you should start -@emph{each} dependency's commands with a category line, and start the -main target's commands with a category line also. This way, you can -ensure that each command is placed in the right category regardless of -which of the dependencies actually run. - -Pre-installation and post-installation commands should not run any -programs except for these: - -@example -[ basename bash cat chgrp chmod chown cmp cp dd diff echo -egrep expand expr false fgrep find getopt grep gunzip gzip -hostname install install-info kill ldconfig ln ls md5sum -mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee -test touch true uname xargs yes -@end example - -@cindex binary packages -The reason for distinguishing the commands in this way is for the sake -of making binary packages. Typically a binary package contains all the -executables and other files that need to be installed, and has its own -method of installing them---so it does not need to run the normal -installation commands. But installing the binary package does need to -execute the pre-installation and post-installation commands. - -Programs to build binary packages work by extracting the -pre-installation and post-installation commands. Here is one way of -extracting the pre-installation commands: - -@smallexample -make -n install -o all \ - PRE_INSTALL=pre-install \ - POST_INSTALL=post-install \ - NORMAL_INSTALL=normal-install \ - | gawk -f pre-install.awk -@end smallexample - -@noindent -where the file @file{pre-install.awk} could contain this: - -@smallexample -$0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ @{on = 0@} -on @{print $0@} -$0 ~ /^\t[ \t]*pre_install[ \t]*$/ @{on = 1@} -@end smallexample - -The resulting file of pre-installation commands is executed as a shell -script as part of installing the binary package. diff --git a/make.h b/make.h index c527fb1..5162d8b 100644 --- a/make.h +++ b/make.h @@ -393,6 +393,8 @@ struct floc }; #define NILF ((struct floc *)0) +#define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1) + /* Fancy processing for variadic functions in both ANSI and pre-ANSI compilers. */ @@ -419,7 +421,7 @@ extern char *xmalloc PARAMS ((unsigned int)); extern char *xrealloc PARAMS ((char *, unsigned int)); extern char *xstrdup PARAMS ((const char *)); extern char *find_next_token PARAMS ((char **, unsigned int *)); -extern char *next_token PARAMS ((char *)); +extern char *next_token PARAMS ((const char *)); extern char *end_of_token PARAMS ((char *)); extern void collapse_continuations PARAMS ((char *)); extern void remove_comments PARAMS((char *)); diff --git a/make.texinfo b/make.texinfo deleted file mode 100644 index 8b30b5c..0000000 --- a/make.texinfo +++ /dev/null @@ -1,9955 +0,0 @@ -\input texinfo @c -*- Texinfo -*- -@c %**start of header -@setfilename make.info -@settitle GNU @code{make} -@setchapternewpage odd -@c %**end of header - -@c FSF publishers: format makebook.texi instead of using this file directly. - -@set RCSID $Id$ -@set EDITION 0.55 -@set VERSION 3.79 -@set UPDATED 04 April 2000 -@set UPDATE-MONTH April 2000 -@comment The ISBN number might need to change on next publication. -@set ISBN 1-882114-80-9 @c CHANGE THIS BEFORE PRINTING AGAIN! --psmith 16jul98 - -@c finalout - -@c ISPELL CHECK: done, 10 June 1993 --roland -@c ISPELL CHECK: done, 2000-06-25 --Martin Buchholz - -@c Combine the variable and function indices: -@syncodeindex vr fn -@c Combine the program and concept indices: -@syncodeindex pg cp - -@dircategory GNU Packages -@direntry -* Make: (make). Remake files automatically. -@end direntry - -@ifinfo -This file documents the GNU Make utility, which determines -automatically which pieces of a large program need to be recompiled, -and issues the commands to recompile them. - -This is Edition @value{EDITION}, last updated @value{UPDATED}, -of @cite{The GNU Make Manual}, for @code{make}, Version @value{VERSION}. - -Copyright (C) 1988, '89, '90, '91, '92, '93, '94, '95, '96, '97, '98, '99, 2000 - Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@end ifinfo - -@iftex -@shorttitlepage GNU Make -@end iftex -@titlepage -@title GNU Make -@subtitle A Program for Directing Recompilation -@subtitle GNU @code{make} Version @value{VERSION} -@subtitle @value{UPDATE-MONTH} -@author Richard M. Stallman and Roland McGrath -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1988, '89, '90, '91, '92, '93, '94, '95, '96, '97, '98, '99, 2000 -Free Software Foundation, Inc. -@sp 2 -Published by the Free Software Foundation @* -59 Temple Place -- Suite 330, @* -Boston, MA 02111-1307 USA @* -ISBN @value{ISBN} @* - -Maintenance and updates since Version 3.76 by Paul D. Smith. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Free Software Foundation. -@sp 2 -Cover art by Etienne Suvasa. -@end titlepage -@page - -@ifinfo -@node Top, Overview, , (dir) -@top Make - -The GNU @code{make} utility automatically determines which pieces of a -large program need to be recompiled, and issues the commands to -recompile them.@refill - -This edition of the @cite{GNU Make Manual}, -last updated @value{UPDATED}, -documents GNU @code{make} Version @value{VERSION}.@refill - -This manual describes @code{make} and contains the following chapters:@refill -@end ifinfo - -@menu -* Overview:: Overview of @code{make}. -* Introduction:: An introduction to @code{make}. -* Makefiles:: Makefiles tell @code{make} what to do. -* Rules:: Rules describe when a file must be remade. -* Commands:: Commands say how to remake a file. -* Using Variables:: You can use variables to avoid repetition. -* Conditionals:: Use or ignore parts of the makefile based - on the values of variables. -* Functions:: Many powerful ways to manipulate text. -* Invoking make: Running. How to invoke @code{make} on the command line. -* Implicit Rules:: Use implicit rules to treat many files alike, - based on their file names. -* Archives:: How @code{make} can update library archives. -* Features:: Features GNU @code{make} has over other @code{make}s. -* Missing:: What GNU @code{make} lacks from other @code{make}s. -* Makefile Conventions:: Conventions for makefiles in GNU programs. -* Quick Reference:: A quick reference for experienced users. -* Error Messages:: A list of common errors generated by @code{make}. -* Complex Makefile:: A real example of a straightforward, - but nontrivial, makefile. -* Concept Index:: Index of Concepts -* Name Index:: Index of Functions, Variables, & Directives - - --- The Detailed Node Listing --- - -Overview of @code{make} - -* Preparing:: Preparing and Running Make -* Reading:: On Reading this Text -* Bugs:: Problems and Bugs - -An Introduction to Makefiles - -* Rule Introduction:: What a rule looks like. -* Simple Makefile:: A Simple Makefile -* How Make Works:: How @code{make} Processes This Makefile -* Variables Simplify:: Variables Make Makefiles Simpler -* make Deduces:: Letting @code{make} Deduce the Commands -* Combine By Prerequisite:: Another Style of Makefile -* Cleanup:: Rules for Cleaning the Directory - -Writing Makefiles - -* Makefile Contents:: What makefiles contain. -* Makefile Names:: How to name your makefile. -* Include:: How one makefile can use another makefile. -* MAKEFILES Variable:: The environment can specify extra makefiles. -* Remaking Makefiles:: How makefiles get remade. -* Overriding Makefiles:: How to override part of one makefile - with another makefile. -* Reading Makefiles:: How makefiles are parsed. - -Writing Rules - -* Rule Example:: An example explained. -* Rule Syntax:: General syntax explained. -* Wildcards:: Using wildcard characters such as `*'. -* Directory Search:: Searching other directories for source files. -* Phony Targets:: Using a target that is not a real file's name. -* Force Targets:: You can use a target without commands - or prerequisites to mark other - targets as phony. -* Empty Targets:: When only the date matters and the - files are empty. -* Special Targets:: Targets with special built-in meanings. -* Multiple Targets:: When to make use of several targets in a rule. -* Multiple Rules:: How to use several rules with the same target. -* Static Pattern:: Static pattern rules apply to multiple targets - and can vary the prerequisites according to - the target name. -* Double-Colon:: How to use a special kind of rule to allow - several independent rules for one target. -* Automatic Prerequisites:: How to automatically generate rules giving - prerequisites from source files themselves. - -Using Wildcard Characters in File Names - -* Wildcard Examples:: Several examples -* Wildcard Pitfall:: Problems to avoid. -* Wildcard Function:: How to cause wildcard expansion where - it does not normally take place. - -Searching Directories for Prerequisites - -* General Search:: Specifying a search path that applies - to every prerequisite. -* Selective Search:: Specifying a search path - for a specified class of names. -* Search Algorithm:: When and how search paths are applied. -* Commands/Search:: How to write shell commands that work together - with search paths. -* Implicit/Search:: How search paths affect implicit rules. -* Libraries/Search:: Directory search for link libraries. - -Static Pattern Rules - -* Static Usage:: The syntax of static pattern rules. -* Static versus Implicit:: When are they better than implicit rules? - -Writing the Commands in Rules - -* Echoing:: How to control when commands are echoed. -* Execution:: How commands are executed. -* Parallel:: How commands can be executed in parallel. -* Errors:: What happens after a command execution error. -* Interrupts:: What happens when a command is interrupted. -* Recursion:: Invoking @code{make} from makefiles. -* Sequences:: Defining canned sequences of commands. -* Empty Commands:: Defining useful, do-nothing commands. - -Recursive Use of @code{make} - -* MAKE Variable:: The special effects of using @samp{$(MAKE)}. -* Variables/Recursion:: How to communicate variables to a sub-@code{make}. -* Options/Recursion:: How to communicate options to a sub-@code{make}. -* -w Option:: How the @samp{-w} or @samp{--print-directory} option - helps debug use of recursive @code{make} commands. - -How to Use Variables - -* Reference:: How to use the value of a variable. -* Flavors:: Variables come in two flavors. -* Advanced:: Advanced features for referencing a variable. -* Values:: All the ways variables get their values. -* Setting:: How to set a variable in the makefile. -* Appending:: How to append more text to the old value - of a variable. -* Override Directive:: How to set a variable in the makefile even if - the user has set it with a command argument. -* Defining:: An alternate way to set a variable - to a verbatim string. -* Environment:: Variable values can come from the environment. -* Automatic:: Some special variables have predefined - meanings for use with implicit rules. - -Advanced Features for Reference to Variables - -* Substitution Refs:: Referencing a variable with - substitutions on the value. -* Computed Names:: Computing the name of the variable to refer to. - -Conditional Parts of Makefiles - -* Conditional Example:: Example of a conditional -* Conditional Syntax:: The syntax of conditionals. -* Testing Flags:: Conditionals that test flags. - -Functions for Transforming Text - -* Syntax of Functions:: How to write a function call. -* Text Functions:: General-purpose text manipulation functions. -* File Name Functions:: Functions for manipulating file names. -* Foreach Function:: Repeat some text with controlled variation. -* Call Function:: Expand a user-defined function. -* Origin Function:: Find where a variable got its value. -* Shell Function:: Substitute the output of a shell command. - -How to Run @code{make} - -* Makefile Arguments:: How to specify which makefile to use. -* Goals:: How to use goal arguments to specify which - parts of the makefile to use. -* Instead of Execution:: How to use mode flags to specify what - kind of thing to do with the commands - in the makefile other than simply - execute them. -* Avoiding Compilation:: How to avoid recompiling certain files. -* Overriding:: How to override a variable to specify - an alternate compiler and other things. -* Testing:: How to proceed past some errors, to - test compilation. -* Options Summary:: Summary of Options - -Using Implicit Rules - -* Using Implicit:: How to use an existing implicit rule - to get the commands for updating a file. -* Catalogue of Rules:: A list of built-in implicit rules. -* Implicit Variables:: How to change what predefined rules do. -* Chained Rules:: How to use a chain of implicit rules. -* Pattern Rules:: How to define new implicit rules. -* Last Resort:: How to defining commands for rules - which cannot find any. -* Suffix Rules:: The old-fashioned style of implicit rule. -* Implicit Rule Search:: The precise algorithm for applying - implicit rules. - -Defining and Redefining Pattern Rules - -* Pattern Intro:: An introduction to pattern rules. -* Pattern Examples:: Examples of pattern rules. -* Automatic:: How to use automatic variables in the - commands of implicit rules. -* Pattern Match:: How patterns match. -* Match-Anything Rules:: Precautions you should take prior to - defining rules that can match any - target file whatever. -* Canceling Rules:: How to override or cancel built-in rules. - -Using @code{make} to Update Archive Files - -* Archive Members:: Archive members as targets. -* Archive Update:: The implicit rule for archive member targets. -* Archive Pitfalls:: Dangers to watch out for when using archives. -* Archive Suffix Rules:: You can write a special kind of suffix rule - for updating archives. - -Implicit Rule for Archive Member Targets - -* Archive Symbols:: How to update archive symbol directories. -@end menu - -@node Overview, Introduction, Top, Top -@comment node-name, next, previous, up -@chapter Overview of @code{make} - -The @code{make} utility automatically determines which pieces of a large -program need to be recompiled, and issues commands to recompile them. -This manual describes GNU @code{make}, which was implemented by Richard -Stallman and Roland McGrath. Development since Version 3.76 has been -handled by Paul D. Smith. - -GNU @code{make} conforms to section 6.2 of @cite{IEEE Standard -1003.2-1992} (POSIX.2). -@cindex POSIX -@cindex IEEE Standard 1003.2 -@cindex standards conformance - -Our examples show C programs, since they are most common, but you can use -@code{make} with any programming language whose compiler can be run with a -shell command. Indeed, @code{make} is not limited to programs. You can -use it to describe any task where some files must be updated automatically -from others whenever the others change. - -@menu -* Preparing:: Preparing and Running Make -* Reading:: On Reading this Text -* Bugs:: Problems and Bugs -@end menu - -@node Preparing, Reading, , Overview -@ifinfo -@heading Preparing and Running Make -@end ifinfo - -To prepare to use @code{make}, you must write a file called -the @dfn{makefile} that describes the relationships among files -in your program and provides commands for updating each file. -In a program, typically, the executable file is updated from object -files, which are in turn made by compiling source files.@refill - -Once a suitable makefile exists, each time you change some source files, -this simple shell command: - -@example -make -@end example - -@noindent -suffices to perform all necessary recompilations. The @code{make} program -uses the makefile data base and the last-modification times of the files to -decide which of the files need to be updated. For each of those files, it -issues the commands recorded in the data base. - -You can provide command line arguments to @code{make} to control which -files should be recompiled, or how. @xref{Running, ,How to Run -@code{make}}. - -@node Reading, Bugs, Preparing, Overview -@section How to Read This Manual - -If you are new to @code{make}, or are looking for a general -introduction, read the first few sections of each chapter, skipping the -later sections. In each chapter, the first few sections contain -introductory or general information and the later sections contain -specialized or technical information. -@ifinfo -The exception is the second chapter, @ref{Introduction, ,An -Introduction to Makefiles}, all of which is introductory. -@end ifinfo -@iftex -The exception is @ref{Introduction, ,An Introduction to Makefiles}, -all of which is introductory. -@end iftex - -If you are familiar with other @code{make} programs, see @ref{Features, -,Features of GNU @code{make}}, which lists the enhancements GNU -@code{make} has, and @ref{Missing, ,Incompatibilities and Missing -Features}, which explains the few things GNU @code{make} lacks that -others have. - -For a quick summary, see @ref{Options Summary}, @ref{Quick Reference}, -and @ref{Special Targets}. - -@node Bugs, , Reading, Overview -@section Problems and Bugs -@cindex reporting bugs -@cindex bugs, reporting -@cindex problems and bugs, reporting - -If you have problems with GNU @code{make} or think you've found a bug, -please report it to the developers; we cannot promise to do anything but -we might well want to fix it. - -Before reporting a bug, make sure you've actually found a real bug. -Carefully reread the documentation and see if it really says you can do -what you're trying to do. If it's not clear whether you should be able -to do something or not, report that too; it's a bug in the -documentation! - -Before reporting a bug or trying to fix it yourself, try to isolate it -to the smallest possible makefile that reproduces the problem. Then -send us the makefile and the exact results @code{make} gave you. Also -say what you expected to occur; this will help us decide whether the -problem was really in the documentation. - -Once you've got a precise problem, please send electronic mail to: - -@example - bug-make@@gnu.org -@end example - -@noindent -Please include the version number of @code{make} you are using. You can -get this information with the command @samp{make --version}. -Be sure also to include the type of machine and operating system you are -using. If possible, include the contents of the file @file{config.h} -that is generated by the configuration process. - -@node Introduction, Makefiles, Overview, Top -@comment node-name, next, previous, up -@chapter An Introduction to Makefiles - -You need a file called a @dfn{makefile} to tell @code{make} what to do. -Most often, the makefile tells @code{make} how to compile and link a -program. -@cindex makefile - -In this chapter, we will discuss a simple makefile that describes how to -compile and link a text editor which consists of eight C source files -and three header files. The makefile can also tell @code{make} how to -run miscellaneous commands when explicitly asked (for example, to remove -certain files as a clean-up operation). To see a more complex example -of a makefile, see @ref{Complex Makefile}. - -When @code{make} recompiles the editor, each changed C source file -must be recompiled. If a header file has changed, each C source file -that includes the header file must be recompiled to be safe. Each -compilation produces an object file corresponding to the source file. -Finally, if any source file has been recompiled, all the object files, -whether newly made or saved from previous compilations, must be linked -together to produce the new executable editor. -@cindex recompilation -@cindex editor - -@menu -* Rule Introduction:: What a rule looks like. -* Simple Makefile:: A Simple Makefile -* How Make Works:: How @code{make} Processes This Makefile -* Variables Simplify:: Variables Make Makefiles Simpler -* make Deduces:: Letting @code{make} Deduce the Commands -* Combine By Prerequisite:: Another Style of Makefile -* Cleanup:: Rules for Cleaning the Directory -@end menu - -@node Rule Introduction, Simple Makefile, , Introduction -@comment node-name, next, previous, up -@section What a Rule Looks Like -@cindex rule, introduction to -@cindex makefile rule parts -@cindex parts of makefile rule - -A simple makefile consists of ``rules'' with the following shape: - -@cindex targets, introduction to -@cindex prerequisites, introduction to -@cindex commands, introduction to -@example -@group -@var{target} @dots{} : @var{prerequisites} @dots{} - @var{command} - @dots{} - @dots{} -@end group -@end example - -A @dfn{target} is usually the name of a file that is generated by a -program; examples of targets are executable or object files. A target -can also be the name of an action to carry out, such as @samp{clean} -(@pxref{Phony Targets}). - -A @dfn{prerequisite} is a file that is used as input to create the -target. A target often depends on several files. - -@cindex tabs in rules -A @dfn{command} is an action that @code{make} carries out. -A rule may have more than one command, each on its own line. -@strong{Please note:} you need to put a tab character at the beginning of -every command line! This is an obscurity that catches the unwary. - -Usually a command is in a rule with prerequisites and serves to create a -target file if any of the prerequisites change. However, the rule that -specifies commands for the target need not have prerequisites. For -example, the rule containing the delete command associated with the -target @samp{clean} does not have prerequisites. - -A @dfn{rule}, then, explains how and when to remake certain files -which are the targets of the particular rule. @code{make} carries out -the commands on the prerequisites to create or update the target. A -rule can also explain how and when to carry out an action. -@xref{Rules, , Writing Rules}. - -A makefile may contain other text besides rules, but a simple makefile -need only contain rules. Rules may look somewhat more complicated -than shown in this template, but all fit the pattern more or less. - -@node Simple Makefile, How Make Works, Rule Introduction, Introduction -@section A Simple Makefile -@cindex simple makefile -@cindex makefile, simple - -Here is a straightforward makefile that describes the way an -executable file called @code{edit} depends on eight object files -which, in turn, depend on eight C source and three header files. - -In this example, all the C files include @file{defs.h}, but only those -defining editing commands include @file{command.h}, and only low -level files that change the editor buffer include @file{buffer.h}. - -@example -@group -edit : main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o - cc -o edit main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o - -main.o : main.c defs.h - cc -c main.c -kbd.o : kbd.c defs.h command.h - cc -c kbd.c -command.o : command.c defs.h command.h - cc -c command.c -display.o : display.c defs.h buffer.h - cc -c display.c -insert.o : insert.c defs.h buffer.h - cc -c insert.c -search.o : search.c defs.h buffer.h - cc -c search.c -files.o : files.c defs.h buffer.h command.h - cc -c files.c -utils.o : utils.c defs.h - cc -c utils.c -clean : - rm edit main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o -@end group -@end example - -@noindent -We split each long line into two lines using backslash-newline; this is -like using one long line, but is easier to read. -@cindex continuation lines -@cindex @code{\} (backslash), for continuation lines -@cindex backslash (@code{\}), for continuation lines -@cindex quoting newline, in makefile -@cindex newline, quoting, in makefile - -To use this makefile to create the executable file called @file{edit}, -type: - -@example -make -@end example - -To use this makefile to delete the executable file and all the object -files from the directory, type: - -@example -make clean -@end example - -In the example makefile, the targets include the executable file -@samp{edit}, and the object files @samp{main.o} and @samp{kbd.o}. The -prerequisites are files such as @samp{main.c} and @samp{defs.h}. -In fact, each @samp{.o} file is both a target and a prerequisite. -Commands include @w{@samp{cc -c main.c}} and @w{@samp{cc -c kbd.c}}. - -When a target is a file, it needs to be recompiled or relinked if any -of its prerequisites change. In addition, any prerequisites that are -themselves automatically generated should be updated first. In this -example, @file{edit} depends on each of the eight object files; the -object file @file{main.o} depends on the source file @file{main.c} and -on the header file @file{defs.h}. - -A shell command follows each line that contains a target and -prerequisites. These shell commands say how to update the target file. -A tab character must come at the beginning of every command line to -distinguish commands lines from other lines in the makefile. (Bear in -mind that @code{make} does not know anything about how the commands -work. It is up to you to supply commands that will update the target -file properly. All @code{make} does is execute the commands in the rule -you have specified when the target file needs to be updated.) -@cindex shell command - -The target @samp{clean} is not a file, but merely the name of an -action. Since you -normally -do not want to carry out the actions in this rule, @samp{clean} is not a prerequisite of any other rule. -Consequently, @code{make} never does anything with it unless you tell -it specifically. Note that this rule not only is not a prerequisite, it -also does not have any prerequisites, so the only purpose of the rule -is to run the specified commands. Targets that do not refer to files -but are just actions are called @dfn{phony targets}. @xref{Phony -Targets}, for information about this kind of target. @xref{Errors, , -Errors in Commands}, to see how to cause @code{make} to ignore errors -from @code{rm} or any other command. -@cindex @code{clean} target -@cindex @code{rm} (shell command) - -@node How Make Works, Variables Simplify, Simple Makefile, Introduction -@comment node-name, next, previous, up -@section How @code{make} Processes a Makefile -@cindex processing a makefile -@cindex makefile, how @code{make} processes - -By default, @code{make} starts with the first target (not targets whose -names start with @samp{.}). This is called the @dfn{default goal}. -(@dfn{Goals} are the targets that @code{make} strives ultimately to -update. @xref{Goals, , Arguments to Specify the Goals}.) -@cindex default goal -@cindex goal, default -@cindex goal - -In the simple example of the previous section, the default goal is to -update the executable program @file{edit}; therefore, we put that rule -first. - -Thus, when you give the command: - -@example -make -@end example - -@noindent -@code{make} reads the makefile in the current directory and begins by -processing the first rule. In the example, this rule is for relinking -@file{edit}; but before @code{make} can fully process this rule, it -must process the rules for the files that @file{edit} depends on, -which in this case are the object files. Each of these files is -processed according to its own rule. These rules say to update each -@samp{.o} file by compiling its source file. The recompilation must -be done if the source file, or any of the header files named as -prerequisites, is more recent than the object file, or if the object -file does not exist. - -The other rules are processed because their targets appear as -prerequisites of the goal. If some other rule is not depended on by the -goal (or anything it depends on, etc.), that rule is not processed, -unless you tell @code{make} to do so (with a command such as -@w{@code{make clean}}). - -Before recompiling an object file, @code{make} considers updating its -prerequisites, the source file and header files. This makefile does not -specify anything to be done for them---the @samp{.c} and @samp{.h} files -are not the targets of any rules---so @code{make} does nothing for these -files. But @code{make} would update automatically generated C programs, -such as those made by Bison or Yacc, by their own rules at this time. - -After recompiling whichever object files need it, @code{make} decides -whether to relink @file{edit}. This must be done if the file -@file{edit} does not exist, or if any of the object files are newer than -it. If an object file was just recompiled, it is now newer than -@file{edit}, so @file{edit} is relinked. -@cindex relinking - -Thus, if we change the file @file{insert.c} and run @code{make}, -@code{make} will compile that file to update @file{insert.o}, and then -link @file{edit}. If we change the file @file{command.h} and run -@code{make}, @code{make} will recompile the object files @file{kbd.o}, -@file{command.o} and @file{files.o} and then link the file @file{edit}. - -@node Variables Simplify, make Deduces, How Make Works, Introduction -@section Variables Make Makefiles Simpler -@cindex variables -@cindex simplifying with variables - -In our example, we had to list all the object files twice in the rule for -@file{edit} (repeated here): - -@example -@group -edit : main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o - cc -o edit main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o -@end group -@end example - -@cindex @code{objects} -Such duplication is error-prone; if a new object file is added to the -system, we might add it to one list and forget the other. We can eliminate -the risk and simplify the makefile by using a variable. @dfn{Variables} -allow a text string to be defined once and substituted in multiple places -later (@pxref{Using Variables, ,How to Use Variables}). - -@cindex @code{OBJECTS} -@cindex @code{objs} -@cindex @code{OBJS} -@cindex @code{obj} -@cindex @code{OBJ} -It is standard practice for every makefile to have a variable named -@code{objects}, @code{OBJECTS}, @code{objs}, @code{OBJS}, @code{obj}, -or @code{OBJ} which is a list of all object file names. We would -define such a variable @code{objects} with a line like this in the -makefile:@refill - -@example -@group -objects = main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o -@end group -@end example - -@noindent -Then, each place we want to put a list of the object file names, we can -substitute the variable's value by writing @samp{$(objects)} -(@pxref{Using Variables, ,How to Use Variables}). - -Here is how the complete simple makefile looks when you use a variable -for the object files: - -@example -@group -objects = main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o - -edit : $(objects) - cc -o edit $(objects) -main.o : main.c defs.h - cc -c main.c -kbd.o : kbd.c defs.h command.h - cc -c kbd.c -command.o : command.c defs.h command.h - cc -c command.c -display.o : display.c defs.h buffer.h - cc -c display.c -insert.o : insert.c defs.h buffer.h - cc -c insert.c -search.o : search.c defs.h buffer.h - cc -c search.c -files.o : files.c defs.h buffer.h command.h - cc -c files.c -utils.o : utils.c defs.h - cc -c utils.c -clean : - rm edit $(objects) -@end group -@end example - -@node make Deduces, Combine By Prerequisite, Variables Simplify, Introduction -@section Letting @code{make} Deduce the Commands -@cindex deducing commands (implicit rules) -@cindex implicit rule, introduction to -@cindex rule, implicit, introduction to - -It is not necessary to spell out the commands for compiling the individual -C source files, because @code{make} can figure them out: it has an -@dfn{implicit rule} for updating a @samp{.o} file from a correspondingly -named @samp{.c} file using a @samp{cc -c} command. For example, it will -use the command @samp{cc -c main.c -o main.o} to compile @file{main.c} into -@file{main.o}. We can therefore omit the commands from the rules for the -object files. @xref{Implicit Rules, ,Using Implicit Rules}.@refill - -When a @samp{.c} file is used automatically in this way, it is also -automatically added to the list of prerequisites. We can therefore omit -the @samp{.c} files from the prerequisites, provided we omit the commands. - -Here is the entire example, with both of these changes, and a variable -@code{objects} as suggested above: - -@example -@group -objects = main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o - -edit : $(objects) - cc -o edit $(objects) - -main.o : defs.h -kbd.o : defs.h command.h -command.o : defs.h command.h -display.o : defs.h buffer.h -insert.o : defs.h buffer.h -search.o : defs.h buffer.h -files.o : defs.h buffer.h command.h -utils.o : defs.h - -.PHONY : clean -clean : - -rm edit $(objects) -@end group -@end example - -@noindent -This is how we would write the makefile in actual practice. (The -complications associated with @samp{clean} are described elsewhere. -See @ref{Phony Targets}, and @ref{Errors, ,Errors in Commands}.) - -Because implicit rules are so convenient, they are important. You -will see them used frequently.@refill - -@node Combine By Prerequisite, Cleanup, make Deduces, Introduction -@section Another Style of Makefile -@cindex combining rules by prerequisite - -When the objects of a makefile are created only by implicit rules, an -alternative style of makefile is possible. In this style of makefile, -you group entries by their prerequisites instead of by their targets. -Here is what one looks like: - -@example -@group -objects = main.o kbd.o command.o display.o \ - insert.o search.o files.o utils.o - -edit : $(objects) - cc -o edit $(objects) - -$(objects) : defs.h -kbd.o command.o files.o : command.h -display.o insert.o search.o files.o : buffer.h -@end group -@end example - -@noindent -Here @file{defs.h} is given as a prerequisite of all the object files; -@file{command.h} and @file{buffer.h} are prerequisites of the specific -object files listed for them. - -Whether this is better is a matter of taste: it is more compact, but some -people dislike it because they find it clearer to put all the information -about each target in one place. - -@node Cleanup, , Combine By Prerequisite, Introduction -@section Rules for Cleaning the Directory -@cindex cleaning up -@cindex removing, to clean up - -Compiling a program is not the only thing you might want to write rules -for. Makefiles commonly tell how to do a few other things besides -compiling a program: for example, how to delete all the object files -and executables so that the directory is @samp{clean}. - -@cindex @code{clean} target -Here is how we -could write a @code{make} rule for cleaning our example editor: - -@example -@group -clean: - rm edit $(objects) -@end group -@end example - -In practice, we might want to write the rule in a somewhat more -complicated manner to handle unanticipated situations. We would do this: - -@example -@group -.PHONY : clean -clean : - -rm edit $(objects) -@end group -@end example - -@noindent -This prevents @code{make} from getting confused by an actual file -called @file{clean} and causes it to continue in spite of errors from -@code{rm}. (See @ref{Phony Targets}, and @ref{Errors, ,Errors in -Commands}.) - -@noindent -A rule such as this should not be placed at the beginning of the -makefile, because we do not want it to run by default! Thus, in the -example makefile, we want the rule for @code{edit}, which recompiles -the editor, to remain the default goal. - -Since @code{clean} is not a prerequisite of @code{edit}, this rule will not -run at all if we give the command @samp{make} with no arguments. In -order to make the rule run, we have to type @samp{make clean}. -@xref{Running, ,How to Run @code{make}}. - -@node Makefiles, Rules, Introduction, Top -@chapter Writing Makefiles - -@cindex makefile, how to write -The information that tells @code{make} how to recompile a system comes from -reading a data base called the @dfn{makefile}. - -@menu -* Makefile Contents:: What makefiles contain. -* Makefile Names:: How to name your makefile. -* Include:: How one makefile can use another makefile. -* MAKEFILES Variable:: The environment can specify extra makefiles. -* Remaking Makefiles:: How makefiles get remade. -* Overriding Makefiles:: How to override part of one makefile - with another makefile. -* Reading Makefiles:: How makefiles are parsed. -@end menu - -@node Makefile Contents, Makefile Names, , Makefiles -@section What Makefiles Contain - -Makefiles contain five kinds of things: @dfn{explicit rules}, -@dfn{implicit rules}, @dfn{variable definitions}, @dfn{directives}, -and @dfn{comments}. Rules, variables, and directives are described at -length in later chapters.@refill - -@itemize @bullet -@cindex rule, explicit, definition of -@cindex explicit rule, definition of -@item -An @dfn{explicit rule} says when and how to remake one or more files, -called the rule's targets. It lists the other files that the targets -depend on, call the @dfn{prerequisites} of the target, and may also give -commands to use to create or update the targets. @xref{Rules, ,Writing -Rules}. - -@cindex rule, implicit, definition of -@cindex implicit rule, definition of -@item -An @dfn{implicit rule} says when and how to remake a class of files -based on their names. It describes how a target may depend on a file -with a name similar to the target and gives commands to create or -update such a target. @xref{Implicit Rules, ,Using Implicit Rules}. - -@cindex variable definition -@item -A @dfn{variable definition} is a line that specifies a text string -value for a variable that can be substituted into the text later. The -simple makefile example shows a variable definition for @code{objects} -as a list of all object files (@pxref{Variables Simplify, , Variables -Make Makefiles Simpler}). - -@cindex directive -@item -A @dfn{directive} is a command for @code{make} to do something special while -reading the makefile. These include: - -@itemize @bullet -@item -Reading another makefile (@pxref{Include, ,Including Other Makefiles}). - -@item -Deciding (based on the values of variables) whether to use or -ignore a part of the makefile (@pxref{Conditionals, ,Conditional Parts of Makefiles}). - -@item -Defining a variable from a verbatim string containing multiple lines -(@pxref{Defining, ,Defining Variables Verbatim}). -@end itemize - -@cindex comments, in makefile -@cindex @code{#} (comments), in makefile -@item -@samp{#} in a line of a makefile starts a @dfn{comment}. It and the rest of -the line are ignored, except that a trailing backslash not escaped by -another backslash will continue the comment across multiple lines. -Comments may appear on any of the lines in the makefile, except within a -@code{define} directive, and perhaps within commands (where the shell -decides what is a comment). A line containing just a comment (with -perhaps spaces before it) is effectively blank, and is ignored.@refill -@end itemize - -@node Makefile Names, Include, Makefile Contents, Makefiles -@section What Name to Give Your Makefile -@cindex makefile name -@cindex name of makefile -@cindex default makefile name -@cindex file name of makefile - -@c following paragraph rewritten to avoid overfull hbox -By default, when @code{make} looks for the makefile, it tries the -following names, in order: @file{GNUmakefile}, @file{makefile} -and @file{Makefile}.@refill -@findex Makefile -@findex GNUmakefile -@findex makefile - -@cindex @code{README} -Normally you should call your makefile either @file{makefile} or -@file{Makefile}. (We recommend @file{Makefile} because it appears -prominently near the beginning of a directory listing, right near other -important files such as @file{README}.) The first name checked, -@file{GNUmakefile}, is not recommended for most makefiles. You should -use this name if you have a makefile that is specific to GNU -@code{make}, and will not be understood by other versions of -@code{make}. Other @code{make} programs look for @file{makefile} and -@file{Makefile}, but not @file{GNUmakefile}. - -If @code{make} finds none of these names, it does not use any makefile. -Then you must specify a goal with a command argument, and @code{make} -will attempt to figure out how to remake it using only its built-in -implicit rules. @xref{Implicit Rules, ,Using Implicit Rules}. - -@cindex @code{-f} -@cindex @code{--file} -@cindex @code{--makefile} -If you want to use a nonstandard name for your makefile, you can specify -the makefile name with the @samp{-f} or @samp{--file} option. The -arguments @w{@samp{-f @var{name}}} or @w{@samp{--file=@var{name}}} tell -@code{make} to read the file @var{name} as the makefile. If you use -more than one @samp{-f} or @samp{--file} option, you can specify several -makefiles. All the makefiles are effectively concatenated in the order -specified. The default makefile names @file{GNUmakefile}, -@file{makefile} and @file{Makefile} are not checked automatically if you -specify @samp{-f} or @samp{--file}.@refill -@cindex specifying makefile name -@cindex makefile name, how to specify -@cindex name of makefile, how to specify -@cindex file name of makefile, how to specify - -@node Include, MAKEFILES Variable, Makefile Names, Makefiles -@section Including Other Makefiles -@cindex including other makefiles -@cindex makefile, including - -@findex include -The @code{include} directive tells @code{make} to suspend reading the -current makefile and read one or more other makefiles before continuing. -The directive is a line in the makefile that looks like this: - -@example -include @var{filenames}@dots{} -@end example - -@noindent -@var{filenames} can contain shell file name patterns. -@cindex shell file name pattern (in @code{include}) -@cindex shell wildcards (in @code{include}) -@cindex wildcard, in @code{include} - -Extra spaces are allowed and ignored at the beginning of the line, but -a tab is not allowed. (If the line begins with a tab, it will be -considered a command line.) Whitespace is required between -@code{include} and the file names, and between file names; extra -whitespace is ignored there and at the end of the directive. A -comment starting with @samp{#} is allowed at the end of the line. If -the file names contain any variable or function references, they are -expanded. @xref{Using Variables, ,How to Use Variables}. - -For example, if you have three @file{.mk} files, @file{a.mk}, -@file{b.mk}, and @file{c.mk}, and @code{$(bar)} expands to -@code{bish bash}, then the following expression - -@example -include foo *.mk $(bar) -@end example - -is equivalent to - -@example -include foo a.mk b.mk c.mk bish bash -@end example - -When @code{make} processes an @code{include} directive, it suspends -reading of the containing makefile and reads from each listed file in -turn. When that is finished, @code{make} resumes reading the -makefile in which the directive appears. - -One occasion for using @code{include} directives is when several programs, -handled by individual makefiles in various directories, need to use a -common set of variable definitions -(@pxref{Setting, ,Setting Variables}) or pattern rules -(@pxref{Pattern Rules, ,Defining and Redefining Pattern Rules}). - -Another such occasion is when you want to generate prerequisites from -source files automatically; the prerequisites can be put in a file that -is included by the main makefile. This practice is generally cleaner -than that of somehow appending the prerequisites to the end of the main -makefile as has been traditionally done with other versions of -@code{make}. @xref{Automatic Prerequisites}. -@cindex prerequisites, automatic generation -@cindex automatic generation of prerequisites -@cindex generating prerequisites automatically - -@cindex @code{-I} -@cindex @code{--include-dir} -@cindex included makefiles, default directories -@cindex default directories for included makefiles -@findex /usr/gnu/include -@findex /usr/local/include -@findex /usr/include -If the specified name does not start with a slash, and the file is not -found in the current directory, several other directories are searched. -First, any directories you have specified with the @samp{-I} or -@samp{--include-dir} option are searched -(@pxref{Options Summary, ,Summary of Options}). -Then the following directories (if they exist) -are searched, in this order: -@file{@var{prefix}/include} (normally @file{/usr/local/include} -@footnote{GNU Make compiled for MS-DOS and MS-Windows behaves as if -@var{prefix} has been defined to be the root of the DJGPP tree -hierarchy.}) -@file{/usr/gnu/include}, -@file{/usr/local/include}, @file{/usr/include}. - -If an included makefile cannot be found in any of these directories, a -warning message is generated, but it is not an immediately fatal error; -processing of the makefile containing the @code{include} continues. -Once it has finished reading makefiles, @code{make} will try to remake -any that are out of date or don't exist. -@xref{Remaking Makefiles, ,How Makefiles Are Remade}. -Only after it has tried to find a way to remake a makefile and failed, -will @code{make} diagnose the missing makefile as a fatal error. - -If you want @code{make} to simply ignore a makefile which does not exist -and cannot be remade, with no error message, use the @w{@code{-include}} -directive instead of @code{include}, like this: - -@example --include @var{filenames}@dots{} -@end example - -This is acts like @code{include} in every way except that there is no -error (not even a warning) if any of the @var{filenames} do not exist. -For compatibility with some other @code{make} implementations, -@code{sinclude} is another name for @w{@code{-include}}. - -@node MAKEFILES Variable, Remaking Makefiles, Include, Makefiles -@section The Variable @code{MAKEFILES} -@cindex makefile, and @code{MAKEFILES} variable -@cindex including (@code{MAKEFILES} variable) - -@vindex MAKEFILES -If the environment variable @code{MAKEFILES} is defined, @code{make} -considers its value as a list of names (separated by whitespace) of -additional makefiles to be read before the others. This works much like -the @code{include} directive: various directories are searched for those -files (@pxref{Include, ,Including Other Makefiles}). In addition, the -default goal is never taken from one of these makefiles and it is not an -error if the files listed in @code{MAKEFILES} are not found.@refill - -@cindex recursion, and @code{MAKEFILES} variable -The main use of @code{MAKEFILES} is in communication between recursive -invocations of @code{make} (@pxref{Recursion, ,Recursive Use of -@code{make}}). It usually is not desirable to set the environment -variable before a top-level invocation of @code{make}, because it is -usually better not to mess with a makefile from outside. However, if -you are running @code{make} without a specific makefile, a makefile in -@code{MAKEFILES} can do useful things to help the built-in implicit -rules work better, such as defining search paths (@pxref{Directory Search}). - -Some users are tempted to set @code{MAKEFILES} in the environment -automatically on login, and program makefiles to expect this to be done. -This is a very bad idea, because such makefiles will fail to work if run by -anyone else. It is much better to write explicit @code{include} directives -in the makefiles. @xref{Include, , Including Other Makefiles}. - -@node Remaking Makefiles, Overriding Makefiles, MAKEFILES Variable, Makefiles -@section How Makefiles Are Remade - -@cindex updating makefiles -@cindex remaking makefiles -@cindex makefile, remaking of -Sometimes makefiles can be remade from other files, such as RCS or SCCS -files. If a makefile can be remade from other files, you probably want -@code{make} to get an up-to-date version of the makefile to read in. - -To this end, after reading in all makefiles, @code{make} will consider -each as a goal target and attempt to update it. If a makefile has a -rule which says how to update it (found either in that very makefile or -in another one) or if an implicit rule applies to it (@pxref{Implicit -Rules, ,Using Implicit Rules}), it will be updated if necessary. After -all makefiles have been checked, if any have actually been changed, -@code{make} starts with a clean slate and reads all the makefiles over -again. (It will also attempt to update each of them over again, but -normally this will not change them again, since they are already up to -date.)@refill - -If you know that one or more of your makefiles cannot be remade and you -want to keep @code{make} from performing an implicit rule search on -them, perhaps for efficiency reasons, you can use any normal method of -preventing implicit rule lookup to do so. For example, you can write an -explicit rule with the makefile as the target, and an empty command -string (@pxref{Empty Commands, ,Using Empty Commands}). - -If the makefiles specify a double-colon rule to remake a file with -commands but no prerequisites, that file will always be remade -(@pxref{Double-Colon}). In the case of makefiles, a makefile that has a -double-colon rule with commands but no prerequisites will be remade every -time @code{make} is run, and then again after @code{make} starts over -and reads the makefiles in again. This would cause an infinite loop: -@code{make} would constantly remake the makefile, and never do anything -else. So, to avoid this, @code{make} will @strong{not} attempt to -remake makefiles which are specified as targets of a double-colon rule -with commands but no prerequisites.@refill - -If you do not specify any makefiles to be read with @samp{-f} or -@samp{--file} options, @code{make} will try the default makefile names; -@pxref{Makefile Names, ,What Name to Give Your Makefile}. Unlike -makefiles explicitly requested with @samp{-f} or @samp{--file} options, -@code{make} is not certain that these makefiles should exist. However, -if a default makefile does not exist but can be created by running -@code{make} rules, you probably want the rules to be run so that the -makefile can be used. - -Therefore, if none of the default makefiles exists, @code{make} will try -to make each of them in the same order in which they are searched for -(@pxref{Makefile Names, ,What Name to Give Your Makefile}) -until it succeeds in making one, or it runs out of names to try. Note -that it is not an error if @code{make} cannot find or make any makefile; -a makefile is not always necessary.@refill - -When you use the @samp{-t} or @samp{--touch} option -(@pxref{Instead of Execution, ,Instead of Executing the Commands}), -you would not want to use an out-of-date makefile to decide which -targets to touch. So the @samp{-t} option has no effect on updating -makefiles; they are really updated even if @samp{-t} is specified. -Likewise, @samp{-q} (or @samp{--question}) and @samp{-n} (or -@samp{--just-print}) do not prevent updating of makefiles, because an -out-of-date makefile would result in the wrong output for other targets. -Thus, @samp{make -f mfile -n foo} will update @file{mfile}, read it in, -and then print the commands to update @file{foo} and its prerequisites -without running them. The commands printed for @file{foo} will be those -specified in the updated contents of @file{mfile}. - -However, on occasion you might actually wish to prevent updating of even -the makefiles. You can do this by specifying the makefiles as goals in -the command line as well as specifying them as makefiles. When the -makefile name is specified explicitly as a goal, the options @samp{-t} -and so on do apply to them. - -Thus, @samp{make -f mfile -n mfile foo} would read the makefile -@file{mfile}, print the commands needed to update it without actually -running them, and then print the commands needed to update @file{foo} -without running them. The commands for @file{foo} will be those -specified by the existing contents of @file{mfile}. - -@node Overriding Makefiles, Reading Makefiles, Remaking Makefiles, Makefiles -@section Overriding Part of Another Makefile - -@cindex overriding makefiles -@cindex makefile, overriding -Sometimes it is useful to have a makefile that is mostly just like -another makefile. You can often use the @samp{include} directive to -include one in the other, and add more targets or variable definitions. -However, if the two makefiles give different commands for the same -target, @code{make} will not let you just do this. But there is another way. - -@cindex match-anything rule, used to override -In the containing makefile (the one that wants to include the other), -you can use a match-anything pattern rule to say that to remake any -target that cannot be made from the information in the containing -makefile, @code{make} should look in another makefile. -@xref{Pattern Rules}, for more information on pattern rules. - -For example, if you have a makefile called @file{Makefile} that says how -to make the target @samp{foo} (and other targets), you can write a -makefile called @file{GNUmakefile} that contains: - -@example -foo: - frobnicate > foo - -%: force - @@$(MAKE) -f Makefile $@@ -force: ; -@end example - -If you say @samp{make foo}, @code{make} will find @file{GNUmakefile}, -read it, and see that to make @file{foo}, it needs to run the command -@samp{frobnicate > foo}. If you say @samp{make bar}, @code{make} will -find no way to make @file{bar} in @file{GNUmakefile}, so it will use the -commands from the pattern rule: @samp{make -f Makefile bar}. If -@file{Makefile} provides a rule for updating @file{bar}, @code{make} -will apply the rule. And likewise for any other target that -@file{GNUmakefile} does not say how to make. - -The way this works is that the pattern rule has a pattern of just -@samp{%}, so it matches any target whatever. The rule specifies a -prerequisite @file{force}, to guarantee that the commands will be run even -if the target file already exists. We give @file{force} target empty -commands to prevent @code{make} from searching for an implicit rule to -build it---otherwise it would apply the same match-anything rule to -@file{force} itself and create a prerequisite loop! - -@node Reading Makefiles, , Overriding Makefiles, Makefiles -@section How @code{make} Reads a Makefile -@cindex reading makefiles -@cindex makefile, parsing - -GNU @code{make} does its work in two distinct phases. During the first -phase it reads all the makefiles, included makefiles, etc. and -internalizes all the variables and their values, implicit and explicit -rules, and constructs a dependency graph of all the targets and their -prerequisites. During the second phase, @code{make} uses these internal -structures to determine what targets will need to be rebuilt and to -invoke the rules necessary to do so. - -It's important to understand this two-phase approach because it has a -direct impact on how variable and function expansion happens; this is -often a source of some confusion when writing makefiles. Here we will -present a summary of the phases in which expansion happens for different -constructs within the makefile. We say that expansion is -@dfn{immediate} if it happens during the first phase: in this case -@code{make} will expand any variables or functions in that section of a -construct as the makefile is parsed. We say that expansion is -@dfn{deferred} if expansion is not performed immediately. Expansion of -deferred construct is not performed until either the construct appears -later in an immediate context, or until the second phase. - -You may not be familiar with some of these constructs yet. You can -reference this section as you become familiar with them, in later -chapters. - -@subheading Variable Assignment -@cindex +=, expansion -@cindex =, expansion -@cindex ?=, expansion -@cindex +=, expansion -@cindex define, expansion - -Variable definitions are parsed as follows: - -@example -@var{immediate} = @var{deferred} -@var{immediate} ?= @var{deferred} -@var{immediate} := @var{immediate} -@var{immediate} += @var{deferred} or @var{immediate} - -define @var{immediate} - @var{deferred} -endef -@end example - -For the append operator, @samp{+=}, the right-hand side is considered -immediate if the variable was previously set as a simple variable -(@samp{:=}), and deferred otherwise. - -@subheading Conditional Syntax -@cindex ifdef, expansion -@cindex ifeq, expansion -@cindex ifndef, expansion -@cindex ifneq, expansion - -All instances of conditional syntax are parsed immediately, in their -entirety; this includes the @code{ifdef}, @code{ifeq}, @code{ifndef}, -and @code{ifneq} forms. - -@subheading Rule Definition -@cindex target, expansion -@cindex prerequisite, expansion -@cindex implicit rule, expansion -@cindex pattern rule, expansion -@cindex explicit rule, expansion - -A rule is always expanded the same way, regardless of the form: - -@example -@var{immediate} : @var{immediate} ; @var{deferred} - @var{deferred} -@end example - -That is, the target and prerequisite sections are expanded immediately, -and the commands used to construct the target are always deferred. This -general rule is true for explicit rules, pattern rules, suffix rules, -static pattern rules, and simple prerequisite definitions. - -@node Rules, Commands, Makefiles, Top -@chapter Writing Rules -@cindex writing rules -@cindex rule, how to write -@cindex target -@cindex prerequisite - -A @dfn{rule} appears in the makefile and says when and how to remake -certain files, called the rule's @dfn{targets} (most often only one per rule). -It lists the other files that are the @dfn{prerequisites} of the target, and -@dfn{commands} to use to create or update the target. - -@cindex default goal -@cindex goal, default -The order of rules is not significant, except for determining the -@dfn{default goal}: the target for @code{make} to consider, if you do -not otherwise specify one. The default goal is the target of the first -rule in the first makefile. If the first rule has multiple targets, -only the first target is taken as the default. There are two -exceptions: a target starting with a period is not a default unless it -contains one or more slashes, @samp{/}, as well; and, a target that -defines a pattern rule has no effect on the default goal. -(@xref{Pattern Rules, ,Defining and Redefining Pattern Rules}.) - -Therefore, we usually write the makefile so that the first rule is the -one for compiling the entire program or all the programs described by -the makefile (often with a target called @samp{all}). -@xref{Goals, ,Arguments to Specify the Goals}. - -@menu -* Rule Example:: An example explained. -* Rule Syntax:: General syntax explained. -* Wildcards:: Using wildcard characters such as `*'. -* Directory Search:: Searching other directories for source files. -* Phony Targets:: Using a target that is not a real file's name. -* Force Targets:: You can use a target without commands - or prerequisites to mark other - targets as phony. -* Empty Targets:: When only the date matters and the - files are empty. -* Special Targets:: Targets with special built-in meanings. -* Multiple Targets:: When to make use of several targets in a rule. -* Multiple Rules:: How to use several rules with the same target. -* Static Pattern:: Static pattern rules apply to multiple targets - and can vary the prerequisites according to - the target name. -* Double-Colon:: How to use a special kind of rule to allow - several independent rules for one target. -* Automatic Prerequisites:: How to automatically generate rules giving - prerequisites from source files themselves. -@end menu - -@ifinfo -@node Rule Example, Rule Syntax, , Rules -@section Rule Example - -Here is an example of a rule: - -@example -foo.o : foo.c defs.h # module for twiddling the frobs - cc -c -g foo.c -@end example - -Its target is @file{foo.o} and its prerequisites are @file{foo.c} and -@file{defs.h}. It has one command, which is @samp{cc -c -g foo.c}. -The command line starts with a tab to identify it as a command. - -This rule says two things: - -@itemize @bullet -@item -How to decide whether @file{foo.o} is out of date: it is out of date -if it does not exist, or if either @file{foo.c} or @file{defs.h} is -more recent than it. - -@item -How to update the file @file{foo.o}: by running @code{cc} as stated. -The command does not explicitly mention @file{defs.h}, but we presume -that @file{foo.c} includes it, and that that is why @file{defs.h} was -added to the prerequisites. -@end itemize -@end ifinfo - -@node Rule Syntax, Wildcards, Rule Example, Rules -@section Rule Syntax - -@cindex rule syntax -@cindex syntax of rules -In general, a rule looks like this: - -@example -@var{targets} : @var{prerequisites} - @var{command} - @dots{} -@end example - -@noindent -or like this: - -@example -@var{targets} : @var{prerequisites} ; @var{command} - @var{command} - @dots{} -@end example - -@cindex targets -@cindex rule targets -The @var{targets} are file names, separated by spaces. Wildcard -characters may be used (@pxref{Wildcards, ,Using Wildcard Characters -in File Names}) and a name of the form @file{@var{a}(@var{m})} -represents member @var{m} in archive file @var{a} -(@pxref{Archive Members, ,Archive Members as Targets}). -Usually there is only one -target per rule, but occasionally there is a reason to have more -(@pxref{Multiple Targets, , Multiple Targets in a Rule}).@refill - -@cindex commands -@cindex tab character (in commands) -The @var{command} lines start with a tab character. The first command may -appear on the line after the prerequisites, with a tab character, or may -appear on the same line, with a semicolon. Either way, the effect is the -same. @xref{Commands, ,Writing the Commands in Rules}. - -@cindex dollar sign (@code{$}), in rules -@cindex @code{$}, in rules -@cindex rule, and @code{$} -Because dollar signs are used to start variable references, if you really -want a dollar sign in a rule you must write two of them, @samp{$$} -(@pxref{Using Variables, ,How to Use Variables}). -You may split a long line by inserting a backslash -followed by a newline, but this is not required, as @code{make} places no -limit on the length of a line in a makefile. - -A rule tells @code{make} two things: when the targets are out of date, -and how to update them when necessary. - -@cindex prerequisites -@cindex rule prerequisites -The criterion for being out of date is specified in terms of the -@var{prerequisites}, which consist of file names separated by spaces. -(Wildcards and archive members (@pxref{Archives}) are allowed here too.) -A target is out of date if it does not exist or if it is older than any -of the prerequisites (by comparison of last-modification times). The -idea is that the contents of the target file are computed based on -information in the prerequisites, so if any of the prerequisites changes, -the contents of the existing target file are no longer necessarily -valid. - -How to update is specified by @var{commands}. These are lines to be -executed by the shell (normally @samp{sh}), but with some extra features -(@pxref{Commands, ,Writing the Commands in Rules}). - -@node Wildcards, Directory Search, Rule Syntax, Rules -@section Using Wildcard Characters in File Names -@cindex wildcard -@cindex file name with wildcards -@cindex globbing (wildcards) - -@cindex @code{*} (wildcard character) -@cindex @code{?} (wildcard character) -@cindex @code{[@dots{}]} (wildcard characters) -A single file name can specify many files using @dfn{wildcard characters}. -The wildcard characters in @code{make} are @samp{*}, @samp{?} and -@samp{[@dots{}]}, the same as in the Bourne shell. For example, @file{*.c} -specifies a list of all the files (in the working directory) whose names -end in @samp{.c}.@refill - -@cindex @code{~} (tilde) -@cindex tilde (@code{~}) -@cindex home directory -The character @samp{~} at the beginning of a file name also has special -significance. If alone, or followed by a slash, it represents your home -directory. For example @file{~/bin} expands to @file{/home/you/bin}. -If the @samp{~} is followed by a word, the string represents the home -directory of the user named by that word. For example @file{~john/bin} -expands to @file{/home/john/bin}. On systems which don't have a home -directory for each user (such as MS-DOS or MS-Windows), this -functionality can be simulated by setting the environment variable -@var{HOME}.@refill - -Wildcard expansion happens automatically in targets, in prerequisites, -and in commands (where the shell does the expansion). In other -contexts, wildcard expansion happens only if you request it explicitly -with the @code{wildcard} function. - -The special significance of a wildcard character can be turned off by -preceding it with a backslash. Thus, @file{foo\*bar} would refer to a -specific file whose name consists of @samp{foo}, an asterisk, and -@samp{bar}.@refill - -@menu -* Wildcard Examples:: Several examples -* Wildcard Pitfall:: Problems to avoid. -* Wildcard Function:: How to cause wildcard expansion where - it does not normally take place. -@end menu - -@node Wildcard Examples, Wildcard Pitfall, , Wildcards -@subsection Wildcard Examples - -Wildcards can be used in the commands of a rule, where they are expanded -by the shell. For example, here is a rule to delete all the object files: - -@example -@group -clean: - rm -f *.o -@end group -@end example -@cindex @code{rm} (shell command) - -Wildcards are also useful in the prerequisites of a rule. With the -following rule in the makefile, @samp{make print} will print all the -@samp{.c} files that have changed since the last time you printed them: - -@example -print: *.c - lpr -p $? - touch print -@end example - -@cindex @code{print} target -@cindex @code{lpr} (shell command) -@cindex @code{touch} (shell command) -@noindent -This rule uses @file{print} as an empty target file; see @ref{Empty -Targets, ,Empty Target Files to Record Events}. (The automatic variable -@samp{$?} is used to print only those files that have changed; see -@ref{Automatic, ,Automatic Variables}.)@refill - -Wildcard expansion does not happen when you define a variable. Thus, if -you write this: - -@example -objects = *.o -@end example - -@noindent -then the value of the variable @code{objects} is the actual string -@samp{*.o}. However, if you use the value of @code{objects} in a target, -prerequisite or command, wildcard expansion will take place at that time. -To set @code{objects} to the expansion, instead use: - -@example -objects := $(wildcard *.o) -@end example - -@noindent -@xref{Wildcard Function}. - -@node Wildcard Pitfall, Wildcard Function, Wildcard Examples, Wildcards -@subsection Pitfalls of Using Wildcards -@cindex wildcard pitfalls -@cindex pitfalls of wildcards -@cindex mistakes with wildcards -@cindex errors with wildcards -@cindex problems with wildcards - -Now here is an example of a naive way of using wildcard expansion, that -does not do what you would intend. Suppose you would like to say that the -executable file @file{foo} is made from all the object files in the -directory, and you write this: - -@example -objects = *.o - -foo : $(objects) - cc -o foo $(CFLAGS) $(objects) -@end example - -@noindent -The value of @code{objects} is the actual string @samp{*.o}. Wildcard -expansion happens in the rule for @file{foo}, so that each @emph{existing} -@samp{.o} file becomes a prerequisite of @file{foo} and will be recompiled if -necessary. - -But what if you delete all the @samp{.o} files? When a wildcard matches -no files, it is left as it is, so then @file{foo} will depend on the -oddly-named file @file{*.o}. Since no such file is likely to exist, -@code{make} will give you an error saying it cannot figure out how to -make @file{*.o}. This is not what you want! - -Actually it is possible to obtain the desired result with wildcard -expansion, but you need more sophisticated techniques, including the -@code{wildcard} function and string substitution. -@ifinfo -@xref{Wildcard Function, ,The Function @code{wildcard}}. -@end ifinfo -@iftex -These are described in the following section. -@end iftex - -@cindex wildcards and MS-DOS/MS-Windows backslashes -@cindex backslashes in pathnames and wildcard expansion - -Microsoft operating systems (MS-DOS and MS-Windows) use backslashes to -separate directories in pathnames, like so: - -@example - c:\foo\bar\baz.c -@end example - -This is equivalent to the Unix-style @file{c:/foo/bar/baz.c} (the -@file{c:} part is the so-called drive letter). When @code{make} runs on -these systems, it supports backslashes as well as the Unix-style forward -slashes in pathnames. However, this support does @emph{not} include the -wildcard expansion, where backslash is a quote character. Therefore, -you @emph{must} use Unix-style slashes in these cases. - - -@node Wildcard Function, , Wildcard Pitfall, Wildcards -@subsection The Function @code{wildcard} -@findex wildcard - -Wildcard expansion happens automatically in rules. But wildcard expansion -does not normally take place when a variable is set, or inside the -arguments of a function. If you want to do wildcard expansion in such -places, you need to use the @code{wildcard} function, like this: - -@example -$(wildcard @var{pattern}@dots{}) -@end example - -@noindent -This string, used anywhere in a makefile, is replaced by a -space-separated list of names of existing files that match one of the -given file name patterns. If no existing file name matches a pattern, -then that pattern is omitted from the output of the @code{wildcard} -function. Note that this is different from how unmatched wildcards -behave in rules, where they are used verbatim rather than ignored -(@pxref{Wildcard Pitfall}). - -One use of the @code{wildcard} function is to get a list of all the C source -files in a directory, like this: - -@example -$(wildcard *.c) -@end example - -We can change the list of C source files into a list of object files by -replacing the @samp{.c} suffix with @samp{.o} in the result, like this: - -@example -$(patsubst %.c,%.o,$(wildcard *.c)) -@end example - -@noindent -(Here we have used another function, @code{patsubst}. -@xref{Text Functions, ,Functions for String Substitution and Analysis}.)@refill - -Thus, a makefile to compile all C source files in the directory and then -link them together could be written as follows: - -@example -objects := $(patsubst %.c,%.o,$(wildcard *.c)) - -foo : $(objects) - cc -o foo $(objects) -@end example - -@noindent -(This takes advantage of the implicit rule for compiling C programs, so -there is no need to write explicit rules for compiling the files. -@xref{Flavors, ,The Two Flavors of Variables}, for an explanation of -@samp{:=}, which is a variant of @samp{=}.) - -@node Directory Search, Phony Targets, Wildcards, Rules -@section Searching Directories for Prerequisites -@vindex VPATH -@findex vpath -@cindex vpath -@cindex search path for prerequisites (@code{VPATH}) -@cindex directory search (@code{VPATH}) - -For large systems, it is often desirable to put sources in a separate -directory from the binaries. The @dfn{directory search} features of -@code{make} facilitate this by searching several directories -automatically to find a prerequisite. When you redistribute the files -among directories, you do not need to change the individual rules, -just the search paths. - -@menu -* General Search:: Specifying a search path that applies - to every prerequisite. -* Selective Search:: Specifying a search path - for a specified class of names. -* Search Algorithm:: When and how search paths are applied. -* Commands/Search:: How to write shell commands that work together - with search paths. -* Implicit/Search:: How search paths affect implicit rules. -* Libraries/Search:: Directory search for link libraries. -@end menu - -@node General Search, Selective Search, , Directory Search -@subsection @code{VPATH}: Search Path for All Prerequisites -@vindex VPATH - -The value of the @code{make} variable @code{VPATH} specifies a list of -directories that @code{make} should search. Most often, the -directories are expected to contain prerequisite files that are not in the -current directory; however, @code{VPATH} specifies a search list that -@code{make} applies for all files, including files which are targets of -rules. - -Thus, if a file that is listed as a target or prerequisite does not exist -in the current directory, @code{make} searches the directories listed in -@code{VPATH} for a file with that name. If a file is found in one of -them, that file may become the prerequisite (see below). Rules may then -specify the names of files in the prerequisite list as if they all -existed in the current directory. @xref{Commands/Search, ,Writing Shell -Commands with Directory Search}. - -In the @code{VPATH} variable, directory names are separated by colons or -blanks. The order in which directories are listed is the order followed -by @code{make} in its search. (On MS-DOS and MS-Windows, semi-colons -are used as separators of directory names in @code{VPATH}, since the -colon can be used in the pathname itself, after the drive letter.) - -For example, - -@example -VPATH = src:../headers -@end example - -@noindent -specifies a path containing two directories, @file{src} and -@file{../headers}, which @code{make} searches in that order. - -With this value of @code{VPATH}, the following rule, - -@example -foo.o : foo.c -@end example - -@noindent -is interpreted as if it were written like this: - -@example -foo.o : src/foo.c -@end example - -@noindent -assuming the file @file{foo.c} does not exist in the current directory but -is found in the directory @file{src}. - -@node Selective Search, Search Algorithm, General Search, Directory Search -@subsection The @code{vpath} Directive -@findex vpath - -Similar to the @code{VPATH} variable, but more selective, is the -@code{vpath} directive (note lower case), which allows you to specify a -search path for a particular class of file names: those that match a -particular pattern. Thus you can supply certain search directories for -one class of file names and other directories (or none) for other file -names. - -There are three forms of the @code{vpath} directive: - -@table @code -@item vpath @var{pattern} @var{directories} -Specify the search path @var{directories} for file names that match -@var{pattern}. - -The search path, @var{directories}, is a list of directories to be -searched, separated by colons (semi-colons on MS-DOS and MS-Windows) or -blanks, just like the search path used in the @code{VPATH} variable. - -@item vpath @var{pattern} -Clear out the search path associated with @var{pattern}. - -@c Extra blank line makes sure this gets two lines. -@item vpath - -Clear all search paths previously specified with @code{vpath} directives. -@end table - -A @code{vpath} pattern is a string containing a @samp{%} character. The -string must match the file name of a prerequisite that is being searched -for, the @samp{%} character matching any sequence of zero or more -characters (as in pattern rules; @pxref{Pattern Rules, ,Defining and -Redefining Pattern Rules}). For example, @code{%.h} matches files that -end in @code{.h}. (If there is no @samp{%}, the pattern must match the -prerequisite exactly, which is not useful very often.) - -@cindex @code{%}, quoting in @code{vpath} -@cindex @code{%}, quoting with @code{\} (backslash) -@cindex @code{\} (backslash), to quote @code{%} -@cindex backslash (@code{\}), to quote @code{%} -@cindex quoting @code{%}, in @code{vpath} -@samp{%} characters in a @code{vpath} directive's pattern can be quoted -with preceding backslashes (@samp{\}). Backslashes that would otherwise -quote @samp{%} characters can be quoted with more backslashes. -Backslashes that quote @samp{%} characters or other backslashes are -removed from the pattern before it is compared to file names. Backslashes -that are not in danger of quoting @samp{%} characters go unmolested.@refill - -When a prerequisite fails to exist in the current directory, if the -@var{pattern} in a @code{vpath} directive matches the name of the -prerequisite file, then the @var{directories} in that directive are searched -just like (and before) the directories in the @code{VPATH} variable. - -For example, - -@example -vpath %.h ../headers -@end example - -@noindent -tells @code{make} to look for any prerequisite whose name ends in @file{.h} -in the directory @file{../headers} if the file is not found in the current -directory. - -If several @code{vpath} patterns match the prerequisite file's name, then -@code{make} processes each matching @code{vpath} directive one by one, -searching all the directories mentioned in each directive. @code{make} -handles multiple @code{vpath} directives in the order in which they -appear in the makefile; multiple directives with the same pattern are -independent of each other. - -@need 750 -Thus, - -@example -@group -vpath %.c foo -vpath % blish -vpath %.c bar -@end group -@end example - -@noindent -will look for a file ending in @samp{.c} in @file{foo}, then -@file{blish}, then @file{bar}, while - -@example -@group -vpath %.c foo:bar -vpath % blish -@end group -@end example - -@noindent -will look for a file ending in @samp{.c} in @file{foo}, then -@file{bar}, then @file{blish}. - -@node Search Algorithm, Commands/Search, Selective Search, Directory Search -@subsection How Directory Searches are Performed -@cindex algorithm for directory search -@cindex directory search algorithm - -When a prerequisite is found through directory search, regardless of type -(general or selective), the pathname located may not be the one that -@code{make} actually provides you in the prerequisite list. Sometimes -the path discovered through directory search is thrown away. - -The algorithm @code{make} uses to decide whether to keep or abandon a -path found via directory search is as follows: - -@enumerate -@item -If a target file does not exist at the path specified in the makefile, -directory search is performed. - -@item -If the directory search is successful, that path is kept and this file -is tentatively stored as the target. - -@item -All prerequisites of this target are examined using this same method. - -@item -After processing the prerequisites, the target may or may not need to be -rebuilt: - -@enumerate a -@item -If the target does @emph{not} need to be rebuilt, the path to the file -found during directory search is used for any prerequisite lists which -contain this target. In short, if @code{make} doesn't need to rebuild -the target then you use the path found via directory search. - -@item -If the target @emph{does} need to be rebuilt (is out-of-date), the -pathname found during directory search is @emph{thrown away}, and the -target is rebuilt using the file name specified in the makefile. In -short, if @code{make} must rebuild, then the target is rebuilt locally, -not in the directory found via directory search. -@end enumerate -@end enumerate - -This algorithm may seem complex, but in practice it is quite often -exactly what you want. - -@cindex traditional directory search (GPATH) -@cindex directory search, traditional (GPATH) -Other versions of @code{make} use a simpler algorithm: if the file does -not exist, and it is found via directory search, then that pathname is -always used whether or not the target needs to be built. Thus, if the -target is rebuilt it is created at the pathname discovered during -directory search. - -@vindex GPATH -If, in fact, this is the behavior you want for some or all of your -directories, you can use the @code{GPATH} variable to indicate this to -@code{make}. - -@code{GPATH} has the same syntax and format as @code{VPATH} (that is, a -space- or colon-delimited list of pathnames). If an out-of-date target -is found by directory search in a directory that also appears in -@code{GPATH}, then that pathname is not thrown away. The target is -rebuilt using the expanded path. - -@node Commands/Search, Implicit/Search, Search Algorithm, Directory Search -@subsection Writing Shell Commands with Directory Search -@cindex shell command, and directory search -@cindex directory search (@code{VPATH}), and shell commands - -When a prerequisite is found in another directory through directory search, -this cannot change the commands of the rule; they will execute as written. -Therefore, you must write the commands with care so that they will look for -the prerequisite in the directory where @code{make} finds it. - -This is done with the @dfn{automatic variables} such as @samp{$^} -(@pxref{Automatic, ,Automatic Variables}). -For instance, the value of @samp{$^} is a -list of all the prerequisites of the rule, including the names of -the directories in which they were found, and the value of -@samp{$@@} is the target. Thus:@refill - -@example -foo.o : foo.c - cc -c $(CFLAGS) $^ -o $@@ -@end example - -@noindent -(The variable @code{CFLAGS} exists so you can specify flags for C -compilation by implicit rules; we use it here for consistency so it will -affect all C compilations uniformly; -@pxref{Implicit Variables, ,Variables Used by Implicit Rules}.) - -Often the prerequisites include header files as well, which you do not -want to mention in the commands. The automatic variable @samp{$<} is -just the first prerequisite: - -@example -VPATH = src:../headers -foo.o : foo.c defs.h hack.h - cc -c $(CFLAGS) $< -o $@@ -@end example - -@node Implicit/Search, Libraries/Search, Commands/Search, Directory Search -@subsection Directory Search and Implicit Rules -@cindex @code{VPATH}, and implicit rules -@cindex directory search (@code{VPATH}), and implicit rules -@cindex search path for prerequisites (@code{VPATH}), and implicit rules -@cindex implicit rule, and directory search -@cindex implicit rule, and @code{VPATH} -@cindex rule, implicit, and directory search -@cindex rule, implicit, and @code{VPATH} - -The search through the directories specified in @code{VPATH} or with -@code{vpath} also happens during consideration of implicit rules -(@pxref{Implicit Rules, ,Using Implicit Rules}). - -For example, when a file @file{foo.o} has no explicit rule, @code{make} -considers implicit rules, such as the built-in rule to compile -@file{foo.c} if that file exists. If such a file is lacking in the -current directory, the appropriate directories are searched for it. If -@file{foo.c} exists (or is mentioned in the makefile) in any of the -directories, the implicit rule for C compilation is applied. - -The commands of implicit rules normally use automatic variables as a -matter of necessity; consequently they will use the file names found by -directory search with no extra effort. - -@node Libraries/Search, , Implicit/Search, Directory Search -@subsection Directory Search for Link Libraries -@cindex link libraries, and directory search -@cindex libraries for linking, directory search -@cindex directory search (@code{VPATH}), and link libraries -@cindex @code{VPATH}, and link libraries -@cindex search path for prerequisites (@code{VPATH}), and link libraries -@cindex @code{-l} (library search) -@cindex link libraries, patterns matching -@cindex @code{.LIBPATTERNS}, and link libraries -@vindex .LIBPATTERNS - -Directory search applies in a special way to libraries used with the -linker. This special feature comes into play when you write a prerequisite -whose name is of the form @samp{-l@var{name}}. (You can tell something -strange is going on here because the prerequisite is normally the name of a -file, and the @emph{file name} of a library generally looks like -@file{lib@var{name}.a}, not like @samp{-l@var{name}}.)@refill - -When a prerequisite's name has the form @samp{-l@var{name}}, @code{make} -handles it specially by searching for the file @file{lib@var{name}.so} in -the current directory, in directories specified by matching @code{vpath} -search paths and the @code{VPATH} search path, and then in the -directories @file{/lib}, @file{/usr/lib}, and @file{@var{prefix}/lib} -(normally @file{/usr/local/lib}, but MS-DOS/MS-Windows versions of -@code{make} behave as if @var{prefix} is defined to be the root of the -DJGPP installation tree). - -If that file is not found, then the file @file{lib@var{name}.a} is -searched for, in the same directories as above. - -For example, if there is a @file{/usr/lib/libcurses.a} library on your -system (and no @file{/usr/lib/libcurses.so} file), then - -@example -@group -foo : foo.c -lcurses - cc $^ -o $@@ -@end group -@end example - -@noindent -would cause the command @samp{cc foo.c /usr/lib/libcurses.a -o foo} to -be executed when @file{foo} is older than @file{foo.c} or than -@file{/usr/lib/libcurses.a}.@refill - -Although the default set of files to be searched for is -@file{lib@var{name}.so} and @file{lib@var{name}.a}, this is customizable -via the @code{.LIBPATTERNS} variable. Each word in the value of this -variable is a pattern string. When a prerequisite like -@samp{-l@var{name}} is seen, @code{make} will replace the percent in -each pattern in the list with @var{name} and perform the above directory -searches using that library filename. If no library is found, the next -word in the list will be used. - -The default value for @code{.LIBPATTERNS} is ``@samp{lib%.so lib%.a}'', -which provides the default behavior described above. - -You can turn off link library expansion completely by setting this -variable to an empty value. - -@node Phony Targets, Force Targets, Directory Search, Rules -@section Phony Targets -@cindex phony targets -@cindex targets, phony -@cindex targets without a file - -A phony target is one that is not really the name of a file. It is just a -name for some commands to be executed when you make an explicit request. -There are two reasons to use a phony target: to avoid a conflict with -a file of the same name, and to improve performance. - -If you write a rule whose commands will not create the target file, the -commands will be executed every time the target comes up for remaking. -Here is an example: - -@example -@group -clean: - rm *.o temp -@end group -@end example - -@noindent -Because the @code{rm} command does not create a file named @file{clean}, -probably no such file will ever exist. Therefore, the @code{rm} command -will be executed every time you say @samp{make clean}. -@cindex @code{rm} (shell command) - -@findex .PHONY -The phony target will cease to work if anything ever does create a file -named @file{clean} in this directory. Since it has no prerequisites, the -file @file{clean} would inevitably be considered up to date, and its -commands would not be executed. To avoid this problem, you can explicitly -declare the target to be phony, using the special target @code{.PHONY} -(@pxref{Special Targets, ,Special Built-in Target Names}) as follows: - -@example -.PHONY : clean -@end example - -@noindent -Once this is done, @samp{make clean} will run the commands regardless of -whether there is a file named @file{clean}. - -Since it knows that phony targets do not name actual files that could be -remade from other files, @code{make} skips the implicit rule search for -phony targets (@pxref{Implicit Rules}). This is why declaring a target -phony is good for performance, even if you are not worried about the -actual file existing. - -Thus, you first write the line that states that @code{clean} is a -phony target, then you write the rule, like this: - -@example -@group -.PHONY: clean -clean: - rm *.o temp -@end group -@end example - -Another example of the usefulness of phony targets is in conjunction -with recursive invocations of @code{make}. In this case the makefile -will often contain a variable which lists a number of subdirectories to -be built. One way to handle this is with one rule whose command is a -shell loop over the subdirectories, like this: - -@example -@group -SUBDIRS = foo bar baz - -subdirs: - for dir in $(SUBDIRS); do \ - $(MAKE) -C $$dir; \ - done -@end group -@end example - -There are a few problems with this method, however. First, any error -detected in a submake is not noted by this rule, so it will continue to -build the rest of the directories even when one fails. This can be -overcome by adding shell commands to note the error and exit, but then -it will do so even if @code{make} is invoked with the @code{-k} option, -which is unfortunate. Second, and perhaps more importantly, you cannot -take advantage of the parallel build capabilities of make using this -method, since there is only one rule. - -By declaring the subdirectories as phony targets (you must do this as -the subdirectory obviously always exists; otherwise it won't be built) -you can remove these problems: - -@example -@group -SUBDIRS = foo bar baz - -.PHONY: subdirs $(SUBDIRS) - -subdirs: $(SUBDIRS) - -$(SUBDIRS): - $(MAKE) -C $@@ - -foo: baz -@end group -@end example - -Here we've also declared that the @file{foo} subdirectory cannot be -built until after the @file{baz} subdirectory is complete; this kind of -relationship declaration is particularly important when attempting -parallel builds. - -A phony target should not be a prerequisite of a real target file; if it -is, its commands are run every time @code{make} goes to update that -file. As long as a phony target is never a prerequisite of a real -target, the phony target commands will be executed only when the phony -target is a specified goal (@pxref{Goals, ,Arguments to Specify the -Goals}). - -Phony targets can have prerequisites. When one directory contains multiple -programs, it is most convenient to describe all of the programs in one -makefile @file{./Makefile}. Since the target remade by default will be the -first one in the makefile, it is common to make this a phony target named -@samp{all} and give it, as prerequisites, all the individual programs. For -example: - -@example -all : prog1 prog2 prog3 -.PHONY : all - -prog1 : prog1.o utils.o - cc -o prog1 prog1.o utils.o - -prog2 : prog2.o - cc -o prog2 prog2.o - -prog3 : prog3.o sort.o utils.o - cc -o prog3 prog3.o sort.o utils.o -@end example - -@noindent -Now you can say just @samp{make} to remake all three programs, or specify -as arguments the ones to remake (as in @samp{make prog1 prog3}). - -When one phony target is a prerequisite of another, it serves as a subroutine -of the other. For example, here @samp{make cleanall} will delete the -object files, the difference files, and the file @file{program}: - -@example -.PHONY: cleanall cleanobj cleandiff - -cleanall : cleanobj cleandiff - rm program - -cleanobj : - rm *.o - -cleandiff : - rm *.diff -@end example - -@node Force Targets, Empty Targets, Phony Targets, Rules -@section Rules without Commands or Prerequisites -@cindex force targets -@cindex targets, force -@cindex @code{FORCE} -@cindex rule, no commands or prerequisites - -If a rule has no prerequisites or commands, and the target of the rule -is a nonexistent file, then @code{make} imagines this target to have -been updated whenever its rule is run. This implies that all targets -depending on this one will always have their commands run. - -An example will illustrate this: - -@example -@group -clean: FORCE - rm $(objects) -FORCE: -@end group -@end example - -Here the target @samp{FORCE} satisfies the special conditions, so the -target @file{clean} that depends on it is forced to run its commands. -There is nothing special about the name @samp{FORCE}, but that is one name -commonly used this way. - -As you can see, using @samp{FORCE} this way has the same results as using -@samp{.PHONY: clean}. - -Using @samp{.PHONY} is more explicit and more efficient. However, -other versions of @code{make} do not support @samp{.PHONY}; thus -@samp{FORCE} appears in many makefiles. @xref{Phony Targets}. - -@node Empty Targets, Special Targets, Force Targets, Rules -@section Empty Target Files to Record Events -@cindex empty targets -@cindex targets, empty -@cindex recording events with empty targets - -The @dfn{empty target} is a variant of the phony target; it is used to hold -commands for an action that you request explicitly from time to time. -Unlike a phony target, this target file can really exist; but the file's -contents do not matter, and usually are empty. - -The purpose of the empty target file is to record, with its -last-modification time, when the rule's commands were last executed. It -does so because one of the commands is a @code{touch} command to update the -target file. - -The empty target file should have some prerequisites (otherwise it -doesn't make sense). When you ask to remake the empty target, the -commands are executed if any prerequisite is more recent than the target; -in other words, if a prerequisite has changed since the last time you -remade the target. Here is an example: - -@example -print: foo.c bar.c - lpr -p $? - touch print -@end example -@cindex @code{print} target -@cindex @code{lpr} (shell command) -@cindex @code{touch} (shell command) - -@noindent -With this rule, @samp{make print} will execute the @code{lpr} command if -either source file has changed since the last @samp{make print}. The -automatic variable @samp{$?} is used to print only those files that have -changed (@pxref{Automatic, ,Automatic Variables}). - -@node Special Targets, Multiple Targets, Empty Targets, Rules -@section Special Built-in Target Names -@cindex special targets -@cindex built-in special targets -@cindex targets, built-in special - -Certain names have special meanings if they appear as targets. - -@table @code -@findex .PHONY -@item .PHONY - -The prerequisites of the special target @code{.PHONY} are considered to -be phony targets. When it is time to consider such a target, -@code{make} will run its commands unconditionally, regardless of -whether a file with that name exists or what its last-modification -time is. @xref{Phony Targets, ,Phony Targets}. - -@findex .SUFFIXES -@item .SUFFIXES - -The prerequisites of the special target @code{.SUFFIXES} are the list -of suffixes to be used in checking for suffix rules. -@xref{Suffix Rules, , Old-Fashioned Suffix Rules}. - -@findex .DEFAULT -@item .DEFAULT - -The commands specified for @code{.DEFAULT} are used for any target for -which no rules are found (either explicit rules or implicit rules). -@xref{Last Resort}. If @code{.DEFAULT} commands are specified, every -file mentioned as a prerequisite, but not as a target in a rule, will have -these commands executed on its behalf. @xref{Implicit Rule Search, -,Implicit Rule Search Algorithm}. - -@findex .PRECIOUS -@item .PRECIOUS -@cindex precious targets -@cindex preserving with @code{.PRECIOUS} - -The targets which @code{.PRECIOUS} depends on are given the following -special treatment: if @code{make} is killed or interrupted during the -execution of their commands, the target is not deleted. -@xref{Interrupts, ,Interrupting or Killing @code{make}}. Also, if the -target is an intermediate file, it will not be deleted after it is no -longer needed, as is normally done. @xref{Chained Rules, ,Chains of -Implicit Rules}. In this latter respect it overlaps with the -@code{.SECONDARY} special target. - -You can also list the target pattern of an implicit rule (such as -@samp{%.o}) as a prerequisite file of the special target @code{.PRECIOUS} -to preserve intermediate files created by rules whose target patterns -match that file's name. - -@findex .INTERMEDIATE -@item .INTERMEDIATE -@cindex intermediate targets, explicit - -The targets which @code{.INTERMEDIATE} depends on are treated as -intermediate files. @xref{Chained Rules, ,Chains of Implicit Rules}. -@code{.INTERMEDIATE} with no prerequisites has no effect. - -@findex .SECONDARY -@item .SECONDARY -@cindex secondary targets -@cindex preserving with @code{.SECONDARY} - -The targets which @code{.SECONDARY} depends on are treated as -intermediate files, except that they are never automatically deleted. -@xref{Chained Rules, ,Chains of Implicit Rules}. - -@code{.SECONDARY} with no prerequisites causes all targets to be treated -as secondary (i.e., no target is removed because it is considered -intermediate). - -@findex .DELETE_ON_ERROR -@item .DELETE_ON_ERROR -@cindex removing targets on failure - -If @code{.DELETE_ON_ERROR} is mentioned as a target anywhere in the -makefile, then @code{make} will delete the target of a rule if it has -changed and its commands exit with a nonzero exit status, just as it -does when it receives a signal. @xref{Errors, ,Errors in Commands}. - -@findex .IGNORE -@item .IGNORE - -If you specify prerequisites for @code{.IGNORE}, then @code{make} will -ignore errors in execution of the commands run for those particular -files. The commands for @code{.IGNORE} are not meaningful. - -If mentioned as a target with no prerequisites, @code{.IGNORE} says to -ignore errors in execution of commands for all files. This usage of -@samp{.IGNORE} is supported only for historical compatibility. Since -this affects every command in the makefile, it is not very useful; we -recommend you use the more selective ways to ignore errors in specific -commands. @xref{Errors, ,Errors in Commands}. - -@findex .LOW_RESOLUTION_TIME -@item .LOW_RESOLUTION_TIME - -If you specify prerequisites for @code{.LOW_RESOLUTION_TIME}, -@command{make} assumes that these files are created by commands that -generate low resolution time stamps. The commands for -@code{.LOW_RESOLUTION_TIME} are not meaningful. - -The high resolution file time stamps of many modern hosts lessen the -chance of @command{make} incorrectly concluding that a file is up to -date. Unfortunately, these hosts provide no way to set a high -resolution file time stamp, so commands like @samp{cp -p} that -explicitly set a file's time stamp must discard its subsecond part. If -a file is created by such a command, you should list it as a -prerequisite of @code{.LOW_RESOLUTION_TIME} so that @command{make} does -not mistakenly conclude that the file is out of date. For example: - -@example -@group -.LOW_RESOLUTION_TIME: dst -dst: src - cp -p src dst -@end group -@end example - -Since @samp{cp -p} discards the subsecond part of @file{src}'s time -stamp, @file{dst} is typically slightly older than @file{src} even when -it is up to date. The @code{.LOW_RESOLUTION_TIME} line causes -@command{make} to consider @file{dst} to be up to date if its time stamp -is at the start of the same second that @file{src}'s time stamp is in. - -Due to a limitation of the archive format, archive member time stamps -are always low resolution. You need not list archive members as -prerequisites of @code{.LOW_RESOLUTION_TIME}, as @command{make} does this -automatically. - -@findex .SILENT -@item .SILENT - -If you specify prerequisites for @code{.SILENT}, then @code{make} will -not print the commands to remake those particular files before executing -them. The commands for @code{.SILENT} are not meaningful. - -If mentioned as a target with no prerequisites, @code{.SILENT} says not -to print any commands before executing them. This usage of -@samp{.SILENT} is supported only for historical compatibility. We -recommend you use the more selective ways to silence specific commands. -@xref{Echoing, ,Command Echoing}. If you want to silence all commands -for a particular run of @code{make}, use the @samp{-s} or -@w{@samp{--silent}} option (@pxref{Options Summary}). - -@findex .EXPORT_ALL_VARIABLES -@item .EXPORT_ALL_VARIABLES - -Simply by being mentioned as a target, this tells @code{make} to -export all variables to child processes by default. -@xref{Variables/Recursion, ,Communicating Variables to a -Sub-@code{make}}. - -@findex .NOTPARALLEL -@item .NOTPARALLEL -@cindex parallel execution, overriding - -If @code{.NOTPARALLEL} is mentioned as a target, then this invocation of -@code{make} will be run serially, even if the @samp{-j} option is -given. Any recursively invoked @code{make} command will still be run in -parallel (unless its makefile contains this target). Any prerequisites -on this target are ignored. -@end table - -Any defined implicit rule suffix also counts as a special target if it -appears as a target, and so does the concatenation of two suffixes, such -as @samp{.c.o}. These targets are suffix rules, an obsolete way of -defining implicit rules (but a way still widely used). In principle, any -target name could be special in this way if you break it in two and add -both pieces to the suffix list. In practice, suffixes normally begin with -@samp{.}, so these special target names also begin with @samp{.}. -@xref{Suffix Rules, ,Old-Fashioned Suffix Rules}. - -@node Multiple Targets, Multiple Rules, Special Targets, Rules -@section Multiple Targets in a Rule -@cindex multiple targets -@cindex several targets in a rule -@cindex targets, multiple -@cindex rule, with multiple targets - -A rule with multiple targets is equivalent to writing many rules, each with -one target, and all identical aside from that. The same commands apply to -all the targets, but their effects may vary because you can substitute the -actual target name into the command using @samp{$@@}. The rule contributes -the same prerequisites to all the targets also. - -This is useful in two cases. - -@itemize @bullet -@item -You want just prerequisites, no commands. For example: - -@example -kbd.o command.o files.o: command.h -@end example - -@noindent -gives an additional prerequisite to each of the three object files -mentioned. - -@item -Similar commands work for all the targets. The commands do not need -to be absolutely identical, since the automatic variable @samp{$@@} -can be used to substitute the particular target to be remade into the -commands (@pxref{Automatic, ,Automatic Variables}). For example: - -@example -@group -bigoutput littleoutput : text.g - generate text.g -$(subst output,,$@@) > $@@ -@end group -@end example -@findex subst - -@noindent -is equivalent to - -@example -bigoutput : text.g - generate text.g -big > bigoutput -littleoutput : text.g - generate text.g -little > littleoutput -@end example - -@noindent -Here we assume the hypothetical program @code{generate} makes two -types of output, one if given @samp{-big} and one if given -@samp{-little}. -@xref{Text Functions, ,Functions for String Substitution and Analysis}, -for an explanation of the @code{subst} function. -@end itemize - -Suppose you would like to vary the prerequisites according to the target, -much as the variable @samp{$@@} allows you to vary the commands. -You cannot do this with multiple targets in an ordinary rule, but you can -do it with a @dfn{static pattern rule}. -@xref{Static Pattern, ,Static Pattern Rules}. - -@node Multiple Rules, Static Pattern, Multiple Targets, Rules -@section Multiple Rules for One Target -@cindex multiple rules for one target -@cindex several rules for one target -@cindex rule, multiple for one target -@cindex target, multiple rules for one - -One file can be the target of several rules. All the prerequisites -mentioned in all the rules are merged into one list of prerequisites for -the target. If the target is older than any prerequisite from any rule, -the commands are executed. - -There can only be one set of commands to be executed for a file. -If more than one rule gives commands for the same file, -@code{make} uses the last set given and prints an error message. -(As a special case, if the file's name begins with a dot, no -error message is printed. This odd behavior is only for -compatibility with other implementations of @code{make}.) -There is no reason to -write your makefiles this way; that is why @code{make} gives you -an error message.@refill - -An extra rule with just prerequisites can be used to give a few extra -prerequisites to many files at once. For example, one usually has a -variable named @code{objects} containing a list of all the compiler output -files in the system being made. An easy way to say that all of them must -be recompiled if @file{config.h} changes is to write the following: - -@example -objects = foo.o bar.o -foo.o : defs.h -bar.o : defs.h test.h -$(objects) : config.h -@end example - -This could be inserted or taken out without changing the rules that really -specify how to make the object files, making it a convenient form to use if -you wish to add the additional prerequisite intermittently. - -Another wrinkle is that the additional prerequisites could be specified with -a variable that you set with a command argument to @code{make} -(@pxref{Overriding, ,Overriding Variables}). For example, - -@example -@group -extradeps= -$(objects) : $(extradeps) -@end group -@end example - -@noindent -means that the command @samp{make extradeps=foo.h} will consider -@file{foo.h} as a prerequisite of each object file, but plain @samp{make} -will not. - -If none of the explicit rules for a target has commands, then @code{make} -searches for an applicable implicit rule to find some commands -@pxref{Implicit Rules, ,Using Implicit Rules}). - -@node Static Pattern, Double-Colon, Multiple Rules, Rules -@section Static Pattern Rules -@cindex static pattern rule -@cindex rule, static pattern -@cindex pattern rules, static (not implicit) -@cindex varying prerequisites -@cindex prerequisites, varying (static pattern) - -@dfn{Static pattern rules} are rules which specify multiple targets and -construct the prerequisite names for each target based on the target name. -They are more general than ordinary rules with multiple targets because the -targets do not have to have identical prerequisites. Their prerequisites must -be @emph{analogous}, but not necessarily @emph{identical}. - -@menu -* Static Usage:: The syntax of static pattern rules. -* Static versus Implicit:: When are they better than implicit rules? -@end menu - -@node Static Usage, Static versus Implicit, , Static Pattern -@subsection Syntax of Static Pattern Rules -@cindex static pattern rule, syntax of -@cindex pattern rules, static, syntax of - -Here is the syntax of a static pattern rule: - -@example -@var{targets} @dots{}: @var{target-pattern}: @var{prereq-patterns} @dots{} - @var{commands} - @dots{} -@end example - -@noindent -The @var{targets} list specifies the targets that the rule applies to. -The targets can contain wildcard characters, just like the targets of -ordinary rules (@pxref{Wildcards, ,Using Wildcard Characters in File -Names}). - -@cindex target pattern, static (not implicit) -@cindex stem -The @var{target-pattern} and @var{prereq-patterns} say how to compute the -prerequisites of each target. Each target is matched against the -@var{target-pattern} to extract a part of the target name, called the -@dfn{stem}. This stem is substituted into each of the @var{prereq-patterns} -to make the prerequisite names (one from each @var{prereq-pattern}). - -Each pattern normally contains the character @samp{%} just once. When the -@var{target-pattern} matches a target, the @samp{%} can match any part of -the target name; this part is called the @dfn{stem}. The rest of the -pattern must match exactly. For example, the target @file{foo.o} matches -the pattern @samp{%.o}, with @samp{foo} as the stem. The targets -@file{foo.c} and @file{foo.out} do not match that pattern.@refill - -@cindex prerequisite pattern, static (not implicit) -The prerequisite names for each target are made by substituting the stem -for the @samp{%} in each prerequisite pattern. For example, if one -prerequisite pattern is @file{%.c}, then substitution of the stem -@samp{foo} gives the prerequisite name @file{foo.c}. It is legitimate -to write a prerequisite pattern that does not contain @samp{%}; then this -prerequisite is the same for all targets. - -@cindex @code{%}, quoting in static pattern -@cindex @code{%}, quoting with @code{\} (backslash) -@cindex @code{\} (backslash), to quote @code{%} -@cindex backslash (@code{\}), to quote @code{%} -@cindex quoting @code{%}, in static pattern -@samp{%} characters in pattern rules can be quoted with preceding -backslashes (@samp{\}). Backslashes that would otherwise quote @samp{%} -characters can be quoted with more backslashes. Backslashes that quote -@samp{%} characters or other backslashes are removed from the pattern -before it is compared to file names or has a stem substituted into it. -Backslashes that are not in danger of quoting @samp{%} characters go -unmolested. For example, the pattern @file{the\%weird\\%pattern\\} has -@samp{the%weird\} preceding the operative @samp{%} character, and -@samp{pattern\\} following it. The final two backslashes are left alone -because they cannot affect any @samp{%} character.@refill - -Here is an example, which compiles each of @file{foo.o} and @file{bar.o} -from the corresponding @file{.c} file: - -@example -@group -objects = foo.o bar.o - -all: $(objects) - -$(objects): %.o: %.c - $(CC) -c $(CFLAGS) $< -o $@@ -@end group -@end example - -@noindent -Here @samp{$<} is the automatic variable that holds the name of the -prerequisite and @samp{$@@} is the automatic variable that holds the name -of the target; see @ref{Automatic, , Automatic Variables}. - -Each target specified must match the target pattern; a warning is issued -for each target that does not. If you have a list of files, only some of -which will match the pattern, you can use the @code{filter} function to -remove nonmatching file names (@pxref{Text Functions, ,Functions for String Substitution and Analysis}): - -@example -files = foo.elc bar.o lose.o - -$(filter %.o,$(files)): %.o: %.c - $(CC) -c $(CFLAGS) $< -o $@@ -$(filter %.elc,$(files)): %.elc: %.el - emacs -f batch-byte-compile $< -@end example - -@noindent -In this example the result of @samp{$(filter %.o,$(files))} is -@file{bar.o lose.o}, and the first static pattern rule causes each of -these object files to be updated by compiling the corresponding C source -file. The result of @w{@samp{$(filter %.elc,$(files))}} is -@file{foo.elc}, so that file is made from @file{foo.el}.@refill - -Another example shows how to use @code{$*} in static pattern rules: -@vindex $*@r{, and static pattern} - -@example -@group -bigoutput littleoutput : %output : text.g - generate text.g -$* > $@@ -@end group -@end example - -@noindent -When the @code{generate} command is run, @code{$*} will expand to the -stem, either @samp{big} or @samp{little}. - -@node Static versus Implicit, , Static Usage, Static Pattern -@subsection Static Pattern Rules versus Implicit Rules -@cindex rule, static pattern versus implicit -@cindex static pattern rule, versus implicit - -A static pattern rule has much in common with an implicit rule defined as a -pattern rule (@pxref{Pattern Rules, ,Defining and Redefining Pattern Rules}). -Both have a pattern for the target and patterns for constructing the -names of prerequisites. The difference is in how @code{make} decides -@emph{when} the rule applies. - -An implicit rule @emph{can} apply to any target that matches its pattern, -but it @emph{does} apply only when the target has no commands otherwise -specified, and only when the prerequisites can be found. If more than one -implicit rule appears applicable, only one applies; the choice depends on -the order of rules. - -By contrast, a static pattern rule applies to the precise list of targets -that you specify in the rule. It cannot apply to any other target and it -invariably does apply to each of the targets specified. If two conflicting -rules apply, and both have commands, that's an error. - -The static pattern rule can be better than an implicit rule for these -reasons: - -@itemize @bullet -@item -You may wish to override the usual implicit rule for a few -files whose names cannot be categorized syntactically but -can be given in an explicit list. - -@item -If you cannot be sure of the precise contents of the directories -you are using, you may not be sure which other irrelevant files -might lead @code{make} to use the wrong implicit rule. The choice -might depend on the order in which the implicit rule search is done. -With static pattern rules, there is no uncertainty: each rule applies -to precisely the targets specified. -@end itemize - -@node Double-Colon, Automatic Prerequisites, Static Pattern, Rules -@section Double-Colon Rules -@cindex double-colon rules -@cindex rule, double-colon (@code{::}) -@cindex multiple rules for one target (@code{::}) -@cindex @code{::} rules (double-colon) - -@dfn{Double-colon} rules are rules written with @samp{::} instead of -@samp{:} after the target names. They are handled differently from -ordinary rules when the same target appears in more than one rule. - -When a target appears in multiple rules, all the rules must be the same -type: all ordinary, or all double-colon. If they are double-colon, each -of them is independent of the others. Each double-colon rule's commands -are executed if the target is older than any prerequisites of that rule. -If there are no prerequisites for that rule, its commands are always -executed (even if the target already exists). This can result in -executing none, any, or all of the double-colon rules. - -Double-colon rules with the same target are in fact completely separate -from one another. Each double-colon rule is processed individually, just -as rules with different targets are processed. - -The double-colon rules for a target are executed in the order they appear -in the makefile. However, the cases where double-colon rules really make -sense are those where the order of executing the commands would not matter. - -Double-colon rules are somewhat obscure and not often very useful; they -provide a mechanism for cases in which the method used to update a target -differs depending on which prerequisite files caused the update, and such -cases are rare. - -Each double-colon rule should specify commands; if it does not, an -implicit rule will be used if one applies. -@xref{Implicit Rules, ,Using Implicit Rules}. - -@node Automatic Prerequisites, , Double-Colon, Rules -@section Generating Prerequisites Automatically -@cindex prerequisites, automatic generation -@cindex automatic generation of prerequisites -@cindex generating prerequisites automatically - -In the makefile for a program, many of the rules you need to write often -say only that some object file depends on some header -file. For example, if @file{main.c} uses @file{defs.h} via an -@code{#include}, you would write: - -@example -main.o: defs.h -@end example - -@noindent -You need this rule so that @code{make} knows that it must remake -@file{main.o} whenever @file{defs.h} changes. You can see that for a -large program you would have to write dozens of such rules in your -makefile. And, you must always be very careful to update the makefile -every time you add or remove an @code{#include}. -@cindex @code{#include} - -@cindex @code{-M} (to compiler) -To avoid this hassle, most modern C compilers can write these rules for -you, by looking at the @code{#include} lines in the source files. -Usually this is done with the @samp{-M} option to the compiler. -For example, the command: - -@example -cc -M main.c -@end example - -@noindent -generates the output: - -@example -main.o : main.c defs.h -@end example - -@noindent -Thus you no longer have to write all those rules yourself. -The compiler will do it for you. - -Note that such a prerequisite constitutes mentioning @file{main.o} in a -makefile, so it can never be considered an intermediate file by implicit -rule search. This means that @code{make} won't ever remove the file -after using it; @pxref{Chained Rules, ,Chains of Implicit Rules}. - -@cindex @code{make depend} -With old @code{make} programs, it was traditional practice to use this -compiler feature to generate prerequisites on demand with a command like -@samp{make depend}. That command would create a file @file{depend} -containing all the automatically-generated prerequisites; then the -makefile could use @code{include} to read them in (@pxref{Include}). - -In GNU @code{make}, the feature of remaking makefiles makes this -practice obsolete---you need never tell @code{make} explicitly to -regenerate the prerequisites, because it always regenerates any makefile -that is out of date. @xref{Remaking Makefiles}. - -The practice we recommend for automatic prerequisite generation is to have -one makefile corresponding to each source file. For each source file -@file{@var{name}.c} there is a makefile @file{@var{name}.d} which lists -what files the object file @file{@var{name}.o} depends on. That way -only the source files that have changed need to be rescanned to produce -the new prerequisites. - -Here is the pattern rule to generate a file of prerequisites (i.e., a makefile) -called @file{@var{name}.d} from a C source file called @file{@var{name}.c}: - -@smallexample -@group -%.d: %.c - set -e; $(CC) -M $(CPPFLAGS) $< \ - | sed 's/\($*\)\.o[ :]*/\1.o $@@ : /g' > $@@; \ - [ -s $@@ ] || rm -f $@@ -@end group -@end smallexample - -@noindent -@xref{Pattern Rules}, for information on defining pattern rules. The -@samp{-e} flag to the shell makes it exit immediately if the -@code{$(CC)} command fails (exits with a nonzero status). Normally the -shell exits with the status of the last command in the pipeline -(@code{sed} in this case), so @code{make} would not notice a nonzero -status from the compiler. -@cindex @code{-e} (shell flag) - -@cindex @code{-MM} (to GNU compiler) -With the GNU C compiler, you may wish to use the @samp{-MM} flag instead -of @samp{-M}. This omits prerequisites on system header files. -@xref{Preprocessor Options, , Options Controlling the Preprocessor, -gcc.info, Using GNU CC}, for details. - -@cindex @code{sed} (shell command) -The purpose of the @code{sed} command is to translate (for example): - -@example -main.o : main.c defs.h -@end example - -@noindent -into: - -@example -main.o main.d : main.c defs.h -@end example - -@noindent -@cindex @code{.d} -This makes each @samp{.d} file depend on all the source and header files -that the corresponding @samp{.o} file depends on. @code{make} then -knows it must regenerate the prerequisites whenever any of the source or -header files changes. - -Once you've defined the rule to remake the @samp{.d} files, -you then use the @code{include} directive to read them all in. -@xref{Include}. For example: - -@example -@group -sources = foo.c bar.c - -include $(sources:.c=.d) -@end group -@end example - -@noindent -(This example uses a substitution variable reference to translate the -list of source files @samp{foo.c bar.c} into a list of prerequisite -makefiles, @samp{foo.d bar.d}. @xref{Substitution Refs}, for full -information on substitution references.) Since the @samp{.d} files are -makefiles like any others, @code{make} will remake them as necessary -with no further work from you. @xref{Remaking Makefiles}. - -@node Commands, Using Variables, Rules, Top -@chapter Writing the Commands in Rules -@cindex commands, how to write -@cindex rule commands -@cindex writing rule commands - -The commands of a rule consist of shell command lines to be executed one -by one. Each command line must start with a tab, except that the first -command line may be attached to the target-and-prerequisites line with a -semicolon in between. Blank lines and lines of just comments may appear -among the command lines; they are ignored. (But beware, an apparently -``blank'' line that begins with a tab is @emph{not} blank! It is an -empty command; @pxref{Empty Commands}.) - -Users use many different shell programs, but commands in makefiles are -always interpreted by @file{/bin/sh} unless the makefile specifies -otherwise. @xref{Execution, ,Command Execution}. - -@cindex comments, in commands -@cindex commands, comments in -@cindex @code{#} (comments), in commands -The shell that is in use determines whether comments can be written on -command lines, and what syntax they use. When the shell is -@file{/bin/sh}, a @samp{#} starts a comment that extends to the end of -the line. The @samp{#} does not have to be at the beginning of a line. -Text on a line before a @samp{#} is not part of the comment. - -@menu -* Echoing:: How to control when commands are echoed. -* Execution:: How commands are executed. -* Parallel:: How commands can be executed in parallel. -* Errors:: What happens after a command execution error. -* Interrupts:: What happens when a command is interrupted. -* Recursion:: Invoking @code{make} from makefiles. -* Sequences:: Defining canned sequences of commands. -* Empty Commands:: Defining useful, do-nothing commands. -@end menu - -@node Echoing, Execution, , Commands -@section Command Echoing -@cindex echoing of commands -@cindex silent operation -@cindex @code{@@} (in commands) -@cindex commands, echoing -@cindex printing of commands - -Normally @code{make} prints each command line before it is executed. -We call this @dfn{echoing} because it gives the appearance that you -are typing the commands yourself. - -When a line starts with @samp{@@}, the echoing of that line is suppressed. -The @samp{@@} is discarded before the command is passed to the shell. -Typically you would use this for a command whose only effect is to print -something, such as an @code{echo} command to indicate progress through -the makefile: - -@example -@@echo About to make distribution files -@end example - -@cindex @code{-n} -@cindex @code{--just-print} -@cindex @code{--dry-run} -@cindex @code{--recon} -When @code{make} is given the flag @samp{-n} or @samp{--just-print} -it only echoes commands, it won't execute them. @xref{Options Summary, -,Summary of Options}. In this case and only this case, even the -commands starting with @samp{@@} are printed. This flag is useful for -finding out which commands @code{make} thinks are necessary without -actually doing them. - -@cindex @code{-s} -@cindex @code{--silent} -@cindex @code{--quiet} -@findex .SILENT -The @samp{-s} or @samp{--silent} -flag to @code{make} prevents all echoing, as if all commands -started with @samp{@@}. A rule in the makefile for the special target -@code{.SILENT} without prerequisites has the same effect -(@pxref{Special Targets, ,Special Built-in Target Names}). -@code{.SILENT} is essentially obsolete since @samp{@@} is more flexible.@refill - -@node Execution, Parallel, Echoing, Commands -@section Command Execution -@cindex commands, execution -@cindex execution, of commands -@cindex shell command, execution -@vindex SHELL @r{(command execution)} - -When it is time to execute commands to update a target, they are executed -by making a new subshell for each line. (In practice, @code{make} may -take shortcuts that do not affect the results.) - -@cindex @code{cd} (shell command) -@strong{Please note:} this implies that shell commands such as @code{cd} -that set variables local to each process will not affect the following -command lines. @footnote{On MS-DOS, the value of current working -directory is @strong{global}, so changing it @emph{will} affect the -following command lines on those systems.} If you want to use @code{cd} -to affect the next command, put the two on a single line with a -semicolon between them. Then @code{make} will consider them a single -command and pass them, together, to a shell which will execute them in -sequence. For example: - -@example -foo : bar/lose - cd bar; gobble lose > ../foo -@end example - -@cindex commands, backslash (@code{\}) in -@cindex commands, quoting newlines in -@cindex backslash (@code{\}), in commands -@cindex @code{\} (backslash), in commands -@cindex quoting newline, in commands -@cindex newline, quoting, in commands -If you would like to split a single shell command into multiple lines of -text, you must use a backslash at the end of all but the last subline. -Such a sequence of lines is combined into a single line, by deleting the -backslash-newline sequences, before passing it to the shell. Thus, the -following is equivalent to the preceding example: - -@example -@group -foo : bar/lose - cd bar; \ - gobble lose > ../foo -@end group -@end example - -@vindex SHELL -The program used as the shell is taken from the variable @code{SHELL}. -By default, the program @file{/bin/sh} is used. - -@vindex COMSPEC -On MS-DOS, if @code{SHELL} is not set, the value of the variable -@code{COMSPEC} (which is always set) is used instead. - -@cindex @code{SHELL}, MS-DOS specifics -The processing of lines that set the variable @code{SHELL} in Makefiles -is different on MS-DOS. The stock shell, @file{command.com}, is -ridiculously limited in its functionality and many users of @code{make} -tend to install a replacement shell. Therefore, on MS-DOS, @code{make} -examines the value of @code{SHELL}, and changes its behavior based on -whether it points to a Unix-style or DOS-style shell. This allows -reasonable functionality even if @code{SHELL} points to -@file{command.com}. - -If @code{SHELL} points to a Unix-style shell, @code{make} on MS-DOS -additionally checks whether that shell can indeed be found; if not, it -ignores the line that sets @code{SHELL}. In MS-DOS, GNU @code{make} -searches for the shell in the following places: - -@enumerate -@item -In the precise place pointed to by the value of @code{SHELL}. For -example, if the makefile specifies @samp{SHELL = /bin/sh}, @code{make} -will look in the directory @file{/bin} on the current drive. - -@item -In the current directory. - -@item -In each of the directories in the @code{PATH} variable, in order. - -@end enumerate - -In every directory it examines, @code{make} will first look for the -specific file (@file{sh} in the example above). If this is not found, -it will also look in that directory for that file with one of the known -extensions which identify executable files. For example @file{.exe}, -@file{.com}, @file{.bat}, @file{.btm}, @file{.sh}, and some others. - -If any of these attempts is successful, the value of @code{SHELL} will -be set to the full pathname of the shell as found. However, if none of -these is found, the value of @code{SHELL} will not be changed, and thus -the line that sets it will be effectively ignored. This is so -@code{make} will only support features specific to a Unix-style shell if -such a shell is actually installed on the system where @code{make} runs. - -Note that this extended search for the shell is limited to the cases -where @code{SHELL} is set from the Makefile; if it is set in the -environment or command line, you are expected to set it to the full -pathname of the shell, exactly as things are on Unix. - -The effect of the above DOS-specific processing is that a Makefile that -says @samp{SHELL = /bin/sh} (as many Unix makefiles do), will work -on MS-DOS unaltered if you have e.g. @file{sh.exe} installed in some -directory along your @code{PATH}. - -@cindex environment, @code{SHELL} in -Unlike most variables, the variable @code{SHELL} is never set from the -environment. This is because the @code{SHELL} environment variable is -used to specify your personal choice of shell program for interactive -use. It would be very bad for personal choices like this to affect the -functioning of makefiles. @xref{Environment, ,Variables from the -Environment}. However, on MS-DOS and MS-Windows the value of -@code{SHELL} in the environment @strong{is} used, since on those systems -most users do not set this variable, and therefore it is most likely set -specifically to be used by @code{make}. On MS-DOS, if the setting of -@code{SHELL} is not suitable for @code{make}, you can set the variable -@code{MAKESHELL} to the shell that @code{make} should use; this will -override the value of @code{SHELL}. - -@node Parallel, Errors, Execution, Commands -@section Parallel Execution -@cindex commands, execution in parallel -@cindex parallel execution -@cindex execution, in parallel -@cindex job slots -@cindex @code{-j} -@cindex @code{--jobs} - -GNU @code{make} knows how to execute several commands at once. -Normally, @code{make} will execute only one command at a time, waiting -for it to finish before executing the next. However, the @samp{-j} or -@samp{--jobs} option tells @code{make} to execute many commands -simultaneously.@refill - -On MS-DOS, the @samp{-j} option has no effect, since that system doesn't -support multi-processing. - -If the @samp{-j} option is followed by an integer, this is the number of -commands to execute at once; this is called the number of @dfn{job slots}. -If there is nothing looking like an integer after the @samp{-j} option, -there is no limit on the number of job slots. The default number of job -slots is one, which means serial execution (one thing at a time). - -One unpleasant consequence of running several commands simultaneously is -that output generated by the commands appears whenever each command -sends it, so messages from different commands may be interspersed. - -Another problem is that two processes cannot both take input from the -same device; so to make sure that only one command tries to take input -from the terminal at once, @code{make} will invalidate the standard -input streams of all but one running command. This means that -attempting to read from standard input will usually be a fatal error (a -@samp{Broken pipe} signal) for most child processes if there are -several. -@cindex broken pipe -@cindex standard input - -It is unpredictable which command will have a valid standard input stream -(which will come from the terminal, or wherever you redirect the standard -input of @code{make}). The first command run will always get it first, and -the first command started after that one finishes will get it next, and so -on. - -We will change how this aspect of @code{make} works if we find a better -alternative. In the mean time, you should not rely on any command using -standard input at all if you are using the parallel execution feature; but -if you are not using this feature, then standard input works normally in -all commands. - -Finally, handling recursive @code{make} invocations raises issues. For -more information on this, see -@ref{Options/Recursion, ,Communicating Options to a Sub-@code{make}}. - -If a command fails (is killed by a signal or exits with a nonzero -status), and errors are not ignored for that command -(@pxref{Errors, ,Errors in Commands}), -the remaining command lines to remake the same target will not be run. -If a command fails and the @samp{-k} or @samp{--keep-going} -option was not given -(@pxref{Options Summary, ,Summary of Options}), -@code{make} aborts execution. If make -terminates for any reason (including a signal) with child processes -running, it waits for them to finish before actually exiting.@refill - -@cindex load average -@cindex limiting jobs based on load -@cindex jobs, limiting based on load -@cindex @code{-l} (load average) -@cindex @code{--max-load} -@cindex @code{--load-average} -When the system is heavily loaded, you will probably want to run fewer jobs -than when it is lightly loaded. You can use the @samp{-l} option to tell -@code{make} to limit the number of jobs to run at once, based on the load -average. The @samp{-l} or @samp{--max-load} -option is followed by a floating-point number. For -example, - -@example --l 2.5 -@end example - -@noindent -will not let @code{make} start more than one job if the load average is -above 2.5. The @samp{-l} option with no following number removes the -load limit, if one was given with a previous @samp{-l} option.@refill - -More precisely, when @code{make} goes to start up a job, and it already has -at least one job running, it checks the current load average; if it is not -lower than the limit given with @samp{-l}, @code{make} waits until the load -average goes below that limit, or until all the other jobs finish. - -By default, there is no load limit. - -@node Errors, Interrupts, Parallel, Commands -@section Errors in Commands -@cindex errors (in commands) -@cindex commands, errors in -@cindex exit status (errors) - -After each shell command returns, @code{make} looks at its exit status. -If the command completed successfully, the next command line is executed -in a new shell; after the last command line is finished, the rule is -finished. - -If there is an error (the exit status is nonzero), @code{make} gives up on -the current rule, and perhaps on all rules. - -Sometimes the failure of a certain command does not indicate a problem. -For example, you may use the @code{mkdir} command to ensure that a -directory exists. If the directory already exists, @code{mkdir} will -report an error, but you probably want @code{make} to continue regardless. - -@cindex @code{-} (in commands) -To ignore errors in a command line, write a @samp{-} at the beginning of -the line's text (after the initial tab). The @samp{-} is discarded before -the command is passed to the shell for execution. - -For example, - -@example -@group -clean: - -rm -f *.o -@end group -@end example -@cindex @code{rm} (shell command) - -@noindent -This causes @code{rm} to continue even if it is unable to remove a file. - -@cindex @code{-i} -@cindex @code{--ignore-errors} -@findex .IGNORE -When you run @code{make} with the @samp{-i} or @samp{--ignore-errors} -flag, errors are ignored in all commands of all rules. A rule in the -makefile for the special target @code{.IGNORE} has the same effect, if -there are no prerequisites. These ways of ignoring errors are obsolete -because @samp{-} is more flexible. - -When errors are to be ignored, because of either a @samp{-} or the -@samp{-i} flag, @code{make} treats an error return just like success, -except that it prints out a message that tells you the status code -the command exited with, and says that the error has been ignored. - -When an error happens that @code{make} has not been told to ignore, -it implies that the current target cannot be correctly remade, and neither -can any other that depends on it either directly or indirectly. No further -commands will be executed for these targets, since their preconditions -have not been achieved. - - -@cindex @code{-k} -@cindex @code{--keep-going} -Normally @code{make} gives up immediately in this circumstance, returning a -nonzero status. However, if the @samp{-k} or @samp{--keep-going} -flag is specified, @code{make} -continues to consider the other prerequisites of the pending targets, -remaking them if necessary, before it gives up and returns nonzero status. -For example, after an error in compiling one object file, @samp{make -k} -will continue compiling other object files even though it already knows -that linking them will be impossible. @xref{Options Summary, ,Summary of Options}. - -The usual behavior assumes that your purpose is to get the specified -targets up to date; once @code{make} learns that this is impossible, it -might as well report the failure immediately. The @samp{-k} option says -that the real purpose is to test as many of the changes made in the -program as possible, perhaps to find several independent problems so -that you can correct them all before the next attempt to compile. This -is why Emacs' @code{compile} command passes the @samp{-k} flag by -default. -@cindex Emacs (@code{M-x compile}) - -@findex .DELETE_ON_ERROR -@cindex deletion of target files -@cindex removal of target files -@cindex target, deleting on error -Usually when a command fails, if it has changed the target file at all, -the file is corrupted and cannot be used---or at least it is not -completely updated. Yet the file's time stamp says that it is now up to -date, so the next time @code{make} runs, it will not try to update that -file. The situation is just the same as when the command is killed by a -signal; @pxref{Interrupts}. So generally the right thing to do is to -delete the target file if the command fails after beginning to change -the file. @code{make} will do this if @code{.DELETE_ON_ERROR} appears -as a target. This is almost always what you want @code{make} to do, but -it is not historical practice; so for compatibility, you must explicitly -request it. - -@node Interrupts, Recursion, Errors, Commands -@section Interrupting or Killing @code{make} -@cindex interrupt -@cindex signal -@cindex deletion of target files -@cindex removal of target files -@cindex target, deleting on interrupt -@cindex killing (interruption) - -If @code{make} gets a fatal signal while a command is executing, it may -delete the target file that the command was supposed to update. This is -done if the target file's last-modification time has changed since -@code{make} first checked it. - -The purpose of deleting the target is to make sure that it is remade from -scratch when @code{make} is next run. Why is this? Suppose you type -@kbd{Ctrl-c} while a compiler is running, and it has begun to write an -object file @file{foo.o}. The @kbd{Ctrl-c} kills the compiler, resulting -in an incomplete file whose last-modification time is newer than the source -file @file{foo.c}. But @code{make} also receives the @kbd{Ctrl-c} signal -and deletes this incomplete file. If @code{make} did not do this, the next -invocation of @code{make} would think that @file{foo.o} did not require -updating---resulting in a strange error message from the linker when it -tries to link an object file half of which is missing. - -@findex .PRECIOUS -You can prevent the deletion of a target file in this way by making the -special target @code{.PRECIOUS} depend on it. Before remaking a target, -@code{make} checks to see whether it appears on the prerequisites of -@code{.PRECIOUS}, and thereby decides whether the target should be deleted -if a signal happens. Some reasons why you might do this are that the -target is updated in some atomic fashion, or exists only to record a -modification-time (its contents do not matter), or must exist at all -times to prevent other sorts of trouble. - -@node Recursion, Sequences, Interrupts, Commands -@section Recursive Use of @code{make} -@cindex recursion -@cindex subdirectories, recursion for - -Recursive use of @code{make} means using @code{make} as a command in a -makefile. This technique is useful when you want separate makefiles for -various subsystems that compose a larger system. For example, suppose you -have a subdirectory @file{subdir} which has its own makefile, and you would -like the containing directory's makefile to run @code{make} on the -subdirectory. You can do it by writing this: - -@example -subsystem: - cd subdir && $(MAKE) -@end example - -@noindent -or, equivalently, this (@pxref{Options Summary, ,Summary of Options}): - -@example -subsystem: - $(MAKE) -C subdir -@end example -@cindex @code{-C} -@cindex @code{--directory} - -You can write recursive @code{make} commands just by copying this example, -but there are many things to know about how they work and why, and about -how the sub-@code{make} relates to the top-level @code{make}. - -For your convenience, GNU @code{make} sets the variable @code{CURDIR} to -the pathname of the current working directory for you. If @code{-C} is -in effect, it will contain the path of the new directory, not the -original. The value has the same precedence it would have if it were -set in the makefile (by default, an environment variable @code{CURDIR} -will not override this value). Note that setting this variable has no -effect on the operation of @code{make} - -@menu -* MAKE Variable:: The special effects of using @samp{$(MAKE)}. -* Variables/Recursion:: How to communicate variables to a sub-@code{make}. -* Options/Recursion:: How to communicate options to a sub-@code{make}. -* -w Option:: How the @samp{-w} or @samp{--print-directory} option - helps debug use of recursive @code{make} commands. -@end menu - -@node MAKE Variable, Variables/Recursion, , Recursion -@subsection How the @code{MAKE} Variable Works -@vindex MAKE -@cindex recursion, and @code{MAKE} variable - -Recursive @code{make} commands should always use the variable @code{MAKE}, -not the explicit command name @samp{make}, as shown here: - -@example -@group -subsystem: - cd subdir && $(MAKE) -@end group -@end example - -The value of this variable is the file name with which @code{make} was -invoked. If this file name was @file{/bin/make}, then the command executed -is @samp{cd subdir && /bin/make}. If you use a special version of -@code{make} to run the top-level makefile, the same special version will be -executed for recursive invocations. -@cindex @code{cd} (shell command) - -As a special feature, using the variable @code{MAKE} in the commands of -a rule alters the effects of the @samp{-t} (@samp{--touch}), @samp{-n} -(@samp{--just-print}), or @samp{-q} (@w{@samp{--question}}) option. -Using the @code{MAKE} variable has the same effect as using a @samp{+} -character at the beginning of the command line. @xref{Instead of -Execution, ,Instead of Executing the Commands}.@refill - -Consider the command @samp{make -t} in the above example. (The -@samp{-t} option marks targets as up to date without actually running -any commands; see @ref{Instead of Execution}.) Following the usual -definition of @samp{-t}, a @samp{make -t} command in the example would -create a file named @file{subsystem} and do nothing else. What you -really want it to do is run @samp{@w{cd subdir &&} @w{make -t}}; but that would -require executing the command, and @samp{-t} says not to execute -commands.@refill -@cindex @code{-t}, and recursion -@cindex recursion, and @code{-t} -@cindex @code{--touch}, and recursion - -The special feature makes this do what you want: whenever a command -line of a rule contains the variable @code{MAKE}, the flags @samp{-t}, -@samp{-n} and @samp{-q} do not apply to that line. Command lines -containing @code{MAKE} are executed normally despite the presence of a -flag that causes most commands not to be run. The usual -@code{MAKEFLAGS} mechanism passes the flags to the sub-@code{make} -(@pxref{Options/Recursion, ,Communicating Options to a -Sub-@code{make}}), so your request to touch the files, or print the -commands, is propagated to the subsystem.@refill - -@node Variables/Recursion, Options/Recursion, MAKE Variable, Recursion -@subsection Communicating Variables to a Sub-@code{make} -@cindex sub-@code{make} -@cindex environment, and recursion -@cindex exporting variables -@cindex variables, environment -@cindex variables, exporting -@cindex recursion, and environment -@cindex recursion, and variables - -Variable values of the top-level @code{make} can be passed to the -sub-@code{make} through the environment by explicit request. These -variables are defined in the sub-@code{make} as defaults, but do not -override what is specified in the makefile used by the sub-@code{make} -makefile unless you use the @samp{-e} switch (@pxref{Options Summary, -,Summary of Options}).@refill - -To pass down, or @dfn{export}, a variable, @code{make} adds the variable -and its value to the environment for running each command. The -sub-@code{make}, in turn, uses the environment to initialize its table -of variable values. @xref{Environment, ,Variables from the -Environment}. - -Except by explicit request, @code{make} exports a variable only if it -is either defined in the environment initially or set on the command -line, and if its name consists only of letters, numbers, and underscores. -Some shells cannot cope with environment variable names consisting of -characters other than letters, numbers, and underscores. - -The special variables @code{SHELL} and @code{MAKEFLAGS} are always -exported (unless you unexport them). -@code{MAKEFILES} is exported if you set it to anything. - -@code{make} automatically passes down variable values that were defined -on the command line, by putting them in the @code{MAKEFLAGS} variable. -@iftex -See the next section. -@end iftex -@ifinfo -@xref{Options/Recursion}. -@end ifinfo - -Variables are @emph{not} normally passed down if they were created by -default by @code{make} (@pxref{Implicit Variables, ,Variables Used by -Implicit Rules}). The sub-@code{make} will define these for -itself.@refill - -@findex export -If you want to export specific variables to a sub-@code{make}, use the -@code{export} directive, like this: - -@example -export @var{variable} @dots{} -@end example - -@noindent -@findex unexport -If you want to @emph{prevent} a variable from being exported, use the -@code{unexport} directive, like this: - -@example -unexport @var{variable} @dots{} -@end example - -@noindent -As a convenience, you can define a variable and export it at the same -time by doing: - -@example -export @var{variable} = value -@end example - -@noindent -has the same result as: - -@example -@var{variable} = value -export @var{variable} -@end example - -@noindent -and - -@example -export @var{variable} := value -@end example - -@noindent -has the same result as: - -@example -@var{variable} := value -export @var{variable} -@end example - -Likewise, - -@example -export @var{variable} += value -@end example - -@noindent -is just like: - -@example -@var{variable} += value -export @var{variable} -@end example - -@noindent -@xref{Appending, ,Appending More Text to Variables}. - -You may notice that the @code{export} and @code{unexport} directives -work in @code{make} in the same way they work in the shell, @code{sh}. - -If you want all variables to be exported by default, you can use -@code{export} by itself: - -@example -export -@end example - -@noindent -This tells @code{make} that variables which are not explicitly mentioned -in an @code{export} or @code{unexport} directive should be exported. -Any variable given in an @code{unexport} directive will still @emph{not} -be exported. If you use @code{export} by itself to export variables by -default, variables whose names contain characters other than -alphanumerics and underscores will not be exported unless specifically -mentioned in an @code{export} directive.@refill - -@findex .EXPORT_ALL_VARIABLES -The behavior elicited by an @code{export} directive by itself was the -default in older versions of GNU @code{make}. If your makefiles depend -on this behavior and you want to be compatible with old versions of -@code{make}, you can write a rule for the special target -@code{.EXPORT_ALL_VARIABLES} instead of using the @code{export} directive. -This will be ignored by old @code{make}s, while the @code{export} -directive will cause a syntax error.@refill -@cindex compatibility in exporting - -Likewise, you can use @code{unexport} by itself to tell @code{make} -@emph{not} to export variables by default. Since this is the default -behavior, you would only need to do this if @code{export} had been used -by itself earlier (in an included makefile, perhaps). You -@strong{cannot} use @code{export} and @code{unexport} by themselves to -have variables exported for some commands and not for others. The last -@code{export} or @code{unexport} directive that appears by itself -determines the behavior for the entire run of @code{make}.@refill - -@vindex MAKELEVEL -@cindex recursion, level of -As a special feature, the variable @code{MAKELEVEL} is changed when it -is passed down from level to level. This variable's value is a string -which is the depth of the level as a decimal number. The value is -@samp{0} for the top-level @code{make}; @samp{1} for a sub-@code{make}, -@samp{2} for a sub-sub-@code{make}, and so on. The incrementation -happens when @code{make} sets up the environment for a command.@refill - -The main use of @code{MAKELEVEL} is to test it in a conditional -directive (@pxref{Conditionals, ,Conditional Parts of Makefiles}); this -way you can write a makefile that behaves one way if run recursively and -another way if run directly by you.@refill - -@vindex MAKEFILES -You can use the variable @code{MAKEFILES} to cause all sub-@code{make} -commands to use additional makefiles. The value of @code{MAKEFILES} is -a whitespace-separated list of file names. This variable, if defined in -the outer-level makefile, is passed down through the environment; then -it serves as a list of extra makefiles for the sub-@code{make} to read -before the usual or specified ones. @xref{MAKEFILES Variable, ,The -Variable @code{MAKEFILES}}.@refill - -@node Options/Recursion, -w Option, Variables/Recursion, Recursion -@subsection Communicating Options to a Sub-@code{make} -@cindex options, and recursion -@cindex recursion, and options - -@vindex MAKEFLAGS -Flags such as @samp{-s} and @samp{-k} are passed automatically to the -sub-@code{make} through the variable @code{MAKEFLAGS}. This variable is -set up automatically by @code{make} to contain the flag letters that -@code{make} received. Thus, if you do @w{@samp{make -ks}} then -@code{MAKEFLAGS} gets the value @samp{ks}.@refill - -As a consequence, every sub-@code{make} gets a value for @code{MAKEFLAGS} -in its environment. In response, it takes the flags from that value and -processes them as if they had been given as arguments. -@xref{Options Summary, ,Summary of Options}. - -@cindex command line variable definitions, and recursion -@cindex variables, command line, and recursion -@cindex recursion, and command line variable definitions -Likewise variables defined on the command line are passed to the -sub-@code{make} through @code{MAKEFLAGS}. Words in the value of -@code{MAKEFLAGS} that contain @samp{=}, @code{make} treats as variable -definitions just as if they appeared on the command line. -@xref{Overriding, ,Overriding Variables}. - -@cindex @code{-C}, and recursion -@cindex @code{-f}, and recursion -@cindex @code{-o}, and recursion -@cindex @code{-W}, and recursion -@cindex @code{--directory}, and recursion -@cindex @code{--file}, and recursion -@cindex @code{--old-file}, and recursion -@cindex @code{--assume-old}, and recursion -@cindex @code{--assume-new}, and recursion -@cindex @code{--new-file}, and recursion -@cindex recursion, and @code{-C} -@cindex recursion, and @code{-f} -@cindex recursion, and @code{-o} -@cindex recursion, and @code{-W} -The options @samp{-C}, @samp{-f}, @samp{-o}, and @samp{-W} are not put -into @code{MAKEFLAGS}; these options are not passed down.@refill - -@cindex @code{-j}, and recursion -@cindex @code{--jobs}, and recursion -@cindex recursion, and @code{-j} -@cindex job slots, and recursion -The @samp{-j} option is a special case (@pxref{Parallel, ,Parallel Execution}). -If you set it to some numeric value @samp{N} and your operating system -supports it (most any UNIX system will; others typically won't), the -parent @code{make} and all the sub-@code{make}s will communicate to -ensure that there are only @samp{N} jobs running at the same time -between them all. Note that any job that is marked recursive -(@pxref{Instead of Execution, ,Instead of Executing the Commands}) -doesn't count against the total jobs (otherwise we could get @samp{N} -sub-@code{make}s running and have no slots left over for any real work!) - -If your operating system doesn't support the above communication, then -@samp{-j 1} is always put into @code{MAKEFLAGS} instead of the value you -specified. This is because if the @w{@samp{-j}} option were passed down -to sub-@code{make}s, you would get many more jobs running in parallel -than you asked for. If you give @samp{-j} with no numeric argument, -meaning to run as many jobs as possible in parallel, this is passed -down, since multiple infinities are no more than one.@refill - -If you do not want to pass the other flags down, you must change the -value of @code{MAKEFLAGS}, like this: - -@example -subsystem: - cd subdir && $(MAKE) MAKEFLAGS= -@end example - -@vindex MAKEOVERRIDES -The command line variable definitions really appear in the variable -@code{MAKEOVERRIDES}, and @code{MAKEFLAGS} contains a reference to this -variable. If you do want to pass flags down normally, but don't want to -pass down the command line variable definitions, you can reset -@code{MAKEOVERRIDES} to empty, like this: - -@example -MAKEOVERRIDES = -@end example - -@noindent -@cindex Arg list too long -@cindex E2BIG -This is not usually useful to do. However, some systems have a small -fixed limit on the size of the environment, and putting so much -information into the value of @code{MAKEFLAGS} can exceed it. If you -see the error message @samp{Arg list too long}, this may be the problem. -@findex .POSIX -@cindex POSIX.2 -(For strict compliance with POSIX.2, changing @code{MAKEOVERRIDES} does -not affect @code{MAKEFLAGS} if the special target @samp{.POSIX} appears -in the makefile. You probably do not care about this.) - -@vindex MFLAGS -A similar variable @code{MFLAGS} exists also, for historical -compatibility. It has the same value as @code{MAKEFLAGS} except that it -does not contain the command line variable definitions, and it always -begins with a hyphen unless it is empty (@code{MAKEFLAGS} begins with a -hyphen only when it begins with an option that has no single-letter -version, such as @samp{--warn-undefined-variables}). @code{MFLAGS} was -traditionally used explicitly in the recursive @code{make} command, like -this: - -@example -subsystem: - cd subdir && $(MAKE) $(MFLAGS) -@end example - -@noindent -but now @code{MAKEFLAGS} makes this usage redundant. If you want your -makefiles to be compatible with old @code{make} programs, use this -technique; it will work fine with more modern @code{make} versions too. - -@cindex setting options from environment -@cindex options, setting from environment -@cindex setting options in makefiles -@cindex options, setting in makefiles -The @code{MAKEFLAGS} variable can also be useful if you want to have -certain options, such as @samp{-k} (@pxref{Options Summary, ,Summary of -Options}), set each time you run @code{make}. You simply put a value for -@code{MAKEFLAGS} in your environment. You can also set @code{MAKEFLAGS} in -a makefile, to specify additional flags that should also be in effect for -that makefile. (Note that you cannot use @code{MFLAGS} this way. That -variable is set only for compatibility; @code{make} does not interpret a -value you set for it in any way.) - -When @code{make} interprets the value of @code{MAKEFLAGS} (either from the -environment or from a makefile), it first prepends a hyphen if the value -does not already begin with one. Then it chops the value into words -separated by blanks, and parses these words as if they were options given -on the command line (except that @samp{-C}, @samp{-f}, @samp{-h}, -@samp{-o}, @samp{-W}, and their long-named versions are ignored; and there -is no error for an invalid option). - -If you do put @code{MAKEFLAGS} in your environment, you should be sure not -to include any options that will drastically affect the actions of -@code{make} and undermine the purpose of makefiles and of @code{make} -itself. For instance, the @samp{-t}, @samp{-n}, and @samp{-q} options, if -put in one of these variables, could have disastrous consequences and would -certainly have at least surprising and probably annoying effects.@refill - -@node -w Option, , Options/Recursion, Recursion -@subsection The @samp{--print-directory} Option -@cindex directories, printing them -@cindex printing directories -@cindex recursion, and printing directories - -If you use several levels of recursive @code{make} invocations, the -@samp{-w} or @w{@samp{--print-directory}} option can make the output a -lot easier to understand by showing each directory as @code{make} -starts processing it and as @code{make} finishes processing it. For -example, if @samp{make -w} is run in the directory @file{/u/gnu/make}, -@code{make} will print a line of the form:@refill - -@example -make: Entering directory `/u/gnu/make'. -@end example - -@noindent -before doing anything else, and a line of the form: - -@example -make: Leaving directory `/u/gnu/make'. -@end example - -@noindent -when processing is completed. - -@cindex @code{-C}, and @code{-w} -@cindex @code{--directory}, and @code{--print-directory} -@cindex recursion, and @code{-w} -@cindex @code{-w}, and @code{-C} -@cindex @code{-w}, and recursion -@cindex @code{--print-directory}, and @code{--directory} -@cindex @code{--print-directory}, and recursion -@cindex @code{--no-print-directory} -@cindex @code{--print-directory}, disabling -@cindex @code{-w}, disabling -Normally, you do not need to specify this option because @samp{make} -does it for you: @samp{-w} is turned on automatically when you use the -@samp{-C} option, and in sub-@code{make}s. @code{make} will not -automatically turn on @samp{-w} if you also use @samp{-s}, which says to -be silent, or if you use @samp{--no-print-directory} to explicitly -disable it. - -@node Sequences, Empty Commands, Recursion, Commands -@section Defining Canned Command Sequences -@cindex sequences of commands -@cindex commands, sequences of - -When the same sequence of commands is useful in making various targets, you -can define it as a canned sequence with the @code{define} directive, and -refer to the canned sequence from the rules for those targets. The canned -sequence is actually a variable, so the name must not conflict with other -variable names. - -Here is an example of defining a canned sequence of commands: - -@example -define run-yacc -yacc $(firstword $^) -mv y.tab.c $@@ -endef -@end example -@cindex @code{yacc} - -@noindent -Here @code{run-yacc} is the name of the variable being defined; -@code{endef} marks the end of the definition; the lines in between are the -commands. The @code{define} directive does not expand variable references -and function calls in the canned sequence; the @samp{$} characters, -parentheses, variable names, and so on, all become part of the value of the -variable you are defining. -@xref{Defining, ,Defining Variables Verbatim}, -for a complete explanation of @code{define}. - -The first command in this example runs Yacc on the first prerequisite of -whichever rule uses the canned sequence. The output file from Yacc is -always named @file{y.tab.c}. The second command moves the output to the -rule's target file name. - -To use the canned sequence, substitute the variable into the commands of a -rule. You can substitute it like any other variable -(@pxref{Reference, ,Basics of Variable References}). -Because variables defined by @code{define} are recursively expanded -variables, all the variable references you wrote inside the @code{define} -are expanded now. For example: - -@example -foo.c : foo.y - $(run-yacc) -@end example - -@noindent -@samp{foo.y} will be substituted for the variable @samp{$^} when it occurs in -@code{run-yacc}'s value, and @samp{foo.c} for @samp{$@@}.@refill - -This is a realistic example, but this particular one is not needed in -practice because @code{make} has an implicit rule to figure out these -commands based on the file names involved -(@pxref{Implicit Rules, ,Using Implicit Rules}). - -@cindex @@, and @code{define} -@cindex -, and @code{define} -@cindex +, and @code{define} -In command execution, each line of a canned sequence is treated just as -if the line appeared on its own in the rule, preceded by a tab. In -particular, @code{make} invokes a separate subshell for each line. You -can use the special prefix characters that affect command lines -(@samp{@@}, @samp{-}, and @samp{+}) on each line of a canned sequence. -@xref{Commands, ,Writing the Commands in Rules}. -For example, using this canned sequence: - -@example -define frobnicate -@@echo "frobnicating target $@@" -frob-step-1 $< -o $@@-step-1 -frob-step-2 $@@-step-1 -o $@@ -endef -@end example - -@noindent -@code{make} will not echo the first line, the @code{echo} command. -But it @emph{will} echo the following two command lines. - -On the other hand, prefix characters on the command line that refers to -a canned sequence apply to every line in the sequence. So the rule: - -@example -frob.out: frob.in - @@$(frobnicate) -@end example - -@noindent -does not echo @emph{any} commands. -(@xref{Echoing, ,Command Echoing}, for a full explanation of @samp{@@}.) - -@node Empty Commands, , Sequences, Commands -@section Using Empty Commands -@cindex empty commands -@cindex commands, empty - -It is sometimes useful to define commands which do nothing. This is done -simply by giving a command that consists of nothing but whitespace. For -example: - -@example -target: ; -@end example - -@noindent -defines an empty command string for @file{target}. You could also use a -line beginning with a tab character to define an empty command string, -but this would be confusing because such a line looks empty. - -@findex .DEFAULT@r{, and empty commands} -You may be wondering why you would want to define a command string that -does nothing. The only reason this is useful is to prevent a target -from getting implicit commands (from implicit rules or the -@code{.DEFAULT} special target; @pxref{Implicit Rules} and -@pxref{Last Resort, ,Defining Last-Resort Default Rules}).@refill - -@c !!! another reason is for canonical stamp files: -@ignore -foo: stamp-foo ; -stamp-foo: foo.in - create foo frm foo.in - touch $@ -@end ignore - -You may be inclined to define empty command strings for targets that are -not actual files, but only exist so that their prerequisites can be -remade. However, this is not the best way to do that, because the -prerequisites may not be remade properly if the target file actually does exist. -@xref{Phony Targets, ,Phony Targets}, for a better way to do this. - -@node Using Variables, Conditionals, Commands, Top -@chapter How to Use Variables -@cindex variable -@cindex value -@cindex recursive variable expansion -@cindex simple variable expansion - -A @dfn{variable} is a name defined in a makefile to represent a string -of text, called the variable's @dfn{value}. These values are -substituted by explicit request into targets, prerequisites, commands, -and other parts of the makefile. (In some other versions of @code{make}, -variables are called @dfn{macros}.) -@cindex macro - -Variables and functions in all parts of a makefile are expanded when -read, except for the shell commands in rules, the right-hand sides of -variable definitions using @samp{=}, and the bodies of variable -definitions using the @code{define} directive.@refill - -Variables can represent lists of file names, options to pass to compilers, -programs to run, directories to look in for source files, directories to -write output in, or anything else you can imagine. - -A variable name may be any sequence of characters not containing @samp{:}, -@samp{#}, @samp{=}, or leading or trailing whitespace. However, -variable names containing characters other than letters, numbers, and -underscores should be avoided, as they may be given special meanings in the -future, and with some shells they cannot be passed through the environment to a -sub-@code{make} -(@pxref{Variables/Recursion, ,Communicating Variables to a Sub-@code{make}}). - -Variable names are case-sensitive. The names @samp{foo}, @samp{FOO}, -and @samp{Foo} all refer to different variables. - -It is traditional to use upper case letters in variable names, but we -recommend using lower case letters for variable names that serve internal -purposes in the makefile, and reserving upper case for parameters that -control implicit rules or for parameters that the user should override with -command options (@pxref{Overriding, ,Overriding Variables}). - -A few variables have names that are a single punctuation character or -just a few characters. These are the @dfn{automatic variables}, and -they have particular specialized uses. @xref{Automatic, ,Automatic Variables}. - -@menu -* Reference:: How to use the value of a variable. -* Flavors:: Variables come in two flavors. -* Advanced:: Advanced features for referencing a variable. -* Values:: All the ways variables get their values. -* Setting:: How to set a variable in the makefile. -* Appending:: How to append more text to the old value - of a variable. -* Override Directive:: How to set a variable in the makefile even if - the user has set it with a command argument. -* Defining:: An alternate way to set a variable - to a verbatim string. -* Environment:: Variable values can come from the environment. -* Target-specific:: Variable values can be defined on a per-target - basis. -* Pattern-specific:: Target-specific variable values can be applied - to a group of targets that match a pattern. -* Automatic:: Some special variables have predefined - meanings for use with implicit rules. -@end menu - -@node Reference, Flavors, , Using Variables -@section Basics of Variable References -@cindex variables, how to reference -@cindex reference to variables -@cindex @code{$}, in variable reference -@cindex dollar sign (@code{$}), in variable reference - -To substitute a variable's value, write a dollar sign followed by the name -of the variable in parentheses or braces: either @samp{$(foo)} or -@samp{$@{foo@}} is a valid reference to the variable @code{foo}. This -special significance of @samp{$} is why you must write @samp{$$} to have -the effect of a single dollar sign in a file name or command. - -Variable references can be used in any context: targets, prerequisites, -commands, most directives, and new variable values. Here is an -example of a common case, where a variable holds the names of all the -object files in a program: - -@example -@group -objects = program.o foo.o utils.o -program : $(objects) - cc -o program $(objects) - -$(objects) : defs.h -@end group -@end example - -Variable references work by strict textual substitution. Thus, the rule - -@example -@group -foo = c -prog.o : prog.$(foo) - $(foo)$(foo) -$(foo) prog.$(foo) -@end group -@end example - -@noindent -could be used to compile a C program @file{prog.c}. Since spaces before -the variable value are ignored in variable assignments, the value of -@code{foo} is precisely @samp{c}. (Don't actually write your makefiles -this way!) - -A dollar sign followed by a character other than a dollar sign, -open-parenthesis or open-brace treats that single character as the -variable name. Thus, you could reference the variable @code{x} with -@samp{$x}. However, this practice is strongly discouraged, except in -the case of the automatic variables (@pxref{Automatic, ,Automatic Variables}). - -@node Flavors, Advanced, Reference, Using Variables -@section The Two Flavors of Variables -@cindex flavors of variables -@cindex recursive variable expansion -@cindex variables, flavors -@cindex recursively expanded variables -@cindex variables, recursively expanded - -There are two ways that a variable in GNU @code{make} can have a value; -we call them the two @dfn{flavors} of variables. The two flavors are -distinguished in how they are defined and in what they do when expanded. - -@cindex = -The first flavor of variable is a @dfn{recursively expanded} variable. -Variables of this sort are defined by lines using @samp{=} -(@pxref{Setting, ,Setting Variables}) or by the @code{define} directive -(@pxref{Defining, ,Defining Variables Verbatim}). The value you specify -is installed verbatim; if it contains references to other variables, -these references are expanded whenever this variable is substituted (in -the course of expanding some other string). When this happens, it is -called @dfn{recursive expansion}.@refill - -For example, - -@example -foo = $(bar) -bar = $(ugh) -ugh = Huh? - -all:;echo $(foo) -@end example - -@noindent -will echo @samp{Huh?}: @samp{$(foo)} expands to @samp{$(bar)} which -expands to @samp{$(ugh)} which finally expands to @samp{Huh?}.@refill - -This flavor of variable is the only sort supported by other versions of -@code{make}. It has its advantages and its disadvantages. An advantage -(most would say) is that: - -@example -CFLAGS = $(include_dirs) -O -include_dirs = -Ifoo -Ibar -@end example - -@noindent -will do what was intended: when @samp{CFLAGS} is expanded in a command, -it will expand to @samp{-Ifoo -Ibar -O}. A major disadvantage is that you -cannot append something on the end of a variable, as in - -@example -CFLAGS = $(CFLAGS) -O -@end example - -@noindent -because it will cause an infinite loop in the variable expansion. -(Actually @code{make} detects the infinite loop and reports an error.) -@cindex loops in variable expansion -@cindex variables, loops in expansion - -Another disadvantage is that any functions -(@pxref{Functions, ,Functions for Transforming Text}) -referenced in the definition will be executed every time the variable is -expanded. This makes @code{make} run slower; worse, it causes the -@code{wildcard} and @code{shell} functions to give unpredictable results -because you cannot easily control when they are called, or even how many -times. - -To avoid all the problems and inconveniences of recursively expanded -variables, there is another flavor: simply expanded variables. - -@cindex simply expanded variables -@cindex variables, simply expanded -@cindex := -@dfn{Simply expanded variables} are defined by lines using @samp{:=} -(@pxref{Setting, ,Setting Variables}). -The value of a simply expanded variable is scanned -once and for all, expanding any references to other variables and -functions, when the variable is defined. The actual value of the simply -expanded variable is the result of expanding the text that you write. -It does not contain any references to other variables; it contains their -values @emph{as of the time this variable was defined}. Therefore, - -@example -x := foo -y := $(x) bar -x := later -@end example - -@noindent -is equivalent to - -@example -y := foo bar -x := later -@end example - -When a simply expanded variable is referenced, its value is substituted -verbatim. - -Here is a somewhat more complicated example, illustrating the use of -@samp{:=} in conjunction with the @code{shell} function. -(@xref{Shell Function, , The @code{shell} Function}.) This example -also shows use of the variable @code{MAKELEVEL}, which is changed -when it is passed down from level to level. -(@xref{Variables/Recursion, , Communicating Variables to a -Sub-@code{make}}, for information about @code{MAKELEVEL}.) - -@vindex MAKELEVEL -@vindex MAKE -@example -@group -ifeq (0,$@{MAKELEVEL@}) -cur-dir := $(shell pwd) -whoami := $(shell whoami) -host-type := $(shell arch) -MAKE := $@{MAKE@} host-type=$@{host-type@} whoami=$@{whoami@} -endif -@end group -@end example - -@noindent -An advantage of this use of @samp{:=} is that a typical -`descend into a directory' command then looks like this: - -@example -@group -$@{subdirs@}: - $@{MAKE@} cur-dir=$@{cur-dir@}/$@@ -C $@@ all -@end group -@end example - -Simply expanded variables generally make complicated makefile programming -more predictable because they work like variables in most programming -languages. They allow you to redefine a variable using its own value (or -its value processed in some way by one of the expansion functions) and to -use the expansion functions much more efficiently -(@pxref{Functions, ,Functions for Transforming Text}). - -@cindex spaces, in variable values -@cindex whitespace, in variable values -@cindex variables, spaces in values -You can also use them to introduce controlled leading whitespace into -variable values. Leading whitespace characters are discarded from your -input before substitution of variable references and function calls; -this means you can include leading spaces in a variable value by -protecting them with variable references, like this: - -@example -nullstring := -space := $(nullstring) # end of the line -@end example - -@noindent -Here the value of the variable @code{space} is precisely one space. The -comment @w{@samp{# end of the line}} is included here just for clarity. -Since trailing space characters are @emph{not} stripped from variable -values, just a space at the end of the line would have the same effect -(but be rather hard to read). If you put whitespace at the end of a -variable value, it is a good idea to put a comment like that at the end -of the line to make your intent clear. Conversely, if you do @emph{not} -want any whitespace characters at the end of your variable value, you -must remember not to put a random comment on the end of the line after -some whitespace, such as this: - -@example -dir := /foo/bar # directory to put the frobs in -@end example - -@noindent -Here the value of the variable @code{dir} is @w{@samp{/foo/bar }} -(with four trailing spaces), which was probably not the intention. -(Imagine something like @w{@samp{$(dir)/file}} with this definition!) - -@cindex conditional variable assignment -@cindex variables, conditional assignment -@cindex ?= -There is another assignment operator for variables, @samp{?=}. This -is called a conditional variable assignment operator, because it only -has an effect if the variable is not yet defined. This statement: - -@example -FOO ?= bar -@end example - -@noindent -is exactly equivalent to this -(@pxref{Origin Function, ,The @code{origin} Function}): - -@example -ifeq ($(origin FOO), undefined) - FOO = bar -endif -@end example - -Note that a variable set to an empty value is still defined, so -@samp{?=} will not set that variable. - -@node Advanced, Values, Flavors, Using Variables -@section Advanced Features for Reference to Variables -@cindex reference to variables - -This section describes some advanced features you can use to reference -variables in more flexible ways. - -@menu -* Substitution Refs:: Referencing a variable with - substitutions on the value. -* Computed Names:: Computing the name of the variable to refer to. -@end menu - -@node Substitution Refs, Computed Names, , Advanced -@subsection Substitution References -@cindex modified variable reference -@cindex substitution variable reference -@cindex variables, modified reference -@cindex variables, substitution reference - -@cindex variables, substituting suffix in -@cindex suffix, substituting in variables -A @dfn{substitution reference} substitutes the value of a variable with -alterations that you specify. It has the form -@samp{$(@var{var}:@var{a}=@var{b})} (or -@samp{$@{@var{var}:@var{a}=@var{b}@}}) and its meaning is to take the value -of the variable @var{var}, replace every @var{a} at the end of a word with -@var{b} in that value, and substitute the resulting string. - -When we say ``at the end of a word'', we mean that @var{a} must appear -either followed by whitespace or at the end of the value in order to be -replaced; other occurrences of @var{a} in the value are unaltered. For -example:@refill - -@example -foo := a.o b.o c.o -bar := $(foo:.o=.c) -@end example - -@noindent -sets @samp{bar} to @samp{a.c b.c c.c}. @xref{Setting, ,Setting Variables}. - -A substitution reference is actually an abbreviation for use of the -@code{patsubst} expansion function (@pxref{Text Functions, ,Functions for String Substitution and Analysis}). We provide -substitution references as well as @code{patsubst} for compatibility with -other implementations of @code{make}. - -@findex patsubst -Another type of substitution reference lets you use the full power of -the @code{patsubst} function. It has the same form -@samp{$(@var{var}:@var{a}=@var{b})} described above, except that now -@var{a} must contain a single @samp{%} character. This case is -equivalent to @samp{$(patsubst @var{a},@var{b},$(@var{var}))}. -@xref{Text Functions, ,Functions for String Substitution and Analysis}, -for a description of the @code{patsubst} function.@refill - -@example -@group -@exdent For example: - -foo := a.o b.o c.o -bar := $(foo:%.o=%.c) -@end group -@end example - -@noindent -sets @samp{bar} to @samp{a.c b.c c.c}. - -@node Computed Names, , Substitution Refs, Advanced -@subsection Computed Variable Names -@cindex nested variable reference -@cindex computed variable name -@cindex variables, computed names -@cindex variables, nested references -@cindex variables, @samp{$} in name -@cindex @code{$}, in variable name -@cindex dollar sign (@code{$}), in variable name - -Computed variable names are a complicated concept needed only for -sophisticated makefile programming. For most purposes you need not -consider them, except to know that making a variable with a dollar sign -in its name might have strange results. However, if you are the type -that wants to understand everything, or you are actually interested in -what they do, read on. - -Variables may be referenced inside the name of a variable. This is -called a @dfn{computed variable name} or a @dfn{nested variable -reference}. For example, - -@example -x = y -y = z -a := $($(x)) -@end example - -@noindent -defines @code{a} as @samp{z}: the @samp{$(x)} inside @samp{$($(x))} expands -to @samp{y}, so @samp{$($(x))} expands to @samp{$(y)} which in turn expands -to @samp{z}. Here the name of the variable to reference is not stated -explicitly; it is computed by expansion of @samp{$(x)}. The reference -@samp{$(x)} here is nested within the outer variable reference. - -The previous example shows two levels of nesting, but any number of levels -is possible. For example, here are three levels: - -@example -x = y -y = z -z = u -a := $($($(x))) -@end example - -@noindent -Here the innermost @samp{$(x)} expands to @samp{y}, so @samp{$($(x))} -expands to @samp{$(y)} which in turn expands to @samp{z}; now we have -@samp{$(z)}, which becomes @samp{u}. - -References to recursively-expanded variables within a variable name are -reexpanded in the usual fashion. For example: - -@example -x = $(y) -y = z -z = Hello -a := $($(x)) -@end example - -@noindent -defines @code{a} as @samp{Hello}: @samp{$($(x))} becomes @samp{$($(y))} -which becomes @samp{$(z)} which becomes @samp{Hello}. - -Nested variable references can also contain modified references and -function invocations (@pxref{Functions, ,Functions for Transforming Text}), -just like any other reference. -For example, using the @code{subst} function -(@pxref{Text Functions, ,Functions for String Substitution and Analysis}): - -@example -@group -x = variable1 -variable2 := Hello -y = $(subst 1,2,$(x)) -z = y -a := $($($(z))) -@end group -@end example - -@noindent -eventually defines @code{a} as @samp{Hello}. It is doubtful that anyone -would ever want to write a nested reference as convoluted as this one, but -it works: @samp{$($($(z)))} expands to @samp{$($(y))} which becomes -@samp{$($(subst 1,2,$(x)))}. This gets the value @samp{variable1} from -@code{x} and changes it by substitution to @samp{variable2}, so that the -entire string becomes @samp{$(variable2)}, a simple variable reference -whose value is @samp{Hello}.@refill - -A computed variable name need not consist entirely of a single variable -reference. It can contain several variable references, as well as some -invariant text. For example, - -@example -@group -a_dirs := dira dirb -1_dirs := dir1 dir2 -@end group - -@group -a_files := filea fileb -1_files := file1 file2 -@end group - -@group -ifeq "$(use_a)" "yes" -a1 := a -else -a1 := 1 -endif -@end group - -@group -ifeq "$(use_dirs)" "yes" -df := dirs -else -df := files -endif - -dirs := $($(a1)_$(df)) -@end group -@end example - -@noindent -will give @code{dirs} the same value as @code{a_dirs}, @code{1_dirs}, -@code{a_files} or @code{1_files} depending on the settings of @code{use_a} -and @code{use_dirs}.@refill - -Computed variable names can also be used in substitution references: - -@example -@group -a_objects := a.o b.o c.o -1_objects := 1.o 2.o 3.o - -sources := $($(a1)_objects:.o=.c) -@end group -@end example - -@noindent -defines @code{sources} as either @samp{a.c b.c c.c} or @samp{1.c 2.c 3.c}, -depending on the value of @code{a1}. - -The only restriction on this sort of use of nested variable references -is that they cannot specify part of the name of a function to be called. -This is because the test for a recognized function name is done before -the expansion of nested references. For example, - -@example -@group -ifdef do_sort -func := sort -else -func := strip -endif -@end group - -@group -bar := a d b g q c -@end group - -@group -foo := $($(func) $(bar)) -@end group -@end example - -@noindent -attempts to give @samp{foo} the value of the variable @samp{sort a d b g -q c} or @samp{strip a d b g q c}, rather than giving @samp{a d b g q c} -as the argument to either the @code{sort} or the @code{strip} function. -This restriction could be removed in the future if that change is shown -to be a good idea. - -You can also use computed variable names in the left-hand side of a -variable assignment, or in a @code{define} directive, as in: - -@example -dir = foo -$(dir)_sources := $(wildcard $(dir)/*.c) -define $(dir)_print -lpr $($(dir)_sources) -endef -@end example - -@noindent -This example defines the variables @samp{dir}, @samp{foo_sources}, and -@samp{foo_print}. - -Note that @dfn{nested variable references} are quite different from -@dfn{recursively expanded variables} -(@pxref{Flavors, ,The Two Flavors of Variables}), though both are -used together in complex ways when doing makefile programming.@refill - -@node Values, Setting, Advanced, Using Variables -@section How Variables Get Their Values -@cindex variables, how they get their values -@cindex value, how a variable gets it - -Variables can get values in several different ways: - -@itemize @bullet -@item -You can specify an overriding value when you run @code{make}. -@xref{Overriding, ,Overriding Variables}. - -@item -You can specify a value in the makefile, either -with an assignment (@pxref{Setting, ,Setting Variables}) or with a -verbatim definition (@pxref{Defining, ,Defining Variables Verbatim}).@refill - -@item -Variables in the environment become @code{make} variables. -@xref{Environment, ,Variables from the Environment}. - -@item -Several @dfn{automatic} variables are given new values for each rule. -Each of these has a single conventional use. -@xref{Automatic, ,Automatic Variables}. - -@item -Several variables have constant initial values. -@xref{Implicit Variables, ,Variables Used by Implicit Rules}. -@end itemize - -@node Setting, Appending, Values, Using Variables -@section Setting Variables -@cindex setting variables -@cindex variables, setting -@cindex = -@cindex := -@cindex ?= - -To set a variable from the makefile, write a line starting with the -variable name followed by @samp{=} or @samp{:=}. Whatever follows the -@samp{=} or @samp{:=} on the line becomes the value. For example, - -@example -objects = main.o foo.o bar.o utils.o -@end example - -@noindent -defines a variable named @code{objects}. Whitespace around the variable -name and immediately after the @samp{=} is ignored. - -Variables defined with @samp{=} are @dfn{recursively expanded} variables. -Variables defined with @samp{:=} are @dfn{simply expanded} variables; these -definitions can contain variable references which will be expanded before -the definition is made. @xref{Flavors, ,The Two Flavors of Variables}. - -The variable name may contain function and variable references, which -are expanded when the line is read to find the actual variable name to use. - -There is no limit on the length of the value of a variable except the -amount of swapping space on the computer. When a variable definition is -long, it is a good idea to break it into several lines by inserting -backslash-newline at convenient places in the definition. This will not -affect the functioning of @code{make}, but it will make the makefile easier -to read. - -Most variable names are considered to have the empty string as a value if -you have never set them. Several variables have built-in initial values -that are not empty, but you can set them in the usual ways -(@pxref{Implicit Variables, ,Variables Used by Implicit Rules}). -Several special variables are set -automatically to a new value for each rule; these are called the -@dfn{automatic} variables (@pxref{Automatic, ,Automatic Variables}). - -If you'd like a variable to be set to a value only if it's not already -set, then you can use the shorthand operator @samp{?=} instead of -@samp{=}. These two settings of the variable @samp{FOO} are identical -(@pxref{Origin Function, ,The @code{origin} Function}): - -@example -FOO ?= bar -@end example - -@noindent -and - -@example -ifeq ($(origin FOO), undefined) -FOO = bar -endif -@end example - -@node Appending, Override Directive, Setting, Using Variables -@section Appending More Text to Variables -@cindex += -@cindex appending to variables -@cindex variables, appending to - -Often it is useful to add more text to the value of a variable already defined. -You do this with a line containing @samp{+=}, like this: - -@example -objects += another.o -@end example - -@noindent -This takes the value of the variable @code{objects}, and adds the text -@samp{another.o} to it (preceded by a single space). Thus: - -@example -objects = main.o foo.o bar.o utils.o -objects += another.o -@end example - -@noindent -sets @code{objects} to @samp{main.o foo.o bar.o utils.o another.o}. - -Using @samp{+=} is similar to: - -@example -objects = main.o foo.o bar.o utils.o -objects := $(objects) another.o -@end example - -@noindent -but differs in ways that become important when you use more complex values. - -When the variable in question has not been defined before, @samp{+=} -acts just like normal @samp{=}: it defines a recursively-expanded -variable. However, when there @emph{is} a previous definition, exactly -what @samp{+=} does depends on what flavor of variable you defined -originally. @xref{Flavors, ,The Two Flavors of Variables}, for an -explanation of the two flavors of variables. - -When you add to a variable's value with @samp{+=}, @code{make} acts -essentially as if you had included the extra text in the initial -definition of the variable. If you defined it first with @samp{:=}, -making it a simply-expanded variable, @samp{+=} adds to that -simply-expanded definition, and expands the new text before appending it -to the old value just as @samp{:=} does -(@pxref{Setting, ,Setting Variables}, for a full explanation of @samp{:=}). -In fact, - -@example -variable := value -variable += more -@end example - -@noindent -is exactly equivalent to: - -@noindent -@example -variable := value -variable := $(variable) more -@end example - -On the other hand, when you use @samp{+=} with a variable that you defined -first to be recursively-expanded using plain @samp{=}, @code{make} does -something a bit different. Recall that when you define a -recursively-expanded variable, @code{make} does not expand the value you set -for variable and function references immediately. Instead it stores the text -verbatim, and saves these variable and function references to be expanded -later, when you refer to the new variable (@pxref{Flavors, ,The Two Flavors -of Variables}). When you use @samp{+=} on a recursively-expanded variable, -it is this unexpanded text to which @code{make} appends the new text you -specify. - -@example -@group -variable = value -variable += more -@end group -@end example - -@noindent -is roughly equivalent to: - -@example -@group -temp = value -variable = $(temp) more -@end group -@end example - -@noindent -except that of course it never defines a variable called @code{temp}. -The importance of this comes when the variable's old value contains -variable references. Take this common example: - -@example -CFLAGS = $(includes) -O -@dots{} -CFLAGS += -pg # enable profiling -@end example - -@noindent -The first line defines the @code{CFLAGS} variable with a reference to another -variable, @code{includes}. (@code{CFLAGS} is used by the rules for C -compilation; @pxref{Catalogue of Rules, ,Catalogue of Implicit Rules}.) -Using @samp{=} for the definition makes @code{CFLAGS} a recursively-expanded -variable, meaning @w{@samp{$(includes) -O}} is @emph{not} expanded when -@code{make} processes the definition of @code{CFLAGS}. Thus, @code{includes} -need not be defined yet for its value to take effect. It only has to be -defined before any reference to @code{CFLAGS}. If we tried to append to the -value of @code{CFLAGS} without using @samp{+=}, we might do it like this: - -@example -CFLAGS := $(CFLAGS) -pg # enable profiling -@end example - -@noindent -This is pretty close, but not quite what we want. Using @samp{:=} -redefines @code{CFLAGS} as a simply-expanded variable; this means -@code{make} expands the text @w{@samp{$(CFLAGS) -pg}} before setting the -variable. If @code{includes} is not yet defined, we get @w{@samp{ -O --pg}}, and a later definition of @code{includes} will have no effect. -Conversely, by using @samp{+=} we set @code{CFLAGS} to the -@emph{unexpanded} value @w{@samp{$(includes) -O -pg}}. Thus we preserve -the reference to @code{includes}, so if that variable gets defined at -any later point, a reference like @samp{$(CFLAGS)} still uses its -value. - -@node Override Directive, Defining, Appending, Using Variables -@section The @code{override} Directive -@findex override -@cindex overriding with @code{override} -@cindex variables, overriding - -If a variable has been set with a command argument -(@pxref{Overriding, ,Overriding Variables}), -then ordinary assignments in the makefile are ignored. If you want to set -the variable in the makefile even though it was set with a command -argument, you can use an @code{override} directive, which is a line that -looks like this:@refill - -@example -override @var{variable} = @var{value} -@end example - -@noindent -or - -@example -override @var{variable} := @var{value} -@end example - -To append more text to a variable defined on the command line, use: - -@example -override @var{variable} += @var{more text} -@end example - -@noindent -@xref{Appending, ,Appending More Text to Variables}. - -The @code{override} directive was not invented for escalation in the war -between makefiles and command arguments. It was invented so you can alter -and add to values that the user specifies with command arguments. - -For example, suppose you always want the @samp{-g} switch when you run the -C compiler, but you would like to allow the user to specify the other -switches with a command argument just as usual. You could use this -@code{override} directive: - -@example -override CFLAGS += -g -@end example - -You can also use @code{override} directives with @code{define} directives. -This is done as you might expect: - -@example -override define foo -bar -endef -@end example - -@noindent -@iftex -See the next section for information about @code{define}. -@end iftex -@ifinfo -@xref{Defining, ,Defining Variables Verbatim}. -@end ifinfo - -@node Defining, Environment, Override Directive, Using Variables -@section Defining Variables Verbatim -@findex define -@findex endef -@cindex verbatim variable definition -@cindex defining variables verbatim -@cindex variables, defining verbatim - -Another way to set the value of a variable is to use the @code{define} -directive. This directive has an unusual syntax which allows newline -characters to be included in the value, which is convenient for defining -canned sequences of commands -(@pxref{Sequences, ,Defining Canned Command Sequences}). - -The @code{define} directive is followed on the same line by the name of the -variable and nothing more. The value to give the variable appears on the -following lines. The end of the value is marked by a line containing just -the word @code{endef}. Aside from this difference in syntax, @code{define} -works just like @samp{=}: it creates a recursively-expanded variable -(@pxref{Flavors, ,The Two Flavors of Variables}). -The variable name may contain function and variable references, which -are expanded when the directive is read to find the actual variable name -to use. - -@example -define two-lines -echo foo -echo $(bar) -endef -@end example - -The value in an ordinary assignment cannot contain a newline; but the -newlines that separate the lines of the value in a @code{define} become -part of the variable's value (except for the final newline which precedes -the @code{endef} and is not considered part of the value).@refill - -@need 800 -The previous example is functionally equivalent to this: - -@example -two-lines = echo foo; echo $(bar) -@end example - -@noindent -since two commands separated by semicolon behave much like two separate -shell commands. However, note that using two separate lines means -@code{make} will invoke the shell twice, running an independent subshell -for each line. @xref{Execution, ,Command Execution}. - -If you want variable definitions made with @code{define} to take -precedence over command-line variable definitions, you can use the -@code{override} directive together with @code{define}: - -@example -override define two-lines -foo -$(bar) -endef -@end example - -@noindent -@xref{Override Directive, ,The @code{override} Directive}. - -@node Environment, Target-specific, Defining, Using Variables -@section Variables from the Environment - -@cindex variables, environment -@cindex environment -Variables in @code{make} can come from the environment in which -@code{make} is run. Every environment variable that @code{make} sees when -it starts up is transformed into a @code{make} variable with the same name -and value. But an explicit assignment in the makefile, or with a command -argument, overrides the environment. (If the @samp{-e} flag is specified, -then values from the environment override assignments in the makefile. -@xref{Options Summary, ,Summary of Options}. -But this is not recommended practice.) - -Thus, by setting the variable @code{CFLAGS} in your environment, you can -cause all C compilations in most makefiles to use the compiler switches you -prefer. This is safe for variables with standard or conventional meanings -because you know that no makefile will use them for other things. (But -this is not totally reliable; some makefiles set @code{CFLAGS} explicitly -and therefore are not affected by the value in the environment.) - -When @code{make} is invoked recursively, variables defined in the -outer invocation can be passed to inner invocations through the -environment (@pxref{Recursion, ,Recursive Use of @code{make}}). By -default, only variables that came from the environment or the command -line are passed to recursive invocations. You can use the -@code{export} directive to pass other variables. -@xref{Variables/Recursion, , Communicating Variables to a -Sub-@code{make}}, for full details. - -Other use of variables from the environment is not recommended. It is not -wise for makefiles to depend for their functioning on environment variables -set up outside their control, since this would cause different users to get -different results from the same makefile. This is against the whole -purpose of most makefiles. - -Such problems would be especially likely with the variable @code{SHELL}, -which is normally present in the environment to specify the user's choice -of interactive shell. It would be very undesirable for this choice to -affect @code{make}. So @code{make} ignores the environment value of -@code{SHELL} (except on MS-DOS and MS-Windows, where @code{SHELL} is -usually not set. @xref{Execution, ,Special handling of SHELL on -MS-DOS}.)@refill - -@node Target-specific, Pattern-specific, Environment, Using Variables -@section Target-specific Variable Values -@cindex target-specific variables -@cindex variables, target-specific - -Variable values in @code{make} are usually global; that is, they are the -same regardless of where they are evaluated (unless they're reset, of -course). One exception to that is automatic variables -(@pxref{Automatic, ,Automatic Variables}). - -The other exception is @dfn{target-specific variable values}. This -feature allows you to define different values for the same variable, -based on the target that @code{make} is currently building. As with -automatic variables, these values are only available within the context -of a target's command script (and in other target-specific assignments). - -Set a target-specific variable value like this: - -@example -@var{target} @dots{} : @var{variable-assignment} -@end example - -@noindent -or like this: - -@example -@var{target} @dots{} : override @var{variable-assignment} -@end example - -Multiple @var{target} values create a target-specific variable value for -each member of the target list individually. - -The @var{variable-assignment} can be any valid form of assignment; -recursive (@samp{=}), static (@samp{:=}), appending (@samp{+=}), or -conditional (@samp{?=}). All variables that appear within the -@var{variable-assignment} are evaluated within the context of the -target: thus, any previously-defined target-specific variable values -will be in effect. Note that this variable is actually distinct from -any ``global'' value: the two variables do not have to have the same -flavor (recursive vs. static). - -Target-specific variables have the same priority as any other makefile -variable. Variables provided on the command-line (and in the -environment if the @samp{-e} option is in force) will take precedence. -Specifying the @code{override} directive will allow the target-specific -variable value to be preferred. - -There is one more special feature of target-specific variables: when you -define a target-specific variable, that variable value is also in effect -for all prerequisites of this target (unless those prerequisites override -it with their own target-specific variable value). So, for example, a -statement like this: - -@example -prog : CFLAGS = -g -prog : prog.o foo.o bar.o -@end example - -@noindent -will set @code{CFLAGS} to @samp{-g} in the command script for -@file{prog}, but it will also set @code{CFLAGS} to @samp{-g} in the -command scripts that create @file{prog.o}, @file{foo.o}, and -@file{bar.o}, and any command scripts which create their prerequisites. - -@node Pattern-specific, , Target-specific, Using Variables -@section Pattern-specific Variable Values -@cindex pattern-specific variables -@cindex variables, pattern-specific - -In addition to target-specific variable values (@pxref{Target-specific, -,Target-specific Variable Values}), GNU @code{make} supports -pattern-specific variable values. In this form, a variable is defined -for any target that matches the pattern specified. Variables defined in -this way are searched after any target-specific variables defined -explicitly for that target, and before target-specific variables defined -for the parent target. - -Set a pattern-specific variable value like this: - -@example -@var{pattern} @dots{} : @var{variable-assignment} -@end example - -@noindent -or like this: - -@example -@var{pattern} @dots{} : override @var{variable-assignment} -@end example - -@noindent -where @var{pattern} is a %-pattern. As with target-specific variable -values, multiple @var{pattern} values create a pattern-specific variable -value for each pattern individually. The @var{variable-assignment} can -be any valid form of assignment. Any command-line variable setting will -take precedence, unless @code{override} is specified. - -For example: - -@example -%.o : CFLAGS = -O -@end example - -@noindent -will assign @code{CFLAGS} the value of @samp{-O} for all targets -matching the pattern @code{%.o}. - -@node Conditionals, Functions, Using Variables, Top -@chapter Conditional Parts of Makefiles - -@cindex conditionals -A @dfn{conditional} causes part of a makefile to be obeyed or ignored -depending on the values of variables. Conditionals can compare the -value of one variable to another, or the value of a variable to -a constant string. Conditionals control what @code{make} actually -``sees'' in the makefile, so they @emph{cannot} be used to control shell -commands at the time of execution.@refill - -@menu -* Conditional Example:: Example of a conditional -* Conditional Syntax:: The syntax of conditionals. -* Testing Flags:: Conditionals that test flags. -@end menu - -@node Conditional Example, Conditional Syntax, , Conditionals -@section Example of a Conditional - -The following example of a conditional tells @code{make} to use one set -of libraries if the @code{CC} variable is @samp{gcc}, and a different -set of libraries otherwise. It works by controlling which of two -command lines will be used as the command for a rule. The result is -that @samp{CC=gcc} as an argument to @code{make} changes not only which -compiler is used but also which libraries are linked. - -@example -libs_for_gcc = -lgnu -normal_libs = - -foo: $(objects) -ifeq ($(CC),gcc) - $(CC) -o foo $(objects) $(libs_for_gcc) -else - $(CC) -o foo $(objects) $(normal_libs) -endif -@end example - -This conditional uses three directives: one @code{ifeq}, one @code{else} -and one @code{endif}. - -The @code{ifeq} directive begins the conditional, and specifies the -condition. It contains two arguments, separated by a comma and surrounded -by parentheses. Variable substitution is performed on both arguments and -then they are compared. The lines of the makefile following the -@code{ifeq} are obeyed if the two arguments match; otherwise they are -ignored. - -The @code{else} directive causes the following lines to be obeyed if the -previous conditional failed. In the example above, this means that the -second alternative linking command is used whenever the first alternative -is not used. It is optional to have an @code{else} in a conditional. - -The @code{endif} directive ends the conditional. Every conditional must -end with an @code{endif}. Unconditional makefile text follows. - -As this example illustrates, conditionals work at the textual level: -the lines of the conditional are treated as part of the makefile, or -ignored, according to the condition. This is why the larger syntactic -units of the makefile, such as rules, may cross the beginning or the -end of the conditional. - -When the variable @code{CC} has the value @samp{gcc}, the above example has -this effect: - -@example -foo: $(objects) - $(CC) -o foo $(objects) $(libs_for_gcc) -@end example - -@noindent -When the variable @code{CC} has any other value, the effect is this: - -@example -foo: $(objects) - $(CC) -o foo $(objects) $(normal_libs) -@end example - -Equivalent results can be obtained in another way by conditionalizing a -variable assignment and then using the variable unconditionally: - -@example -libs_for_gcc = -lgnu -normal_libs = - -ifeq ($(CC),gcc) - libs=$(libs_for_gcc) -else - libs=$(normal_libs) -endif - -foo: $(objects) - $(CC) -o foo $(objects) $(libs) -@end example - -@node Conditional Syntax, Testing Flags, Conditional Example, Conditionals -@section Syntax of Conditionals -@findex ifdef -@findex ifeq -@findex ifndef -@findex ifneq -@findex else -@findex endif - -The syntax of a simple conditional with no @code{else} is as follows: - -@example -@var{conditional-directive} -@var{text-if-true} -endif -@end example - -@noindent -The @var{text-if-true} may be any lines of text, to be considered as part -of the makefile if the condition is true. If the condition is false, no -text is used instead. - -The syntax of a complex conditional is as follows: - -@example -@var{conditional-directive} -@var{text-if-true} -else -@var{text-if-false} -endif -@end example - -@noindent -If the condition is true, @var{text-if-true} is used; otherwise, -@var{text-if-false} is used instead. The @var{text-if-false} can be any -number of lines of text. - -The syntax of the @var{conditional-directive} is the same whether the -conditional is simple or complex. There are four different directives that -test different conditions. Here is a table of them: - -@table @code -@item ifeq (@var{arg1}, @var{arg2}) -@itemx ifeq '@var{arg1}' '@var{arg2}' -@itemx ifeq "@var{arg1}" "@var{arg2}" -@itemx ifeq "@var{arg1}" '@var{arg2}' -@itemx ifeq '@var{arg1}' "@var{arg2}" -Expand all variable references in @var{arg1} and @var{arg2} and -compare them. If they are identical, the @var{text-if-true} is -effective; otherwise, the @var{text-if-false}, if any, is effective. - -Often you want to test if a variable has a non-empty value. When the -value results from complex expansions of variables and functions, -expansions you would consider empty may actually contain whitespace -characters and thus are not seen as empty. However, you can use the -@code{strip} function (@pxref{Text Functions}) to avoid interpreting -whitespace as a non-empty value. For example: - -@example -@group -ifeq ($(strip $(foo)),) -@var{text-if-empty} -endif -@end group -@end example - -@noindent -will evaluate @var{text-if-empty} even if the expansion of -@code{$(foo)} contains whitespace characters. - -@item ifneq (@var{arg1}, @var{arg2}) -@itemx ifneq '@var{arg1}' '@var{arg2}' -@itemx ifneq "@var{arg1}" "@var{arg2}" -@itemx ifneq "@var{arg1}" '@var{arg2}' -@itemx ifneq '@var{arg1}' "@var{arg2}" -Expand all variable references in @var{arg1} and @var{arg2} and -compare them. If they are different, the @var{text-if-true} is -effective; otherwise, the @var{text-if-false}, if any, is effective. - -@item ifdef @var{variable-name} -If the variable @var{variable-name} has a non-empty value, the -@var{text-if-true} is effective; otherwise, the @var{text-if-false}, -if any, is effective. Variables that have never been defined have an -empty value. - -Note that @code{ifdef} only tests whether a variable has a value. It -does not expand the variable to see if that value is nonempty. -Consequently, tests using @code{ifdef} return true for all definitions -except those like @code{foo =}. To test for an empty value, use -@w{@code{ifeq ($(foo),)}}. For example, - -@example -bar = -foo = $(bar) -ifdef foo -frobozz = yes -else -frobozz = no -endif -@end example - -@noindent -sets @samp{frobozz} to @samp{yes}, while: - -@example -foo = -ifdef foo -frobozz = yes -else -frobozz = no -endif -@end example - -@noindent -sets @samp{frobozz} to @samp{no}. - -@item ifndef @var{variable-name} -If the variable @var{variable-name} has an empty value, the -@var{text-if-true} is effective; otherwise, the @var{text-if-false}, -if any, is effective. -@end table - -Extra spaces are allowed and ignored at the beginning of the conditional -directive line, but a tab is not allowed. (If the line begins with a tab, -it will be considered a command for a rule.) Aside from this, extra spaces -or tabs may be inserted with no effect anywhere except within the directive -name or within an argument. A comment starting with @samp{#} may appear at -the end of the line. - -The other two directives that play a part in a conditional are @code{else} -and @code{endif}. Each of these directives is written as one word, with no -arguments. Extra spaces are allowed and ignored at the beginning of the -line, and spaces or tabs at the end. A comment starting with @samp{#} may -appear at the end of the line. - -Conditionals affect which lines of the makefile @code{make} uses. If -the condition is true, @code{make} reads the lines of the -@var{text-if-true} as part of the makefile; if the condition is false, -@code{make} ignores those lines completely. It follows that syntactic -units of the makefile, such as rules, may safely be split across the -beginning or the end of the conditional.@refill - -@code{make} evaluates conditionals when it reads a makefile. -Consequently, you cannot use automatic variables in the tests of -conditionals because they are not defined until commands are run -(@pxref{Automatic, , Automatic Variables}). - -To prevent intolerable confusion, it is not permitted to start a -conditional in one makefile and end it in another. However, you may -write an @code{include} directive within a conditional, provided you do -not attempt to terminate the conditional inside the included file. - -@node Testing Flags, , Conditional Syntax, Conditionals -@section Conditionals that Test Flags - -You can write a conditional that tests @code{make} command flags such as -@samp{-t} by using the variable @code{MAKEFLAGS} together with the -@code{findstring} function -(@pxref{Text Functions, , Functions for String Substitution and Analysis}). -This is useful when @code{touch} is not enough to make a file appear up -to date. - -The @code{findstring} function determines whether one string appears as a -substring of another. If you want to test for the @samp{-t} flag, -use @samp{t} as the first string and the value of @code{MAKEFLAGS} as -the other. - -For example, here is how to arrange to use @samp{ranlib -t} to finish -marking an archive file up to date: - -@example -archive.a: @dots{} -ifneq (,$(findstring t,$(MAKEFLAGS))) - +touch archive.a - +ranlib -t archive.a -else - ranlib archive.a -endif -@end example - -@noindent -The @samp{+} prefix marks those command lines as ``recursive'' so -that they will be executed despite use of the @samp{-t} flag. -@xref{Recursion, ,Recursive Use of @code{make}}. - -@node Functions, Running, Conditionals, Top -@chapter Functions for Transforming Text -@cindex functions - -@dfn{Functions} allow you to do text processing in the makefile to compute -the files to operate on or the commands to use. You use a function in a -@dfn{function call}, where you give the name of the function and some text -(the @dfn{arguments}) for the function to operate on. The result of the -function's processing is substituted into the makefile at the point of the -call, just as a variable might be substituted. - -@menu -* Syntax of Functions:: How to write a function call. -* Text Functions:: General-purpose text manipulation functions. -* File Name Functions:: Functions for manipulating file names. -* Foreach Function:: Repeat some text with controlled variation. -* If Function:: Conditionally expand a value. -* Call Function:: Expand a user-defined function. -* Origin Function:: Find where a variable got its value. -* Shell Function:: Substitute the output of a shell command. -* Make Control Functions:: Functions that control how make runs. -@end menu - -@node Syntax of Functions, Text Functions, , Functions -@section Function Call Syntax -@cindex @code{$}, in function call -@cindex dollar sign (@code{$}), in function call -@cindex arguments of functions -@cindex functions, syntax of - -A function call resembles a variable reference. It looks like this: - -@example -$(@var{function} @var{arguments}) -@end example - -@noindent -or like this: - -@example -$@{@var{function} @var{arguments}@} -@end example - -Here @var{function} is a function name; one of a short list of names -that are part of @code{make}. You can also essentially create your own -functions by using the @code{call} builtin function. - -The @var{arguments} are the arguments of the function. They are -separated from the function name by one or more spaces or tabs, and if -there is more than one argument, then they are separated by commas. -Such whitespace and commas are not part of an argument's value. The -delimiters which you use to surround the function call, whether -parentheses or braces, can appear in an argument only in matching pairs; -the other kind of delimiters may appear singly. If the arguments -themselves contain other function calls or variable references, it is -wisest to use the same kind of delimiters for all the references; write -@w{@samp{$(subst a,b,$(x))}}, not @w{@samp{$(subst a,b,$@{x@})}}. This -is because it is clearer, and because only one type of delimiter is -matched to find the end of the reference. - -The text written for each argument is processed by substitution of -variables and function calls to produce the argument value, which -is the text on which the function acts. The substitution is done in the -order in which the arguments appear. - -Commas and unmatched parentheses or braces cannot appear in the text of an -argument as written; leading spaces cannot appear in the text of the first -argument as written. These characters can be put into the argument value -by variable substitution. First define variables @code{comma} and -@code{space} whose values are isolated comma and space characters, then -substitute these variables where such characters are wanted, like this: - -@example -@group -comma:= , -empty:= -space:= $(empty) $(empty) -foo:= a b c -bar:= $(subst $(space),$(comma),$(foo)) -# @r{bar is now `a,b,c'.} -@end group -@end example - -@noindent -Here the @code{subst} function replaces each space with a comma, through -the value of @code{foo}, and substitutes the result. - -@node Text Functions, File Name Functions, Syntax of Functions, Functions -@section Functions for String Substitution and Analysis -@cindex functions, for text - -Here are some functions that operate on strings: - -@table @code -@item $(subst @var{from},@var{to},@var{text}) -@findex subst -Performs a textual replacement on the text @var{text}: each occurrence -of @var{from} is replaced by @var{to}. The result is substituted for -the function call. For example, - -@example -$(subst ee,EE,feet on the street) -@end example - -substitutes the string @samp{fEEt on the strEEt}. - -@item $(patsubst @var{pattern},@var{replacement},@var{text}) -@findex patsubst -Finds whitespace-separated words in @var{text} that match -@var{pattern} and replaces them with @var{replacement}. Here -@var{pattern} may contain a @samp{%} which acts as a wildcard, -matching any number of any characters within a word. If -@var{replacement} also contains a @samp{%}, the @samp{%} is replaced -by the text that matched the @samp{%} in @var{pattern}. Only the first -@samp{%} in the @var{pattern} and @var{replacement} is treated this -way; any subsequent @samp{%} is unchanged.@refill - -@cindex @code{%}, quoting in @code{patsubst} -@cindex @code{%}, quoting with @code{\} (backslash) -@cindex @code{\} (backslash), to quote @code{%} -@cindex backslash (@code{\}), to quote @code{%} -@cindex quoting @code{%}, in @code{patsubst} -@samp{%} characters in @code{patsubst} function invocations can be -quoted with preceding backslashes (@samp{\}). Backslashes that would -otherwise quote @samp{%} characters can be quoted with more backslashes. -Backslashes that quote @samp{%} characters or other backslashes are -removed from the pattern before it is compared file names or has a stem -substituted into it. Backslashes that are not in danger of quoting -@samp{%} characters go unmolested. For example, the pattern -@file{the\%weird\\%pattern\\} has @samp{the%weird\} preceding the -operative @samp{%} character, and @samp{pattern\\} following it. The -final two backslashes are left alone because they cannot affect any -@samp{%} character.@refill - -Whitespace between words is folded into single space characters; -leading and trailing whitespace is discarded. - -For example, - -@example -$(patsubst %.c,%.o,x.c.c bar.c) -@end example - -@noindent -produces the value @samp{x.c.o bar.o}. - -Substitution references (@pxref{Substitution Refs, ,Substitution -References}) are a simpler way to get the effect of the @code{patsubst} -function: - -@example -$(@var{var}:@var{pattern}=@var{replacement}) -@end example - -@noindent -is equivalent to - -@example -$(patsubst @var{pattern},@var{replacement},$(@var{var})) -@end example - -The second shorthand simplifies one of the most common uses of -@code{patsubst}: replacing the suffix at the end of file names. - -@example -$(@var{var}:@var{suffix}=@var{replacement}) -@end example - -@noindent -is equivalent to - -@example -$(patsubst %@var{suffix},%@var{replacement},$(@var{var})) -@end example - -@noindent -For example, you might have a list of object files: - -@example -objects = foo.o bar.o baz.o -@end example - -@noindent -To get the list of corresponding source files, you could simply write: - -@example -$(objects:.o=.c) -@end example - -@noindent -instead of using the general form: - -@example -$(patsubst %.o,%.c,$(objects)) -@end example - -@item $(strip @var{string}) -@cindex stripping whitespace -@cindex whitespace, stripping -@cindex spaces, stripping -@findex strip -Removes leading and trailing whitespace from @var{string} and replaces -each internal sequence of one or more whitespace characters with a -single space. Thus, @samp{$(strip a b c )} results in @w{@samp{a b c}}. - -The function @code{strip} can be very useful when used in conjunction -with conditionals. When comparing something with the empty string -@samp{} using @code{ifeq} or @code{ifneq}, you usually want a string of -just whitespace to match the empty string (@pxref{Conditionals}). - -Thus, the following may fail to have the desired results: - -@example -.PHONY: all -ifneq "$(needs_made)" "" -all: $(needs_made) -else -all:;@@echo 'Nothing to make!' -endif -@end example - -@noindent -Replacing the variable reference @w{@samp{$(needs_made)}} with the -function call @w{@samp{$(strip $(needs_made))}} in the @code{ifneq} -directive would make it more robust.@refill - -@item $(findstring @var{find},@var{in}) -@findex findstring -@cindex searching for strings -@cindex finding strings -@cindex strings, searching for -Searches @var{in} for an occurrence of @var{find}. If it occurs, the -value is @var{find}; otherwise, the value is empty. You can use this -function in a conditional to test for the presence of a specific -substring in a given string. Thus, the two examples, - -@example -$(findstring a,a b c) -$(findstring a,b c) -@end example - -@noindent -produce the values @samp{a} and @samp{} (the empty string), -respectively. @xref{Testing Flags}, for a practical application of -@code{findstring}.@refill - -@need 750 -@findex filter -@cindex filtering words -@cindex words, filtering -@item $(filter @var{pattern}@dots{},@var{text}) -Returns all whitespace-separated words in @var{text} that @emph{do} match -any of the @var{pattern} words, removing any words that @emph{do not} -match. The patterns are written using @samp{%}, just like the patterns -used in the @code{patsubst} function above.@refill - -The @code{filter} function can be used to separate out different types -of strings (such as file names) in a variable. For example: - -@example -sources := foo.c bar.c baz.s ugh.h -foo: $(sources) - cc $(filter %.c %.s,$(sources)) -o foo -@end example - -@noindent -says that @file{foo} depends of @file{foo.c}, @file{bar.c}, -@file{baz.s} and @file{ugh.h} but only @file{foo.c}, @file{bar.c} and -@file{baz.s} should be specified in the command to the -compiler.@refill - -@item $(filter-out @var{pattern}@dots{},@var{text}) -@findex filter-out -@cindex filtering out words -@cindex words, filtering out -Returns all whitespace-separated words in @var{text} that @emph{do not} -match any of the @var{pattern} words, removing the words that @emph{do} -match one or more. This is the exact opposite of the @code{filter} -function.@refill - -Removes all whitespace-separated words in @var{text} that @emph{do} -match the @var{pattern} words, returning only the words that @emph{do -not} match. This is the exact opposite of the @code{filter} -function.@refill - -For example, given: - -@example -@group -objects=main1.o foo.o main2.o bar.o -mains=main1.o main2.o -@end group -@end example - -@noindent -the following generates a list which contains all the object files not -in @samp{mains}: - -@example -$(filter-out $(mains),$(objects)) -@end example - -@need 1500 -@findex sort -@cindex sorting words -@item $(sort @var{list}) -Sorts the words of @var{list} in lexical order, removing duplicate -words. The output is a list of words separated by single spaces. -Thus, - -@example -$(sort foo bar lose) -@end example - -@noindent -returns the value @samp{bar foo lose}. - -@cindex removing duplicate words -@cindex duplicate words, removing -@cindex words, removing duplicates -Incidentally, since @code{sort} removes duplicate words, you can use -it for this purpose even if you don't care about the sort order. -@end table - -Here is a realistic example of the use of @code{subst} and -@code{patsubst}. Suppose that a makefile uses the @code{VPATH} variable -to specify a list of directories that @code{make} should search for -prerequisite files -(@pxref{General Search, , @code{VPATH} Search Path for All Prerequisites}). -This example shows how to -tell the C compiler to search for header files in the same list of -directories.@refill - -The value of @code{VPATH} is a list of directories separated by colons, -such as @samp{src:../headers}. First, the @code{subst} function is used to -change the colons to spaces: - -@example -$(subst :, ,$(VPATH)) -@end example - -@noindent -This produces @samp{src ../headers}. Then @code{patsubst} is used to turn -each directory name into a @samp{-I} flag. These can be added to the -value of the variable @code{CFLAGS}, which is passed automatically to the C -compiler, like this: - -@example -override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH))) -@end example - -@noindent -The effect is to append the text @samp{-Isrc -I../headers} to the -previously given value of @code{CFLAGS}. The @code{override} directive is -used so that the new value is assigned even if the previous value of -@code{CFLAGS} was specified with a command argument (@pxref{Override -Directive, , The @code{override} Directive}). - -@node File Name Functions, Foreach Function, Text Functions, Functions -@section Functions for File Names -@cindex functions, for file names -@cindex file name functions - -Several of the built-in expansion functions relate specifically to -taking apart file names or lists of file names. - -Each of the following functions performs a specific transformation on a -file name. The argument of the function is regarded as a series of file -names, separated by whitespace. (Leading and trailing whitespace is -ignored.) Each file name in the series is transformed in the same way and -the results are concatenated with single spaces between them. - -@table @code -@item $(dir @var{names}@dots{}) -@findex dir -@cindex directory part -@cindex file name, directory part -Extracts the directory-part of each file name in @var{names}. The -directory-part of the file name is everything up through (and -including) the last slash in it. If the file name contains no slash, -the directory part is the string @samp{./}. For example, - -@example -$(dir src/foo.c hacks) -@end example - -@noindent -produces the result @samp{src/ ./}. - -@item $(notdir @var{names}@dots{}) -@findex notdir -@cindex file name, nondirectory part -@cindex nondirectory part -Extracts all but the directory-part of each file name in @var{names}. -If the file name contains no slash, it is left unchanged. Otherwise, -everything through the last slash is removed from it. - -A file name that ends with a slash becomes an empty string. This is -unfortunate, because it means that the result does not always have the -same number of whitespace-separated file names as the argument had; -but we do not see any other valid alternative. - -For example, - -@example -$(notdir src/foo.c hacks) -@end example - -@noindent -produces the result @samp{foo.c hacks}. - -@item $(suffix @var{names}@dots{}) -@findex suffix -@cindex suffix, function to find -@cindex file name suffix -Extracts the suffix of each file name in @var{names}. If the file name -contains a period, the suffix is everything starting with the last -period. Otherwise, the suffix is the empty string. This frequently -means that the result will be empty when @var{names} is not, and if -@var{names} contains multiple file names, the result may contain fewer -file names. - -For example, - -@example -$(suffix src/foo.c src-1.0/bar.c hacks) -@end example - -@noindent -produces the result @samp{.c .c}. - -@item $(basename @var{names}@dots{}) -@findex basename -@cindex basename -@cindex file name, basename of -Extracts all but the suffix of each file name in @var{names}. If the -file name contains a period, the basename is everything starting up to -(and not including) the last period. Periods in the directory part are -ignored. If there is no period, the basename is the entire file name. -For example, - -@example -$(basename src/foo.c src-1.0/bar hacks) -@end example - -@noindent -produces the result @samp{src/foo src-1.0/bar hacks}. - -@c plural convention with dots (be consistent) -@item $(addsuffix @var{suffix},@var{names}@dots{}) -@findex addsuffix -@cindex suffix, adding -@cindex file name suffix, adding -The argument @var{names} is regarded as a series of names, separated -by whitespace; @var{suffix} is used as a unit. The value of -@var{suffix} is appended to the end of each individual name and the -resulting larger names are concatenated with single spaces between -them. For example, - -@example -$(addsuffix .c,foo bar) -@end example - -@noindent -produces the result @samp{foo.c bar.c}. - -@item $(addprefix @var{prefix},@var{names}@dots{}) -@findex addprefix -@cindex prefix, adding -@cindex file name prefix, adding -The argument @var{names} is regarded as a series of names, separated -by whitespace; @var{prefix} is used as a unit. The value of -@var{prefix} is prepended to the front of each individual name and the -resulting larger names are concatenated with single spaces between -them. For example, - -@example -$(addprefix src/,foo bar) -@end example - -@noindent -produces the result @samp{src/foo src/bar}. - -@item $(join @var{list1},@var{list2}) -@findex join -@cindex joining lists of words -@cindex words, joining lists -Concatenates the two arguments word by word: the two first words (one -from each argument) concatenated form the first word of the result, the -two second words form the second word of the result, and so on. So the -@var{n}th word of the result comes from the @var{n}th word of each -argument. If one argument has more words that the other, the extra -words are copied unchanged into the result. - -For example, @samp{$(join a b,.c .o)} produces @samp{a.c b.o}. - -Whitespace between the words in the lists is not preserved; it is -replaced with a single space. - -This function can merge the results of the @code{dir} and -@code{notdir} functions, to produce the original list of files which -was given to those two functions.@refill - -@item $(word @var{n},@var{text}) -@findex word -@cindex word, selecting a -@cindex selecting a word -Returns the @var{n}th word of @var{text}. The legitimate values of -@var{n} start from 1. If @var{n} is bigger than the number of words -in @var{text}, the value is empty. For example, - -@example -$(word 2, foo bar baz) -@end example - -@noindent -returns @samp{bar}. - -@item $(wordlist @var{s},@var{e},@var{text}) -@findex wordlist -@cindex words, selecting lists of -@cindex selecting word lists -Returns the list of words in @var{text} starting with word @var{s} and -ending with word @var{e} (inclusive). The legitimate values of @var{s} -and @var{e} start from 1. If @var{s} is bigger than the number of words -in @var{text}, the value is empty. If @var{e} is bigger than the number -of words in @var{text}, words up to the end of @var{text} are returned. -If @var{s} is greater than @var{e}, nothing is returned. For example, - -@example -$(wordlist 2, 3, foo bar baz) -@end example - -@noindent -returns @samp{bar baz}. - -@c Following item phrased to prevent overfull hbox. --RJC 17 Jul 92 -@item $(words @var{text}) -@findex words -@cindex words, finding number -Returns the number of words in @var{text}. -Thus, the last word of @var{text} is -@w{@code{$(word $(words @var{text}),@var{text})}}.@refill - -@item $(firstword @var{names}@dots{}) -@findex firstword -@cindex words, extracting first -The argument @var{names} is regarded as a series of names, separated -by whitespace. The value is the first name in the series. The rest -of the names are ignored. - -For example, - -@example -$(firstword foo bar) -@end example - -@noindent -produces the result @samp{foo}. Although @code{$(firstword -@var{text})} is the same as @code{$(word 1,@var{text})}, the -@code{firstword} function is retained for its simplicity.@refill - -@item $(wildcard @var{pattern}) -@findex wildcard -@cindex wildcard, function -The argument @var{pattern} is a file name pattern, typically containing -wildcard characters (as in shell file name patterns). The result of -@code{wildcard} is a space-separated list of the names of existing files -that match the pattern. -@xref{Wildcards, ,Using Wildcard Characters in File Names}. -@end table - -@node Foreach Function, If Function, File Name Functions, Functions -@section The @code{foreach} Function -@findex foreach -@cindex words, iterating over - -The @code{foreach} function is very different from other functions. It -causes one piece of text to be used repeatedly, each time with a different -substitution performed on it. It resembles the @code{for} command in the -shell @code{sh} and the @code{foreach} command in the C-shell @code{csh}. - -The syntax of the @code{foreach} function is: - -@example -$(foreach @var{var},@var{list},@var{text}) -@end example - -@noindent -The first two arguments, @var{var} and @var{list}, are expanded before -anything else is done; note that the last argument, @var{text}, is -@strong{not} expanded at the same time. Then for each word of the expanded -value of @var{list}, the variable named by the expanded value of @var{var} -is set to that word, and @var{text} is expanded. Presumably @var{text} -contains references to that variable, so its expansion will be different -each time. - -The result is that @var{text} is expanded as many times as there are -whitespace-separated words in @var{list}. The multiple expansions of -@var{text} are concatenated, with spaces between them, to make the result -of @code{foreach}. - -This simple example sets the variable @samp{files} to the list of all files -in the directories in the list @samp{dirs}: - -@example -dirs := a b c d -files := $(foreach dir,$(dirs),$(wildcard $(dir)/*)) -@end example - -Here @var{text} is @samp{$(wildcard $(dir)/*)}. The first repetition -finds the value @samp{a} for @code{dir}, so it produces the same result -as @samp{$(wildcard a/*)}; the second repetition produces the result -of @samp{$(wildcard b/*)}; and the third, that of @samp{$(wildcard c/*)}. - -This example has the same result (except for setting @samp{dirs}) as -the following example: - -@example -files := $(wildcard a/* b/* c/* d/*) -@end example - -When @var{text} is complicated, you can improve readability by giving it -a name, with an additional variable: - -@example -find_files = $(wildcard $(dir)/*) -dirs := a b c d -files := $(foreach dir,$(dirs),$(find_files)) -@end example - -@noindent -Here we use the variable @code{find_files} this way. We use plain @samp{=} -to define a recursively-expanding variable, so that its value contains an -actual function call to be reexpanded under the control of @code{foreach}; -a simply-expanded variable would not do, since @code{wildcard} would be -called only once at the time of defining @code{find_files}. - -The @code{foreach} function has no permanent effect on the variable -@var{var}; its value and flavor after the @code{foreach} function call are -the same as they were beforehand. The other values which are taken from -@var{list} are in effect only temporarily, during the execution of -@code{foreach}. The variable @var{var} is a simply-expanded variable -during the execution of @code{foreach}. If @var{var} was undefined -before the @code{foreach} function call, it is undefined after the call. -@xref{Flavors, ,The Two Flavors of Variables}.@refill - -You must take care when using complex variable expressions that result in -variable names because many strange things are valid variable names, but -are probably not what you intended. For example, - -@smallexample -files := $(foreach Esta escrito en espanol!,b c ch,$(find_files)) -@end smallexample - -@noindent -might be useful if the value of @code{find_files} references the variable -whose name is @samp{Esta escrito en espanol!} (es un nombre bastante largo, -no?), but it is more likely to be a mistake. - -@node If Function, Call Function, Foreach Function, Functions -@section The @code{if} Function -@findex if -@cindex conditional expansion - -The @code{if} function provides support for conditional expansion in a -functional context (as opposed to the GNU @code{make} makefile -conditionals such as @code{ifeq} (@pxref{Conditional Syntax, ,Syntax of -Conditionals}). - -An @code{if} function call can contain either two or three arguments: - -@example -$(if @var{condition},@var{then-part}[,@var{else-part}]) -@end example - -The first argument, @var{condition}, first has all preceding and -trailing whitespace stripped, then is expanded. If it expands to any -non-empty string, then the condition is considered to be true. If it -expands to an empty string, the condition is considered to be false. - -If the condition is true then the second argument, @var{then-part}, is -evaluated and this is used as the result of the evaluation of the entire -@code{if} function. - -If the condition is false then the third argument, @var{else-part}, is -evaluated and this is the result of the @code{if} function. If there is -no third argument, the @code{if} function evaluates to nothing (the -empty string). - -Note that only one of the @var{then-part} or the @var{else-part} will be -evaluated, never both. Thus, either can contain side-effects (such as -@code{shell} function calls, etc.) - -@node Call Function, Origin Function, If Function, Functions -@section The @code{call} Function -@findex call -@cindex functions, user defined -@cindex user defined functions - -The @code{call} function is unique in that it can be used to create new -parameterized functions. You can write a complex expression as the -value of a variable, then use @code{call} to expand it with different -values. - -The syntax of the @code{call} function is: - -@example -$(call @var{variable},@var{param},@var{param},@dots{}) -@end example - -When @code{make} expands this function, it assigns each @var{param} to -temporary variables @code{$(1)}, @code{$(2)}, etc. The variable -@code{$(0)} will contain @var{variable}. There is no maximum number of -parameter arguments. There is no minimum, either, but it doesn't make -sense to use @code{call} with no parameters. - -Then @var{variable} is expanded as a @code{make} variable in the context -of these temporary assignments. Thus, any reference to @code{$(1)} in -the value of @var{variable} will resolve to the first @var{param} in the -invocation of @code{call}. - -Note that @var{variable} is the @emph{name} of a variable, not a -@emph{reference} to that variable. Therefore you would not normally use -a @samp{$} or parentheses when writing it. (You can, however, use a -variable reference in the name if you want the name not to be a -constant.) - -If @var{variable} is the name of a builtin function, the builtin function -is always invoked (even if a @code{make} variable by that name also -exists). - -The @code{call} function expands the @var{param} arguments before -assigning them to temporary variables. This means that @var{variable} -values containing references to builtin functions that have special -expansion rules, like @code{foreach} or @code{if}, may not work as you -expect. - -Some examples may make this clearer. - -This macro simply reverses its arguments: - -@smallexample -reverse = $(2) $(1) - -foo = $(call reverse,a,b) -@end smallexample - -@noindent -Here @var{foo} will contain @samp{b a}. - -This one is slightly more interesting: it defines a macro to search for -the first instance of a program in @code{PATH}: - -@smallexample -pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) - -LS := $(call pathsearch,ls) -@end smallexample - -@noindent -Now the variable LS contains @code{/bin/ls} or similar. - -The @code{call} function can be nested. Each recursive invocation gets -its own local values for @code{$(1)}, etc. that mask the values of -higher-level @code{call}. For example, here is an implementation of a -@dfn{map} function: - -@smallexample -map = $(foreach a,$(2),$(call $(1),$(a))) -@end smallexample - -Now you can @var{map} a function that normally takes only one argument, -such as @code{origin}, to multiple values in one step: - -@smallexample -o = $(call map,origin,o map MAKE) -@end smallexample - -and end up with @var{o} containing something like @samp{file file default}. - -A final caution: be careful when adding whitespace to the arguments to -@code{call}. As with other functions, any whitespace contained in the -second and subsequent arguments is kept; this can cause strange -effects. It's generally safest to remove all extraneous whitespace when -providing parameters to @code{call}. - - -@node Origin Function, Shell Function, Call Function, Functions -@section The @code{origin} Function -@findex origin -@cindex variables, origin of -@cindex origin of variable - -The @code{origin} function is unlike most other functions in that it does -not operate on the values of variables; it tells you something @emph{about} -a variable. Specifically, it tells you where it came from. - -The syntax of the @code{origin} function is: - -@example -$(origin @var{variable}) -@end example - -Note that @var{variable} is the @emph{name} of a variable to inquire about; -not a @emph{reference} to that variable. Therefore you would not normally -use a @samp{$} or parentheses when writing it. (You can, however, use a -variable reference in the name if you want the name not to be a constant.) - -The result of this function is a string telling you how the variable -@var{variable} was defined: - -@table @samp -@item undefined - -if @var{variable} was never defined. - -@item default - -if @var{variable} has a default definition, as is usual with @code{CC} -and so on. @xref{Implicit Variables, ,Variables Used by Implicit Rules}. -Note that if you have redefined a default variable, the @code{origin} -function will return the origin of the later definition. - -@item environment - -if @var{variable} was defined as an environment variable and the -@samp{-e} option is @emph{not} turned on (@pxref{Options Summary, ,Summary of Options}). - -@item environment override - -if @var{variable} was defined as an environment variable and the -@w{@samp{-e}} option @emph{is} turned on (@pxref{Options Summary, -,Summary of Options}).@refill - -@item file - -if @var{variable} was defined in a makefile. - -@item command line - -if @var{variable} was defined on the command line. - -@item override - -if @var{variable} was defined with an @code{override} directive in a -makefile (@pxref{Override Directive, ,The @code{override} Directive}). - -@item automatic - -if @var{variable} is an automatic variable defined for the -execution of the commands for each rule -(@pxref{Automatic, , Automatic Variables}). -@end table - -This information is primarily useful (other than for your curiosity) to -determine if you want to believe the value of a variable. For example, -suppose you have a makefile @file{foo} that includes another makefile -@file{bar}. You want a variable @code{bletch} to be defined in @file{bar} -if you run the command @w{@samp{make -f bar}}, even if the environment contains -a definition of @code{bletch}. However, if @file{foo} defined -@code{bletch} before including @file{bar}, you do not want to override that -definition. This could be done by using an @code{override} directive in -@file{foo}, giving that definition precedence over the later definition in -@file{bar}; unfortunately, the @code{override} directive would also -override any command line definitions. So, @file{bar} could -include:@refill - -@example -@group -ifdef bletch -ifeq "$(origin bletch)" "environment" -bletch = barf, gag, etc. -endif -endif -@end group -@end example - -@noindent -If @code{bletch} has been defined from the environment, this will redefine -it. - -If you want to override a previous definition of @code{bletch} if it came -from the environment, even under @samp{-e}, you could instead write: - -@example -@group -ifneq "$(findstring environment,$(origin bletch))" "" -bletch = barf, gag, etc. -endif -@end group -@end example - -Here the redefinition takes place if @samp{$(origin bletch)} returns either -@samp{environment} or @samp{environment override}. -@xref{Text Functions, , Functions for String Substitution and Analysis}. - -@node Shell Function, Make Control Functions, Origin Function, Functions -@section The @code{shell} Function -@findex shell -@cindex commands, expansion -@cindex backquotes -@cindex shell command, function for - -The @code{shell} function is unlike any other function except the -@code{wildcard} function -(@pxref{Wildcard Function, ,The Function @code{wildcard}}) in that it -communicates with the world outside of @code{make}. - -The @code{shell} function performs the same function that backquotes -(@samp{`}) perform in most shells: it does @dfn{command expansion}. This -means that it takes an argument that is a shell command and returns the -output of the command. The only processing @code{make} does on the result, -before substituting it into the surrounding text, is to convert each -newline or carriage-return / newline pair to a single space. It also -removes the trailing (carriage-return and) newline, if it's the last -thing in the result.@refill - -The commands run by calls to the @code{shell} function are run when the -function calls are expanded. In most cases, this is when the makefile is -read in. The exception is that function calls in the commands of the rules -are expanded when the commands are run, and this applies to @code{shell} -function calls like all others. - -Here are some examples of the use of the @code{shell} function: - -@example -contents := $(shell cat foo) -@end example - -@noindent -sets @code{contents} to the contents of the file @file{foo}, with a space -(rather than a newline) separating each line. - -@example -files := $(shell echo *.c) -@end example - -@noindent -sets @code{files} to the expansion of @samp{*.c}. Unless @code{make} is -using a very strange shell, this has the same result as -@w{@samp{$(wildcard *.c)}}.@refill - -@node Make Control Functions, , Shell Function, Functions -@section Functions That Control Make -@cindex functions, for controlling make -@cindex controlling make - -These functions control the way make runs. Generally, they are used to -provide information to the user of the makefile or to cause make to stop -if some sort of environmental error is detected. - -@table @code -@item $(error @var{text}@dots{}) -@findex error -@cindex error, stopping on -@cindex stopping make -Generates a fatal error where the message is @var{text}. Note that the -error is generated whenever this function is evaluated. So, if you put -it inside a command script or on the right side of a recursive variable -assignment, it won't be evaluated until later. The @var{text} will be -expanded before the error is generated. - -For example, - -@example -ifdef ERROR1 -$(error error is $(ERROR1)) -endif -@end example - -@noindent -will generate a fatal error during the read of the makefile if the -@code{make} variable @code{ERROR1} is defined. Or, - -@example -ERR = $(error found an error!) - -.PHONY: err -err: ; $(ERR) -@end example - -@noindent -will generate a fatal error while @code{make} is running, if the -@code{err} target is invoked. - -@item $(warning @var{text}@dots{}) -@findex warning -@cindex warnings, printing -@cindex printing user warnings -This function works similarly to the @code{error} function, above, -except that @code{make} doesn't exit. Instead, @var{text} is expanded -and the resulting message is displayed, but processing of the makefile -continues. - -The result of the expansion of this function is the empty string. -@end table - -@node Running, Implicit Rules, Functions, Top -@chapter How to Run @code{make} - -A makefile that says how to recompile a program can be used in more -than one way. The simplest use is to recompile every file that is out -of date. Usually, makefiles are written so that if you run -@code{make} with no arguments, it does just that. - -But you might want to update only some of the files; you might want to use -a different compiler or different compiler options; you might want just to -find out which files are out of date without changing them. - -By giving arguments when you run @code{make}, you can do any of these -things and many others. - -The exit status of @code{make} is always one of three values: -@table @code -@item 0 -The exit status is zero if @code{make} is successful. -@item 2 -The exit status is two if @code{make} encounters any errors. -It will print messages describing the particular errors. -@item 1 -The exit status is one if you use the @samp{-q} flag and @code{make} -determines that some target is not already up to date. -@xref{Instead of Execution, ,Instead of Executing the Commands}. -@end table - -@menu -* Makefile Arguments:: How to specify which makefile to use. -* Goals:: How to use goal arguments to specify which - parts of the makefile to use. -* Instead of Execution:: How to use mode flags to specify what - kind of thing to do with the commands - in the makefile other than simply - execute them. -* Avoiding Compilation:: How to avoid recompiling certain files. -* Overriding:: How to override a variable to specify - an alternate compiler and other things. -* Testing:: How to proceed past some errors, to - test compilation. -* Options Summary:: Summary of Options -@end menu - -@node Makefile Arguments, Goals, , Running -@section Arguments to Specify the Makefile -@cindex @code{--file} -@cindex @code{--makefile} -@cindex @code{-f} - -The way to specify the name of the makefile is with the @samp{-f} or -@samp{--file} option (@samp{--makefile} also works). For example, -@samp{-f altmake} says to use the file @file{altmake} as the makefile. - -If you use the @samp{-f} flag several times and follow each @samp{-f} -with an argument, all the specified files are used jointly as -makefiles. - -If you do not use the @samp{-f} or @samp{--file} flag, the default is -to try @file{GNUmakefile}, @file{makefile}, and @file{Makefile}, in -that order, and use the first of these three which exists or can be made -(@pxref{Makefiles, ,Writing Makefiles}).@refill - -@node Goals, Instead of Execution, Makefile Arguments, Running -@section Arguments to Specify the Goals -@cindex goal, how to specify - -The @dfn{goals} are the targets that @code{make} should strive ultimately -to update. Other targets are updated as well if they appear as -prerequisites of goals, or prerequisites of prerequisites of goals, etc. - -By default, the goal is the first target in the makefile (not counting -targets that start with a period). Therefore, makefiles are usually -written so that the first target is for compiling the entire program or -programs they describe. If the first rule in the makefile has several -targets, only the first target in the rule becomes the default goal, not -the whole list. - -You can specify a different goal or goals with arguments to @code{make}. -Use the name of the goal as an argument. If you specify several goals, -@code{make} processes each of them in turn, in the order you name them. - -Any target in the makefile may be specified as a goal (unless it -starts with @samp{-} or contains an @samp{=}, in which case it will be -parsed as a switch or variable definition, respectively). Even -targets not in the makefile may be specified, if @code{make} can find -implicit rules that say how to make them. - -@cindex @code{MAKECMDGOALS} -@vindex MAKECMDGOALS -@code{Make} will set the special variable @code{MAKECMDGOALS} to the -list of goals you specified on the command line. If no goals were given -on the command line, this variable is empty. Note that this variable -should be used only in special circumstances. - -An example of appropriate use is to avoid including @file{.d} files -during @code{clean} rules (@pxref{Automatic Prerequisites}), so -@code{make} won't create them only to immediately remove them -again:@refill - -@example -@group -sources = foo.c bar.c - -ifneq ($(MAKECMDGOALS),clean) -include $(sources:.c=.d) -endif -@end group -@end example - -One use of specifying a goal is if you want to compile only a part of -the program, or only one of several programs. Specify as a goal each -file that you wish to remake. For example, consider a directory containing -several programs, with a makefile that starts like this: - -@example -.PHONY: all -all: size nm ld ar as -@end example - -If you are working on the program @code{size}, you might want to say -@w{@samp{make size}} so that only the files of that program are recompiled. - -Another use of specifying a goal is to make files that are not normally -made. For example, there may be a file of debugging output, or a -version of the program that is compiled specially for testing, which has -a rule in the makefile but is not a prerequisite of the default goal. - -Another use of specifying a goal is to run the commands associated with -a phony target (@pxref{Phony Targets}) or empty target (@pxref{Empty -Targets, ,Empty Target Files to Record Events}). Many makefiles contain -a phony target named @file{clean} which deletes everything except source -files. Naturally, this is done only if you request it explicitly with -@w{@samp{make clean}}. Following is a list of typical phony and empty -target names. @xref{Standard Targets}, for a detailed list of all the -standard target names which GNU software packages use. - -@table @file -@item all -@cindex @code{all} @r{(standard target)} -Make all the top-level targets the makefile knows about. - -@item clean -@cindex @code{clean} @r{(standard target)} -Delete all files that are normally created by running @code{make}. - -@item mostlyclean -@cindex @code{mostlyclean} @r{(standard target)} -Like @samp{clean}, but may refrain from deleting a few files that people -normally don't want to recompile. For example, the @samp{mostlyclean} -target for GCC does not delete @file{libgcc.a}, because recompiling it -is rarely necessary and takes a lot of time. - -@item distclean -@cindex @code{distclean} @r{(standard target)} -@itemx realclean -@cindex @code{realclean} @r{(standard target)} -@itemx clobber -@cindex @code{clobber} @r{(standard target)} -Any of these targets might be defined to delete @emph{more} files than -@samp{clean} does. For example, this would delete configuration files -or links that you would normally create as preparation for compilation, -even if the makefile itself cannot create these files. - -@item install -@cindex @code{install} @r{(standard target)} -Copy the executable file into a directory that users typically search -for commands; copy any auxiliary files that the executable uses into -the directories where it will look for them. - -@item print -@cindex @code{print} @r{(standard target)} -Print listings of the source files that have changed. - -@item tar -@cindex @code{tar} @r{(standard target)} -Create a tar file of the source files. - -@item shar -@cindex @code{shar} @r{(standard target)} -Create a shell archive (shar file) of the source files. - -@item dist -@cindex @code{dist} @r{(standard target)} -Create a distribution file of the source files. This might -be a tar file, or a shar file, or a compressed version of one of the -above, or even more than one of the above. - -@item TAGS -@cindex @code{TAGS} @r{(standard target)} -Update a tags table for this program. - -@item check -@cindex @code{check} @r{(standard target)} -@itemx test -@cindex @code{test} @r{(standard target)} -Perform self tests on the program this makefile builds. -@end table - -@node Instead of Execution, Avoiding Compilation, Goals, Running -@section Instead of Executing the Commands -@cindex execution, instead of -@cindex commands, instead of executing - -The makefile tells @code{make} how to tell whether a target is up to date, -and how to update each target. But updating the targets is not always -what you want. Certain options specify other activities for @code{make}. - -@comment Extra blank lines make it print better. -@table @samp -@item -n -@itemx --just-print -@itemx --dry-run -@itemx --recon -@cindex @code{--just-print} -@cindex @code{--dry-run} -@cindex @code{--recon} -@cindex @code{-n} - -``No-op''. The activity is to print what commands would be used to make -the targets up to date, but not actually execute them. - -@item -t -@itemx --touch -@cindex @code{--touch} -@cindex touching files -@cindex target, touching -@cindex @code{-t} - -``Touch''. The activity is to mark the targets as up to date without -actually changing them. In other words, @code{make} pretends to compile -the targets but does not really change their contents. - -@item -q -@itemx --question -@cindex @code{--question} -@cindex @code{-q} -@cindex question mode - -``Question''. The activity is to find out silently whether the targets -are up to date already; but execute no commands in either case. In other -words, neither compilation nor output will occur. - -@item -W @var{file} -@itemx --what-if=@var{file} -@itemx --assume-new=@var{file} -@itemx --new-file=@var{file} -@cindex @code{--what-if} -@cindex @code{-W} -@cindex @code{--assume-new} -@cindex @code{--new-file} -@cindex what if -@cindex files, assuming new - -``What if''. Each @samp{-W} flag is followed by a file name. The given -files' modification times are recorded by @code{make} as being the present -time, although the actual modification times remain the same. -You can use the @samp{-W} flag in conjunction with the @samp{-n} flag -to see what would happen if you were to modify specific files.@refill -@end table - -With the @samp{-n} flag, @code{make} prints the commands that it would -normally execute but does not execute them. - -With the @samp{-t} flag, @code{make} ignores the commands in the rules -and uses (in effect) the command @code{touch} for each target that needs to -be remade. The @code{touch} command is also printed, unless @samp{-s} or -@code{.SILENT} is used. For speed, @code{make} does not actually invoke -the program @code{touch}. It does the work directly. - -With the @samp{-q} flag, @code{make} prints nothing and executes no -commands, but the exit status code it returns is zero if and only if the -targets to be considered are already up to date. If the exit status is -one, then some updating needs to be done. If @code{make} encounters an -error, the exit status is two, so you can distinguish an error from a -target that is not up to date. - -It is an error to use more than one of these three flags in the same -invocation of @code{make}. - -The @samp{-n}, @samp{-t}, and @samp{-q} options do not affect command -lines that begin with @samp{+} characters or contain the strings -@samp{$(MAKE)} or @samp{$@{MAKE@}}. Note that only the line containing -the @samp{+} character or the strings @samp{$(MAKE)} or @samp{$@{MAKE@}} -is run regardless of these options. Other lines in the same rule are -not run unless they too begin with @samp{+} or contain @samp{$(MAKE)} or -@samp{$@{MAKE@}} (@xref{MAKE Variable, ,How the @code{MAKE} Variable Works}.) - -The @samp{-W} flag provides two features: - -@itemize @bullet -@item -If you also use the @samp{-n} or @samp{-q} flag, you can see what -@code{make} would do if you were to modify some files. - -@item -Without the @samp{-n} or @samp{-q} flag, when @code{make} is actually -executing commands, the @samp{-W} flag can direct @code{make} to act -as if some files had been modified, without actually modifying the -files.@refill -@end itemize - -Note that the options @samp{-p} and @samp{-v} allow you to obtain other -information about @code{make} or about the makefiles in use -(@pxref{Options Summary, ,Summary of Options}).@refill - -@node Avoiding Compilation, Overriding, Instead of Execution, Running -@section Avoiding Recompilation of Some Files -@cindex @code{-o} -@cindex @code{--old-file} -@cindex @code{--assume-old} -@cindex files, assuming old -@cindex files, avoiding recompilation of -@cindex recompilation, avoiding - -Sometimes you may have changed a source file but you do not want to -recompile all the files that depend on it. For example, suppose you add -a macro or a declaration to a header file that many other files depend -on. Being conservative, @code{make} assumes that any change in the -header file requires recompilation of all dependent files, but you know -that they do not need to be recompiled and you would rather not waste -the time waiting for them to compile. - -If you anticipate the problem before changing the header file, you can -use the @samp{-t} flag. This flag tells @code{make} not to run the -commands in the rules, but rather to mark the target up to date by -changing its last-modification date. You would follow this procedure: - -@enumerate -@item -Use the command @samp{make} to recompile the source files that really -need recompilation. - -@item -Make the changes in the header files. - -@item -Use the command @samp{make -t} to mark all the object files as -up to date. The next time you run @code{make}, the changes in the -header files will not cause any recompilation. -@end enumerate - -If you have already changed the header file at a time when some files -do need recompilation, it is too late to do this. Instead, you can -use the @w{@samp{-o @var{file}}} flag, which marks a specified file as -``old'' (@pxref{Options Summary, ,Summary of Options}). This means -that the file itself will not be remade, and nothing else will be -remade on its account. Follow this procedure: - -@enumerate -@item -Recompile the source files that need compilation for reasons independent -of the particular header file, with @samp{make -o @var{headerfile}}. -If several header files are involved, use a separate @samp{-o} option -for each header file. - -@item -Touch all the object files with @samp{make -t}. -@end enumerate - -@node Overriding, Testing, Avoiding Compilation, Running -@section Overriding Variables -@cindex overriding variables with arguments -@cindex variables, overriding with arguments -@cindex command line variables -@cindex variables, command line - -An argument that contains @samp{=} specifies the value of a variable: -@samp{@var{v}=@var{x}} sets the value of the variable @var{v} to @var{x}. -If you specify a value in this way, all ordinary assignments of the same -variable in the makefile are ignored; we say they have been -@dfn{overridden} by the command line argument. - -The most common way to use this facility is to pass extra flags to -compilers. For example, in a properly written makefile, the variable -@code{CFLAGS} is included in each command that runs the C compiler, so a -file @file{foo.c} would be compiled something like this: - -@example -cc -c $(CFLAGS) foo.c -@end example - -Thus, whatever value you set for @code{CFLAGS} affects each compilation -that occurs. The makefile probably specifies the usual value for -@code{CFLAGS}, like this: - -@example -CFLAGS=-g -@end example - -Each time you run @code{make}, you can override this value if you -wish. For example, if you say @samp{make CFLAGS='-g -O'}, each C -compilation will be done with @samp{cc -c -g -O}. (This illustrates -how you can use quoting in the shell to enclose spaces and other -special characters in the value of a variable when you override it.) - -The variable @code{CFLAGS} is only one of many standard variables that -exist just so that you can change them this way. @xref{Implicit -Variables, , Variables Used by Implicit Rules}, for a complete list. - -You can also program the makefile to look at additional variables of your -own, giving the user the ability to control other aspects of how the -makefile works by changing the variables. - -When you override a variable with a command argument, you can define either -a recursively-expanded variable or a simply-expanded variable. The -examples shown above make a recursively-expanded variable; to make a -simply-expanded variable, write @samp{:=} instead of @samp{=}. But, unless -you want to include a variable reference or function call in the -@emph{value} that you specify, it makes no difference which kind of -variable you create. - -There is one way that the makefile can change a variable that you have -overridden. This is to use the @code{override} directive, which is a line -that looks like this: @samp{override @var{variable} = @var{value}} -(@pxref{Override Directive, ,The @code{override} Directive}). - -@node Testing, Options Summary, Overriding, Running -@section Testing the Compilation of a Program -@cindex testing compilation -@cindex compilation, testing - -Normally, when an error happens in executing a shell command, @code{make} -gives up immediately, returning a nonzero status. No further commands are -executed for any target. The error implies that the goal cannot be -correctly remade, and @code{make} reports this as soon as it knows. - -When you are compiling a program that you have just changed, this is not -what you want. Instead, you would rather that @code{make} try compiling -every file that can be tried, to show you as many compilation errors -as possible. - -@cindex @code{-k} -@cindex @code{--keep-going} -On these occasions, you should use the @samp{-k} or -@samp{--keep-going} flag. This tells @code{make} to continue to -consider the other prerequisites of the pending targets, remaking them -if necessary, before it gives up and returns nonzero status. For -example, after an error in compiling one object file, @samp{make -k} -will continue compiling other object files even though it already -knows that linking them will be impossible. In addition to continuing -after failed shell commands, @samp{make -k} will continue as much as -possible after discovering that it does not know how to make a target -or prerequisite file. This will always cause an error message, but -without @samp{-k}, it is a fatal error (@pxref{Options Summary, -,Summary of Options}).@refill - -The usual behavior of @code{make} assumes that your purpose is to get the -goals up to date; once @code{make} learns that this is impossible, it might -as well report the failure immediately. The @samp{-k} flag says that the -real purpose is to test as much as possible of the changes made in the -program, perhaps to find several independent problems so that you can -correct them all before the next attempt to compile. This is why Emacs' -@kbd{M-x compile} command passes the @samp{-k} flag by default. - -@node Options Summary, , Testing, Running -@section Summary of Options -@cindex options -@cindex flags -@cindex switches - -Here is a table of all the options @code{make} understands: - -@table @samp -@item -b -@cindex @code{-b} -@itemx -m -@cindex @code{-m} -These options are ignored for compatibility with other versions of @code{make}. - -@item -C @var{dir} -@cindex @code{-C} -@itemx --directory=@var{dir} -@cindex @code{--directory} -Change to directory @var{dir} before reading the makefiles. If multiple -@samp{-C} options are specified, each is interpreted relative to the -previous one: @samp{-C / -C etc} is equivalent to @samp{-C /etc}. -This is typically used with recursive invocations of @code{make} -(@pxref{Recursion, ,Recursive Use of @code{make}}). - -@item -d -@cindex @code{-d} -@c Extra blank line here makes the table look better. - -Print debugging information in addition to normal processing. The -debugging information says which files are being considered for -remaking, which file-times are being compared and with what results, -which files actually need to be remade, which implicit rules are -considered and which are applied---everything interesting about how -@code{make} decides what to do. The @code{-d} option is equivalent to -@samp{--debug=a} (see below). - -@item --debug[=@var{options}] -@cindex @code{--debug} -@c Extra blank line here makes the table look better. - -Print debugging information in addition to normal processing. Various -levels and types of output can be chosen. With no arguments, print the -``basic'' level of debugging. Possible arguments are below; only the -first character is considered, and values must be comma- or -space-separated. - -@table @code -@item a (@i{all}) -All types of debugging output are enabled. This is equivalent to using -@samp{-d}. - -@item b (@i{basic}) -Basic debugging prints each target that was found to be out-of-date, and -whether the build was successful or not. - -@item v (@i{verbose}) -A level above @samp{basic}; includes messages about which makefiles were -parsed, prerequisites that did not need to be rebuilt, etc. This option -also enables @samp{basic} messages. - -@item i (@i{implicit}) -Prints messages describing the implicit rule searches for each target. -This option also enables @samp{basic} messages. - -@item j (@i{jobs}) -Prints messages giving details on the invocation of specific subcommands. - -@item m (@i{makefile}) -By default, the above messages are not enabled while trying to remake -the makefiles. This option enables messages while rebuilding makefiles, -too. Note that the @samp{all} option does enable this option. This -option also enables @samp{basic} messages. -@end table - -@item -e -@cindex @code{-e} -@itemx --environment-overrides -@cindex @code{--environment-overrides} -Give variables taken from the environment precedence -over variables from makefiles. -@xref{Environment, ,Variables from the Environment}. - -@item -f @var{file} -@cindex @code{-f} -@itemx --file=@var{file} -@cindex @code{--file} -@itemx --makefile=@var{file} -@cindex @code{--makefile} -Read the file named @var{file} as a makefile. -@xref{Makefiles, ,Writing Makefiles}. - -@item -h -@cindex @code{-h} -@itemx --help -@cindex @code{--help} -@c Extra blank line here makes the table look better. - -Remind you of the options that @code{make} understands and then exit. - -@item -i -@cindex @code{-i} -@itemx --ignore-errors -@cindex @code{--ignore-errors} -Ignore all errors in commands executed to remake files. -@xref{Errors, ,Errors in Commands}. - -@item -I @var{dir} -@cindex @code{-I} -@itemx --include-dir=@var{dir} -@cindex @code{--include-dir} -Specifies a directory @var{dir} to search for included makefiles. -@xref{Include, ,Including Other Makefiles}. If several @samp{-I} -options are used to specify several directories, the directories are -searched in the order specified. - -@item -j [@var{jobs}] -@cindex @code{-j} -@itemx --jobs[=@var{jobs}] -@cindex @code{--jobs} -Specifies the number of jobs (commands) to run simultaneously. With no -argument, @code{make} runs as many jobs simultaneously as possible. If -there is more than one @samp{-j} option, the last one is effective. -@xref{Parallel, ,Parallel Execution}, -for more information on how commands are run. -Note that this option is ignored on MS-DOS. - -@item -k -@cindex @code{-k} -@itemx --keep-going -@cindex @code{--keep-going} -Continue as much as possible after an error. While the target that -failed, and those that depend on it, cannot be remade, the other -prerequisites of these targets can be processed all the same. -@xref{Testing, ,Testing the Compilation of a Program}. - -@item -l [@var{load}] -@cindex @code{-l} -@itemx --load-average[=@var{load}] -@cindex @code{--load-average} -@itemx --max-load[=@var{load}] -@cindex @code{--max-load} -Specifies that no new jobs (commands) should be started if there are -other jobs running and the load average is at least @var{load} (a -floating-point number). With no argument, removes a previous load -limit. @xref{Parallel, ,Parallel Execution}. - -@item -n -@cindex @code{-n} -@itemx --just-print -@cindex @code{--just-print} -@itemx --dry-run -@cindex @code{--dry-run} -@itemx --recon -@cindex @code{--recon} -@c Extra blank line here makes the table look better. - -Print the commands that would be executed, but do not execute them. -@xref{Instead of Execution, ,Instead of Executing the Commands}. - -@item -o @var{file} -@cindex @code{-o} -@itemx --old-file=@var{file} -@cindex @code{--old-file} -@itemx --assume-old=@var{file} -@cindex @code{--assume-old} -Do not remake the file @var{file} even if it is older than its -prerequisites, and do not remake anything on account of changes in -@var{file}. Essentially the file is treated as very old and its rules -are ignored. @xref{Avoiding Compilation, ,Avoiding Recompilation of -Some Files}.@refill - -@item -p -@cindex @code{-p} -@itemx --print-data-base -@cindex @code{--print-data-base} -@cindex data base of @code{make} rules -@cindex predefined rules and variables, printing -Print the data base (rules and variable values) that results from -reading the makefiles; then execute as usual or as otherwise specified. -This also prints the version information given by the @samp{-v} switch -(see below). To print the data base without trying to remake any files, -use @w{@samp{make -qp}}. To print the data base of predefined rules and -variables, use @w{@samp{make -p -f /dev/null}}. The data base output -contains filename and linenumber information for command and variable -definitions, so it can be a useful debugging tool in complex environments. - -@item -q -@cindex @code{-q} -@itemx --question -@cindex @code{--question} -``Question mode''. Do not run any commands, or print anything; just -return an exit status that is zero if the specified targets are already -up to date, one if any remaking is required, or two if an error is -encountered. @xref{Instead of Execution, ,Instead of Executing the -Commands}.@refill - -@item -r -@cindex @code{-r} -@itemx --no-builtin-rules -@cindex @code{--no-builtin-rules} -Eliminate use of the built-in implicit rules (@pxref{Implicit Rules, -,Using Implicit Rules}). You can still define your own by writing -pattern rules (@pxref{Pattern Rules, ,Defining and Redefining Pattern -Rules}). The @samp{-r} option also clears out the default list of -suffixes for suffix rules (@pxref{Suffix Rules, ,Old-Fashioned Suffix -Rules}). But you can still define your own suffixes with a rule for -@code{.SUFFIXES}, and then define your own suffix rules. Note that only -@emph{rules} are affected by the @code{-r} option; default variables -remain in effect (@pxref{Implicit Variables, ,Variables Used by Implicit -Rules}); see the @samp{-R} option below. - -@item -R -@cindex @code{-R} -@itemx --no-builtin-variables -@cindex @code{--no-builtin-variables} -Eliminate use of the built-in rule-specific variables (@pxref{Implicit -Variables, ,Variables Used by Implicit Rules}). You can still define -your own, of course. The @samp{-R} option also automatically enables -the @samp{-r} option (see above), since it doesn't make sense to have -implicit rules without any definitions for the variables that they use. - -@item -s -@cindex @code{-s} -@itemx --silent -@cindex @code{--silent} -@itemx --quiet -@cindex @code{--quiet} -@c Extra blank line here makes the table look better. - -Silent operation; do not print the commands as they are executed. -@xref{Echoing, ,Command Echoing}. - -@item -S -@cindex @code{-S} -@itemx --no-keep-going -@cindex @code{--no-keep-going} -@itemx --stop -@cindex @code{--stop} -@c Extra blank line here makes the table look better. - -Cancel the effect of the @samp{-k} option. This is never necessary -except in a recursive @code{make} where @samp{-k} might be inherited -from the top-level @code{make} via @code{MAKEFLAGS} -(@pxref{Recursion, ,Recursive Use of @code{make}}) -or if you set @samp{-k} in @code{MAKEFLAGS} in your environment.@refill - -@item -t -@cindex @code{-t} -@itemx --touch -@cindex @code{--touch} -@c Extra blank line here makes the table look better. - -Touch files (mark them up to date without really changing them) -instead of running their commands. This is used to pretend that the -commands were done, in order to fool future invocations of -@code{make}. @xref{Instead of Execution, ,Instead of Executing the Commands}. - -@item -v -@cindex @code{-v} -@itemx --version -@cindex @code{--version} -Print the version of the @code{make} program plus a copyright, a list -of authors, and a notice that there is no warranty; then exit. - -@item -w -@cindex @code{-w} -@itemx --print-directory -@cindex @code{--print-directory} -Print a message containing the working directory both before and after -executing the makefile. This may be useful for tracking down errors -from complicated nests of recursive @code{make} commands. -@xref{Recursion, ,Recursive Use of @code{make}}. (In practice, you -rarely need to specify this option since @samp{make} does it for you; -see @ref{-w Option, ,The @samp{--print-directory} Option}.) - -@itemx --no-print-directory -@cindex @code{--no-print-directory} -Disable printing of the working directory under @code{-w}. -This option is useful when @code{-w} is turned on automatically, -but you do not want to see the extra messages. -@xref{-w Option, ,The @samp{--print-directory} Option}. - -@item -W @var{file} -@cindex @code{-W} -@itemx --what-if=@var{file} -@cindex @code{--what-if} -@itemx --new-file=@var{file} -@cindex @code{--new-file} -@itemx --assume-new=@var{file} -@cindex @code{--assume-new} -Pretend that the target @var{file} has just been modified. When used -with the @samp{-n} flag, this shows you what would happen if you were -to modify that file. Without @samp{-n}, it is almost the same as -running a @code{touch} command on the given file before running -@code{make}, except that the modification time is changed only in the -imagination of @code{make}. -@xref{Instead of Execution, ,Instead of Executing the Commands}. - -@item --warn-undefined-variables -@cindex @code{--warn-undefined-variables} -@cindex variables, warning for undefined -@cindex undefined variables, warning message -Issue a warning message whenever @code{make} sees a reference to an -undefined variable. This can be helpful when you are trying to debug -makefiles which use variables in complex ways. -@end table - -@node Implicit Rules, Archives, Running, Top -@chapter Using Implicit Rules -@cindex implicit rule -@cindex rule, implicit - -Certain standard ways of remaking target files are used very often. For -example, one customary way to make an object file is from a C source file -using the C compiler, @code{cc}. - -@dfn{Implicit rules} tell @code{make} how to use customary techniques so -that you do not have to specify them in detail when you want to use -them. For example, there is an implicit rule for C compilation. File -names determine which implicit rules are run. For example, C -compilation typically takes a @file{.c} file and makes a @file{.o} file. -So @code{make} applies the implicit rule for C compilation when it sees -this combination of file name endings.@refill - -A chain of implicit rules can apply in sequence; for example, @code{make} -will remake a @file{.o} file from a @file{.y} file by way of a @file{.c} file. -@iftex -@xref{Chained Rules, ,Chains of Implicit Rules}. -@end iftex - -The built-in implicit rules use several variables in their commands so -that, by changing the values of the variables, you can change the way the -implicit rule works. For example, the variable @code{CFLAGS} controls the -flags given to the C compiler by the implicit rule for C compilation. -@iftex -@xref{Implicit Variables, ,Variables Used by Implicit Rules}. -@end iftex - -You can define your own implicit rules by writing @dfn{pattern rules}. -@iftex -@xref{Pattern Rules, ,Defining and Redefining Pattern Rules}. -@end iftex - -@dfn{Suffix rules} are a more limited way to define implicit rules. -Pattern rules are more general and clearer, but suffix rules are -retained for compatibility. -@iftex -@xref{Suffix Rules, ,Old-Fashioned Suffix Rules}. -@end iftex - -@menu -* Using Implicit:: How to use an existing implicit rule - to get the commands for updating a file. -* Catalogue of Rules:: A list of built-in implicit rules. -* Implicit Variables:: How to change what predefined rules do. -* Chained Rules:: How to use a chain of implicit rules. -* Pattern Rules:: How to define new implicit rules. -* Last Resort:: How to defining commands for rules - which cannot find any. -* Suffix Rules:: The old-fashioned style of implicit rule. -* Implicit Rule Search:: The precise algorithm for applying - implicit rules. -@end menu - -@node Using Implicit, Catalogue of Rules, , Implicit Rules -@section Using Implicit Rules -@cindex implicit rule, how to use -@cindex rule, implicit, how to use - -To allow @code{make} to find a customary method for updating a target file, -all you have to do is refrain from specifying commands yourself. Either -write a rule with no command lines, or don't write a rule at all. Then -@code{make} will figure out which implicit rule to use based on which -kind of source file exists or can be made. - -For example, suppose the makefile looks like this: - -@example -foo : foo.o bar.o - cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS) -@end example - -@noindent -Because you mention @file{foo.o} but do not give a rule for it, @code{make} -will automatically look for an implicit rule that tells how to update it. -This happens whether or not the file @file{foo.o} currently exists. - -If an implicit rule is found, it can supply both commands and one or -more prerequisites (the source files). You would want to write a rule -for @file{foo.o} with no command lines if you need to specify additional -prerequisites, such as header files, that the implicit rule cannot -supply. - -Each implicit rule has a target pattern and prerequisite patterns. There may -be many implicit rules with the same target pattern. For example, numerous -rules make @samp{.o} files: one, from a @samp{.c} file with the C compiler; -another, from a @samp{.p} file with the Pascal compiler; and so on. The rule -that actually applies is the one whose prerequisites exist or can be made. -So, if you have a file @file{foo.c}, @code{make} will run the C compiler; -otherwise, if you have a file @file{foo.p}, @code{make} will run the Pascal -compiler; and so on. - -Of course, when you write the makefile, you know which implicit rule you -want @code{make} to use, and you know it will choose that one because you -know which possible prerequisite files are supposed to exist. -@xref{Catalogue of Rules, ,Catalogue of Implicit Rules}, -for a catalogue of all the predefined implicit rules. - -Above, we said an implicit rule applies if the required prerequisites ``exist -or can be made''. A file ``can be made'' if it is mentioned explicitly in -the makefile as a target or a prerequisite, or if an implicit rule can be -recursively found for how to make it. When an implicit prerequisite is the -result of another implicit rule, we say that @dfn{chaining} is occurring. -@xref{Chained Rules, ,Chains of Implicit Rules}. - -In general, @code{make} searches for an implicit rule for each target, and -for each double-colon rule, that has no commands. A file that is mentioned -only as a prerequisite is considered a target whose rule specifies nothing, -so implicit rule search happens for it. @xref{Implicit Rule Search, ,Implicit Rule Search Algorithm}, for the -details of how the search is done. - -Note that explicit prerequisites do not influence implicit rule search. -For example, consider this explicit rule: - -@example -foo.o: foo.p -@end example - -@noindent -The prerequisite on @file{foo.p} does not necessarily mean that -@code{make} will remake @file{foo.o} according to the implicit rule to -make an object file, a @file{.o} file, from a Pascal source file, a -@file{.p} file. For example, if @file{foo.c} also exists, the implicit -rule to make an object file from a C source file is used instead, -because it appears before the Pascal rule in the list of predefined -implicit rules (@pxref{Catalogue of Rules, , Catalogue of Implicit -Rules}). - -If you do not want an implicit rule to be used for a target that has no -commands, you can give that target empty commands by writing a semicolon -(@pxref{Empty Commands, ,Defining Empty Commands}). - -@node Catalogue of Rules, Implicit Variables, Using Implicit, Implicit Rules -@section Catalogue of Implicit Rules -@cindex implicit rule, predefined -@cindex rule, implicit, predefined - -Here is a catalogue of predefined implicit rules which are always -available unless the makefile explicitly overrides or cancels them. -@xref{Canceling Rules, ,Canceling Implicit Rules}, for information on -canceling or overriding an implicit rule. The @samp{-r} or -@samp{--no-builtin-rules} option cancels all predefined rules. - -Not all of these rules will always be defined, even when the @samp{-r} -option is not given. Many of the predefined implicit rules are -implemented in @code{make} as suffix rules, so which ones will be -defined depends on the @dfn{suffix list} (the list of prerequisites of -the special target @code{.SUFFIXES}). The default suffix list is: -@code{.out}, @code{.a}, @code{.ln}, @code{.o}, @code{.c}, @code{.cc}, -@code{.C}, @code{.p}, @code{.f}, @code{.F}, @code{.r}, @code{.y}, -@code{.l}, @code{.s}, @code{.S}, @code{.mod}, @code{.sym}, @code{.def}, -@code{.h}, @code{.info}, @code{.dvi}, @code{.tex}, @code{.texinfo}, -@code{.texi}, @code{.txinfo}, @code{.w}, @code{.ch} @code{.web}, -@code{.sh}, @code{.elc}, @code{.el}. All of the implicit rules -described below whose prerequisites have one of these suffixes are -actually suffix rules. If you modify the suffix list, the only -predefined suffix rules in effect will be those named by one or two of -the suffixes that are on the list you specify; rules whose suffixes fail -to be on the list are disabled. @xref{Suffix Rules, ,Old-Fashioned -Suffix Rules}, for full details on suffix rules. - -@table @asis -@item Compiling C programs -@cindex C, rule to compile -@pindex cc -@pindex gcc -@pindex .o -@pindex .c -@file{@var{n}.o} is made automatically from @file{@var{n}.c} with -a command of the form @samp{$(CC) -c $(CPPFLAGS) $(CFLAGS)}.@refill - -@item Compiling C++ programs -@cindex C++, rule to compile -@pindex g++ -@pindex .C -@pindex .cc -@file{@var{n}.o} is made automatically from @file{@var{n}.cc} or -@file{@var{n}.C} with a command of the form @samp{$(CXX) -c $(CPPFLAGS) -$(CXXFLAGS)}. We encourage you to use the suffix @samp{.cc} for C++ -source files instead of @samp{.C}.@refill - -@item Compiling Pascal programs -@cindex Pascal, rule to compile -@pindex pc -@pindex .p -@file{@var{n}.o} is made automatically from @file{@var{n}.p} -with the command @samp{$(PC) -c $(PFLAGS)}.@refill - -@item Compiling Fortran and Ratfor programs -@cindex Fortran, rule to compile -@cindex Ratfor, rule to compile -@pindex f77 -@pindex .f -@pindex .r -@pindex .F -@file{@var{n}.o} is made automatically from @file{@var{n}.r}, -@file{@var{n}.F} or @file{@var{n}.f} by running the -Fortran compiler. The precise command used is as follows:@refill - -@table @samp -@item .f -@samp{$(FC) -c $(FFLAGS)}. -@item .F -@samp{$(FC) -c $(FFLAGS) $(CPPFLAGS)}. -@item .r -@samp{$(FC) -c $(FFLAGS) $(RFLAGS)}. -@end table - -@item Preprocessing Fortran and Ratfor programs -@file{@var{n}.f} is made automatically from @file{@var{n}.r} or -@file{@var{n}.F}. This rule runs just the preprocessor to convert a -Ratfor or preprocessable Fortran program into a strict Fortran -program. The precise command used is as follows:@refill - -@table @samp -@item .F -@samp{$(FC) -F $(CPPFLAGS) $(FFLAGS)}. -@item .r -@samp{$(FC) -F $(FFLAGS) $(RFLAGS)}. -@end table - -@item Compiling Modula-2 programs -@cindex Modula-2, rule to compile -@pindex m2c -@pindex .sym -@pindex .def -@pindex .mod -@file{@var{n}.sym} is made from @file{@var{n}.def} with a command -of the form @samp{$(M2C) $(M2FLAGS) $(DEFFLAGS)}. @file{@var{n}.o} -is made from @file{@var{n}.mod}; the form is: -@w{@samp{$(M2C) $(M2FLAGS) $(MODFLAGS)}}.@refill - -@need 1200 -@item Assembling and preprocessing assembler programs -@cindex assembly, rule to compile -@pindex as -@pindex .s -@file{@var{n}.o} is made automatically from @file{@var{n}.s} by -running the assembler, @code{as}. The precise command is -@samp{$(AS) $(ASFLAGS)}.@refill - -@pindex .S -@file{@var{n}.s} is made automatically from @file{@var{n}.S} by -running the C preprocessor, @code{cpp}. The precise command is -@w{@samp{$(CPP) $(CPPFLAGS)}}. - -@item Linking a single object file -@cindex linking, predefined rule for -@pindex ld -@pindex .o -@file{@var{n}} is made automatically from @file{@var{n}.o} by running -the linker (usually called @code{ld}) via the C compiler. The precise -command used is @w{@samp{$(CC) $(LDFLAGS) @var{n}.o $(LOADLIBES) $(LDLIBS)}}. - -This rule does the right thing for a simple program with only one -source file. It will also do the right thing if there are multiple -object files (presumably coming from various other source files), one -of which has a name matching that of the executable file. Thus, - -@example -x: y.o z.o -@end example - -@noindent -when @file{x.c}, @file{y.c} and @file{z.c} all exist will execute: - -@example -@group -cc -c x.c -o x.o -cc -c y.c -o y.o -cc -c z.c -o z.o -cc x.o y.o z.o -o x -rm -f x.o -rm -f y.o -rm -f z.o -@end group -@end example - -@noindent -In more complicated cases, such as when there is no object file whose -name derives from the executable file name, you must write an explicit -command for linking. - -Each kind of file automatically made into @samp{.o} object files will -be automatically linked by using the compiler (@samp{$(CC)}, -@samp{$(FC)} or @samp{$(PC)}; the C compiler @samp{$(CC)} is used to -assemble @samp{.s} files) without the @samp{-c} option. This could be -done by using the @samp{.o} object files as intermediates, but it is -faster to do the compiling and linking in one step, so that's how it's -done.@refill - -@item Yacc for C programs -@pindex yacc -@cindex Yacc, rule to run -@pindex .y -@file{@var{n}.c} is made automatically from @file{@var{n}.y} by -running Yacc with the command @samp{$(YACC) $(YFLAGS)}. - -@item Lex for C programs -@pindex lex -@cindex Lex, rule to run -@pindex .l -@file{@var{n}.c} is made automatically from @file{@var{n}.l} by -by running Lex. The actual command is @samp{$(LEX) $(LFLAGS)}. - -@item Lex for Ratfor programs -@file{@var{n}.r} is made automatically from @file{@var{n}.l} by -by running Lex. The actual command is @samp{$(LEX) $(LFLAGS)}. - -The convention of using the same suffix @samp{.l} for all Lex files -regardless of whether they produce C code or Ratfor code makes it -impossible for @code{make} to determine automatically which of the two -languages you are using in any particular case. If @code{make} is -called upon to remake an object file from a @samp{.l} file, it must -guess which compiler to use. It will guess the C compiler, because -that is more common. If you are using Ratfor, make sure @code{make} -knows this by mentioning @file{@var{n}.r} in the makefile. Or, if you -are using Ratfor exclusively, with no C files, remove @samp{.c} from -the list of implicit rule suffixes with:@refill - -@example -@group -.SUFFIXES: -.SUFFIXES: .o .r .f .l @dots{} -@end group -@end example - -@item Making Lint Libraries from C, Yacc, or Lex programs -@pindex lint -@cindex @code{lint}, rule to run -@pindex .ln -@file{@var{n}.ln} is made from @file{@var{n}.c} by running @code{lint}. -The precise command is @w{@samp{$(LINT) $(LINTFLAGS) $(CPPFLAGS) -i}}. -The same command is used on the C code produced from -@file{@var{n}.y} or @file{@var{n}.l}.@refill - -@item @TeX{} and Web -@cindex @TeX{}, rule to run -@cindex Web, rule to run -@pindex tex -@pindex cweave -@pindex weave -@pindex tangle -@pindex ctangle -@pindex .dvi -@pindex .tex -@pindex .web -@pindex .w -@pindex .ch -@file{@var{n}.dvi} is made from @file{@var{n}.tex} with the command -@samp{$(TEX)}. @file{@var{n}.tex} is made from @file{@var{n}.web} with -@samp{$(WEAVE)}, or from @file{@var{n}.w} (and from @file{@var{n}.ch} if -it exists or can be made) with @samp{$(CWEAVE)}. @file{@var{n}.p} is -made from @file{@var{n}.web} with @samp{$(TANGLE)} and @file{@var{n}.c} -is made from @file{@var{n}.w} (and from @file{@var{n}.ch} if it exists -or can be made) with @samp{$(CTANGLE)}.@refill - -@item Texinfo and Info -@cindex Texinfo, rule to format -@cindex Info, rule to format -@pindex texi2dvi -@pindex makeinfo -@pindex .texinfo -@pindex .info -@pindex .texi -@pindex .txinfo -@file{@var{n}.dvi} is made from @file{@var{n}.texinfo}, -@file{@var{n}.texi}, or @file{@var{n}.txinfo}, with the command -@w{@samp{$(TEXI2DVI) $(TEXI2DVI_FLAGS)}}. @file{@var{n}.info} is made from -@file{@var{n}.texinfo}, @file{@var{n}.texi}, or @file{@var{n}.txinfo}, with -the command @w{@samp{$(MAKEINFO) $(MAKEINFO_FLAGS)}}. - -@item RCS -@cindex RCS, rule to extract from -@pindex co -@pindex ,v @r{(RCS file extension)} -Any file @file{@var{n}} is extracted if necessary from an RCS file -named either @file{@var{n},v} or @file{RCS/@var{n},v}. The precise -command used is @w{@samp{$(CO) $(COFLAGS)}}. @file{@var{n}} will not be -extracted from RCS if it already exists, even if the RCS file is -newer. The rules for RCS are terminal -(@pxref{Match-Anything Rules, ,Match-Anything Pattern Rules}), -so RCS files cannot be generated from another source; they must -actually exist.@refill - -@item SCCS -@cindex SCCS, rule to extract from -@pindex get -@pindex s. @r{(SCCS file prefix)} -Any file @file{@var{n}} is extracted if necessary from an SCCS file -named either @file{s.@var{n}} or @file{SCCS/s.@var{n}}. The precise -command used is @w{@samp{$(GET) $(GFLAGS)}}. The rules for SCCS are -terminal (@pxref{Match-Anything Rules, ,Match-Anything Pattern Rules}), -so SCCS files cannot be generated from another source; they must -actually exist.@refill - -@pindex .sh -For the benefit of SCCS, a file @file{@var{n}} is copied from -@file{@var{n}.sh} and made executable (by everyone). This is for -shell scripts that are checked into SCCS. Since RCS preserves the -execution permission of a file, you do not need to use this feature -with RCS.@refill - -We recommend that you avoid using of SCCS. RCS is widely held to be -superior, and is also free. By choosing free software in place of -comparable (or inferior) proprietary software, you support the free -software movement. -@end table - -Usually, you want to change only the variables listed in the table -above, which are documented in the following section. - -However, the commands in built-in implicit rules actually use -variables such as @code{COMPILE.c}, @code{LINK.p}, and -@code{PREPROCESS.S}, whose values contain the commands listed above. - -@code{make} follows the convention that the rule to compile a -@file{.@var{x}} source file uses the variable @code{COMPILE.@var{x}}. -Similarly, the rule to produce an executable from a @file{.@var{x}} -file uses @code{LINK.@var{x}}; and the rule to preprocess a -@file{.@var{x}} file uses @code{PREPROCESS.@var{x}}. - -@vindex OUTPUT_OPTION -Every rule that produces an object file uses the variable -@code{OUTPUT_OPTION}. @code{make} defines this variable either to -contain @samp{-o $@@}, or to be empty, depending on a compile-time -option. You need the @samp{-o} option to ensure that the output goes -into the right file when the source file is in a different directory, -as when using @code{VPATH} (@pxref{Directory Search}). However, -compilers on some systems do not accept a @samp{-o} switch for object -files. If you use such a system, and use @code{VPATH}, some -compilations will put their output in the wrong place. -A possible workaround for this problem is to give @code{OUTPUT_OPTION} -the value @w{@samp{; mv $*.o $@@}}. - -@node Implicit Variables, Chained Rules, Catalogue of Rules, Implicit Rules -@section Variables Used by Implicit Rules -@cindex flags for compilers - -The commands in built-in implicit rules make liberal use of certain -predefined variables. You can alter these variables in the makefile, -with arguments to @code{make}, or in the environment to alter how the -implicit rules work without redefining the rules themselves. You can -cancel all variables used by implicit rules with the @samp{-R} or -@samp{--no-builtin-variables} option. - -For example, the command used to compile a C source file actually says -@samp{$(CC) -c $(CFLAGS) $(CPPFLAGS)}. The default values of the variables -used are @samp{cc} and nothing, resulting in the command @samp{cc -c}. By -redefining @samp{CC} to @samp{ncc}, you could cause @samp{ncc} to be -used for all C compilations performed by the implicit rule. By redefining -@samp{CFLAGS} to be @samp{-g}, you could pass the @samp{-g} option to -each compilation. @emph{All} implicit rules that do C compilation use -@samp{$(CC)} to get the program name for the compiler and @emph{all} -include @samp{$(CFLAGS)} among the arguments given to the compiler.@refill - -The variables used in implicit rules fall into two classes: those that are -names of programs (like @code{CC}) and those that contain arguments for the -programs (like @code{CFLAGS}). (The ``name of a program'' may also contain -some command arguments, but it must start with an actual executable program -name.) If a variable value contains more than one argument, separate them -with spaces. - -Here is a table of variables used as names of programs in built-in rules: - -@table @code -@item AR -@vindex AR -Archive-maintaining program; default @samp{ar}. -@pindex ar - -@item AS -@vindex AS -Program for doing assembly; default @samp{as}. -@pindex as - -@item CC -@vindex CC -Program for compiling C programs; default @samp{cc}. -@pindex cc - -@item CXX -@vindex CXX -Program for compiling C++ programs; default @samp{g++}. -@pindex g++ - -@item CO -@vindex CO -Program for extracting a file from RCS; default @samp{co}. -@pindex co - -@item CPP -@vindex CPP -Program for running the C preprocessor, with results to standard output; -default @samp{$(CC) -E}. - -@item FC -@vindex FC -Program for compiling or preprocessing Fortran and Ratfor programs; -default @samp{f77}. -@pindex f77 - -@item GET -@vindex GET -Program for extracting a file from SCCS; default @samp{get}. -@pindex get - -@item LEX -@vindex LEX -Program to use to turn Lex grammars into C programs or Ratfor programs; -default @samp{lex}. -@pindex lex - -@item PC -@vindex PC -Program for compiling Pascal programs; default @samp{pc}. -@pindex pc - -@item YACC -@vindex YACC -Program to use to turn Yacc grammars into C programs; default @samp{yacc}. -@pindex yacc - -@item YACCR -@vindex YACCR -Program to use to turn Yacc grammars into Ratfor -programs; default @samp{yacc -r}. - -@item MAKEINFO -@vindex MAKEINFO -Program to convert a Texinfo source file into an Info file; default -@samp{makeinfo}. -@pindex makeinfo - -@item TEX -@vindex TEX -Program to make @TeX{} @sc{dvi} files from @TeX{} source; -default @samp{tex}. -@pindex tex - -@item TEXI2DVI -@vindex TEXI2DVI -Program to make @TeX{} @sc{dvi} files from Texinfo source; -default @samp{texi2dvi}. -@pindex texi2dvi - -@item WEAVE -@vindex WEAVE -Program to translate Web into @TeX{}; default @samp{weave}. -@pindex weave - -@item CWEAVE -@vindex CWEAVE -Program to translate C Web into @TeX{}; default @samp{cweave}. -@pindex cweave - -@item TANGLE -@vindex TANGLE -Program to translate Web into Pascal; default @samp{tangle}. -@pindex tangle - -@item CTANGLE -@vindex CTANGLE -Program to translate C Web into C; default @samp{ctangle}. -@pindex ctangle - -@item RM -@vindex RM -Command to remove a file; default @samp{rm -f}. -@pindex rm -@end table - -Here is a table of variables whose values are additional arguments for the -programs above. The default values for all of these is the empty -string, unless otherwise noted. - -@table @code -@item ARFLAGS -@vindex ARFLAGS -Flags to give the archive-maintaining program; default @samp{rv}. - -@item ASFLAGS -@vindex ASFLAGS -Extra flags to give to the assembler (when explicitly -invoked on a @samp{.s} or @samp{.S} file). - -@item CFLAGS -@vindex CFLAGS -Extra flags to give to the C compiler. - -@item CXXFLAGS -@vindex CXXFLAGS -Extra flags to give to the C++ compiler. - -@item COFLAGS -@vindex COFLAGS -Extra flags to give to the RCS @code{co} program. - -@item CPPFLAGS -@vindex CPPFLAGS -Extra flags to give to the C preprocessor and programs -that use it (the C and Fortran compilers). - -@item FFLAGS -@vindex FFLAGS -Extra flags to give to the Fortran compiler. - -@item GFLAGS -@vindex GFLAGS -Extra flags to give to the SCCS @code{get} program. - -@item LDFLAGS -@vindex LDFLAGS -Extra flags to give to compilers when they are -supposed to invoke the linker, @samp{ld}. - -@item LFLAGS -@vindex LFLAGS -Extra flags to give to Lex. - -@item PFLAGS -@vindex PFLAGS -Extra flags to give to the Pascal compiler. - -@item RFLAGS -@vindex RFLAGS -Extra flags to give to the Fortran compiler for Ratfor programs. - -@item YFLAGS -@vindex YFLAGS -Extra flags to give to Yacc. -@end table - -@node Chained Rules, Pattern Rules, Implicit Variables, Implicit Rules -@section Chains of Implicit Rules - -@cindex chains of rules -@cindex rule, implicit, chains of -Sometimes a file can be made by a sequence of implicit rules. For example, -a file @file{@var{n}.o} could be made from @file{@var{n}.y} by running -first Yacc and then @code{cc}. Such a sequence is called a @dfn{chain}. - -If the file @file{@var{n}.c} exists, or is mentioned in the makefile, no -special searching is required: @code{make} finds that the object file can -be made by C compilation from @file{@var{n}.c}; later on, when considering -how to make @file{@var{n}.c}, the rule for running Yacc is -used. Ultimately both @file{@var{n}.c} and @file{@var{n}.o} are -updated.@refill - -@cindex intermediate files -@cindex files, intermediate -However, even if @file{@var{n}.c} does not exist and is not mentioned, -@code{make} knows how to envision it as the missing link between -@file{@var{n}.o} and @file{@var{n}.y}! In this case, @file{@var{n}.c} is -called an @dfn{intermediate file}. Once @code{make} has decided to use the -intermediate file, it is entered in the data base as if it had been -mentioned in the makefile, along with the implicit rule that says how to -create it.@refill - -Intermediate files are remade using their rules just like all other -files. But intermediate files are treated differently in two ways. - -The first difference is what happens if the intermediate file does not -exist. If an ordinary file @var{b} does not exist, and @code{make} -considers a target that depends on @var{b}, it invariably creates -@var{b} and then updates the target from @var{b}. But if @var{b} is an -intermediate file, then @code{make} can leave well enough alone. It -won't bother updating @var{b}, or the ultimate target, unless some -prerequisite of @var{b} is newer than that target or there is some other -reason to update that target. - -The second difference is that if @code{make} @emph{does} create @var{b} -in order to update something else, it deletes @var{b} later on after it -is no longer needed. Therefore, an intermediate file which did not -exist before @code{make} also does not exist after @code{make}. -@code{make} reports the deletion to you by printing a @samp{rm -f} -command showing which file it is deleting. - -Ordinarily, a file cannot be intermediate if it is mentioned in the -makefile as a target or prerequisite. However, you can explicitly mark a -file as intermediate by listing it as a prerequisite of the special target -@code{.INTERMEDIATE}. This takes effect even if the file is mentioned -explicitly in some other way. - -@cindex intermediate files, preserving -@cindex preserving intermediate files -@cindex secondary files -You can prevent automatic deletion of an intermediate file by marking it -as a @dfn{secondary} file. To do this, list it as a prerequisite of the -special target @code{.SECONDARY}. When a file is secondary, @code{make} -will not create the file merely because it does not already exist, but -@code{make} does not automatically delete the file. Marking a file as -secondary also marks it as intermediate. - -You can list the target pattern of an implicit rule (such as @samp{%.o}) -as a prerequisite of the special target @code{.PRECIOUS} to preserve -intermediate files made by implicit rules whose target patterns match -that file's name; see @ref{Interrupts}.@refill -@cindex preserving with @code{.PRECIOUS} -@cindex @code{.PRECIOUS} intermediate files - -A chain can involve more than two implicit rules. For example, it is -possible to make a file @file{foo} from @file{RCS/foo.y,v} by running RCS, -Yacc and @code{cc}. Then both @file{foo.y} and @file{foo.c} are -intermediate files that are deleted at the end.@refill - -No single implicit rule can appear more than once in a chain. This means -that @code{make} will not even consider such a ridiculous thing as making -@file{foo} from @file{foo.o.o} by running the linker twice. This -constraint has the added benefit of preventing any infinite loop in the -search for an implicit rule chain. - -There are some special implicit rules to optimize certain cases that would -otherwise be handled by rule chains. For example, making @file{foo} from -@file{foo.c} could be handled by compiling and linking with separate -chained rules, using @file{foo.o} as an intermediate file. But what -actually happens is that a special rule for this case does the compilation -and linking with a single @code{cc} command. The optimized rule is used in -preference to the step-by-step chain because it comes earlier in the -ordering of rules. - -@node Pattern Rules, Last Resort, Chained Rules, Implicit Rules -@section Defining and Redefining Pattern Rules - -You define an implicit rule by writing a @dfn{pattern rule}. A pattern -rule looks like an ordinary rule, except that its target contains the -character @samp{%} (exactly one of them). The target is considered a -pattern for matching file names; the @samp{%} can match any nonempty -substring, while other characters match only themselves. The prerequisites -likewise use @samp{%} to show how their names relate to the target name. - -Thus, a pattern rule @samp{%.o : %.c} says how to make any file -@file{@var{stem}.o} from another file @file{@var{stem}.c}.@refill - -Note that expansion using @samp{%} in pattern rules occurs -@strong{after} any variable or function expansions, which take place -when the makefile is read. @xref{Using Variables, , How to Use -Variables}, and @ref{Functions, ,Functions for Transforming Text}. - -@menu -* Pattern Intro:: An introduction to pattern rules. -* Pattern Examples:: Examples of pattern rules. -* Automatic:: How to use automatic variables in the - commands of implicit rules. -* Pattern Match:: How patterns match. -* Match-Anything Rules:: Precautions you should take prior to - defining rules that can match any - target file whatever. -* Canceling Rules:: How to override or cancel built-in rules. -@end menu - -@node Pattern Intro, Pattern Examples, , Pattern Rules -@subsection Introduction to Pattern Rules -@cindex pattern rule -@cindex rule, pattern - -A pattern rule contains the character @samp{%} (exactly one of them) -in the target; otherwise, it looks exactly like an ordinary rule. The -target is a pattern for matching file names; the @samp{%} matches any -nonempty substring, while other characters match only themselves. -@cindex target pattern, implicit -@cindex @code{%}, in pattern rules - -For example, @samp{%.c} as a pattern matches any file name that ends in -@samp{.c}. @samp{s.%.c} as a pattern matches any file name that starts -with @samp{s.}, ends in @samp{.c} and is at least five characters long. -(There must be at least one character to match the @samp{%}.) The substring -that the @samp{%} matches is called the @dfn{stem}.@refill - -@samp{%} in a prerequisite of a pattern rule stands for the same stem -that was matched by the @samp{%} in the target. In order for -the pattern rule to apply, its target pattern must match the file name -under consideration, and its prerequisite patterns must name files that -exist or can be made. These files become prerequisites of the target. -@cindex prerequisite pattern, implicit - -Thus, a rule of the form - -@example -%.o : %.c ; @var{command}@dots{} -@end example - -@noindent -specifies how to make a file @file{@var{n}.o}, with another file -@file{@var{n}.c} as its prerequisite, provided that @file{@var{n}.c} -exists or can be made. - -There may also be prerequisites that do not use @samp{%}; such a prerequisite -attaches to every file made by this pattern rule. These unvarying -prerequisites are useful occasionally. - -A pattern rule need not have any prerequisites that contain @samp{%}, or -in fact any prerequisites at all. Such a rule is effectively a general -wildcard. It provides a way to make any file that matches the target -pattern. @xref{Last Resort}. - -@c !!! The end of of this paragraph should be rewritten. --bob -Pattern rules may have more than one target. Unlike normal rules, this -does not act as many different rules with the same prerequisites and -commands. If a pattern rule has multiple targets, @code{make} knows that -the rule's commands are responsible for making all of the targets. The -commands are executed only once to make all the targets. When searching -for a pattern rule to match a target, the target patterns of a rule other -than the one that matches the target in need of a rule are incidental: -@code{make} worries only about giving commands and prerequisites to the file -presently in question. However, when this file's commands are run, the -other targets are marked as having been updated themselves. -@cindex multiple targets, in pattern rule -@cindex target, multiple in pattern rule - -The order in which pattern rules appear in the makefile is important -since this is the order in which they are considered. -Of equally applicable -rules, only the first one found is used. The rules you write take precedence -over those that are built in. Note however, that a rule whose -prerequisites actually exist or are mentioned always takes priority over a -rule with prerequisites that must be made by chaining other implicit rules. -@cindex pattern rules, order of -@cindex order of pattern rules - -@node Pattern Examples, Automatic, Pattern Intro, Pattern Rules -@subsection Pattern Rule Examples - -Here are some examples of pattern rules actually predefined in -@code{make}. First, the rule that compiles @samp{.c} files into @samp{.o} -files:@refill - -@example -%.o : %.c - $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@@ -@end example - -@noindent -defines a rule that can make any file @file{@var{x}.o} from -@file{@var{x}.c}. The command uses the automatic variables @samp{$@@} and -@samp{$<} to substitute the names of the target file and the source file -in each case where the rule applies (@pxref{Automatic, ,Automatic Variables}).@refill - -Here is a second built-in rule: - -@example -% :: RCS/%,v - $(CO) $(COFLAGS) $< -@end example - -@noindent -defines a rule that can make any file @file{@var{x}} whatsoever from a -corresponding file @file{@var{x},v} in the subdirectory @file{RCS}. Since -the target is @samp{%}, this rule will apply to any file whatever, provided -the appropriate prerequisite file exists. The double colon makes the rule -@dfn{terminal}, which means that its prerequisite may not be an intermediate -file (@pxref{Match-Anything Rules, ,Match-Anything Pattern Rules}).@refill - -@need 500 -This pattern rule has two targets: - -@example -@group -%.tab.c %.tab.h: %.y - bison -d $< -@end group -@end example - -@noindent -@c The following paragraph is rewritten to avoid overfull hboxes -This tells @code{make} that the command @samp{bison -d @var{x}.y} will -make both @file{@var{x}.tab.c} and @file{@var{x}.tab.h}. If the file -@file{foo} depends on the files @file{parse.tab.o} and @file{scan.o} -and the file @file{scan.o} depends on the file @file{parse.tab.h}, -when @file{parse.y} is changed, the command @samp{bison -d parse.y} -will be executed only once, and the prerequisites of both -@file{parse.tab.o} and @file{scan.o} will be satisfied. (Presumably -the file @file{parse.tab.o} will be recompiled from @file{parse.tab.c} -and the file @file{scan.o} from @file{scan.c}, while @file{foo} is -linked from @file{parse.tab.o}, @file{scan.o}, and its other -prerequisites, and it will execute happily ever after.)@refill - -@node Automatic, Pattern Match, Pattern Examples, Pattern Rules -@subsection Automatic Variables -@cindex automatic variables -@cindex variables, automatic -@cindex variables, and implicit rule - -Suppose you are writing a pattern rule to compile a @samp{.c} file into a -@samp{.o} file: how do you write the @samp{cc} command so that it operates -on the right source file name? You cannot write the name in the command, -because the name is different each time the implicit rule is applied. - -What you do is use a special feature of @code{make}, the @dfn{automatic -variables}. These variables have values computed afresh for each rule that -is executed, based on the target and prerequisites of the rule. In this -example, you would use @samp{$@@} for the object file name and @samp{$<} -for the source file name. - -Here is a table of automatic variables: - -@table @code -@vindex $@@ -@vindex @@ @r{(automatic variable)} -@item $@@ -The file name of the target of the rule. If the target is an archive -member, then @samp{$@@} is the name of the archive file. In a pattern -rule that has multiple targets (@pxref{Pattern Intro, ,Introduction to -Pattern Rules}), @samp{$@@} is the name of whichever target caused the -rule's commands to be run. - -@vindex $% -@vindex % @r{(automatic variable)} -@item $% -The target member name, when the target is an archive member. -@xref{Archives}. For example, if the target is @file{foo.a(bar.o)} then -@samp{$%} is @file{bar.o} and @samp{$@@} is @file{foo.a}. @samp{$%} is -empty when the target is not an archive member. - -@vindex $< -@vindex < @r{(automatic variable)} -@item $< -The name of the first prerequisite. If the target got its commands from -an implicit rule, this will be the first prerequisite added by the -implicit rule (@pxref{Implicit Rules}). - -@vindex $? -@vindex ? @r{(automatic variable)} -@item $? -The names of all the prerequisites that are newer than the target, with -spaces between them. For prerequisites which are archive members, only -the member named is used (@pxref{Archives}). -@cindex prerequisites, list of changed -@cindex list of changed prerequisites - -@vindex $^ -@vindex ^ @r{(automatic variable)} -@item $^ -The names of all the prerequisites, with spaces between them. For -prerequisites which are archive members, only the member named is used -(@pxref{Archives}). A target has only one prerequisite on each other file -it depends on, no matter how many times each file is listed as a -prerequisite. So if you list a prerequisite more than once for a target, -the value of @code{$^} contains just one copy of the name. -@cindex prerequisites, list of all -@cindex list of all prerequisites - -@vindex $+ -@vindex + @r{(automatic variable)} -@item $+ -This is like @samp{$^}, but prerequisites listed more than once are -duplicated in the order they were listed in the makefile. This is -primarily useful for use in linking commands where it is meaningful to -repeat library file names in a particular order. - -@vindex $* -@vindex * @r{(automatic variable)} -@item $* -The stem with which an implicit rule matches (@pxref{Pattern Match, ,How -Patterns Match}). If the target is @file{dir/a.foo.b} and the target -pattern is @file{a.%.b} then the stem is @file{dir/foo}. The stem is -useful for constructing names of related files.@refill -@cindex stem, variable for - -In a static pattern rule, the stem is part of the file name that matched -the @samp{%} in the target pattern. - -In an explicit rule, there is no stem; so @samp{$*} cannot be determined -in that way. Instead, if the target name ends with a recognized suffix -(@pxref{Suffix Rules, ,Old-Fashioned Suffix Rules}), @samp{$*} is set to -the target name minus the suffix. For example, if the target name is -@samp{foo.c}, then @samp{$*} is set to @samp{foo}, since @samp{.c} is a -suffix. GNU @code{make} does this bizarre thing only for compatibility -with other implementations of @code{make}. You should generally avoid -using @samp{$*} except in implicit rules or static pattern rules.@refill - -If the target name in an explicit rule does not end with a recognized -suffix, @samp{$*} is set to the empty string for that rule. -@end table - -@samp{$?} is useful even in explicit rules when you wish to operate on only -the prerequisites that have changed. For example, suppose that an archive -named @file{lib} is supposed to contain copies of several object files. -This rule copies just the changed object files into the archive: - -@example -@group -lib: foo.o bar.o lose.o win.o - ar r lib $? -@end group -@end example - -Of the variables listed above, four have values that are single file -names, and three have values that are lists of file names. These seven -have variants that get just the file's directory name or just the file -name within the directory. The variant variables' names are formed by -appending @samp{D} or @samp{F}, respectively. These variants are -semi-obsolete in GNU @code{make} since the functions @code{dir} and -@code{notdir} can be used to get a similar effect (@pxref{File Name -Functions, , Functions for File Names}). Note, however, that the -@samp{D} variants all omit the trailing slash which always appears in -the output of the @code{dir} function. Here is a table of the variants: - -@table @samp -@vindex $(@@D) -@vindex @@D @r{(automatic variable)} -@item $(@@D) -The directory part of the file name of the target, with the trailing -slash removed. If the value of @samp{$@@} is @file{dir/foo.o} then -@samp{$(@@D)} is @file{dir}. This value is @file{.} if @samp{$@@} does -not contain a slash. - -@vindex $(@@F) -@vindex @@F @r{(automatic variable)} -@item $(@@F) -The file-within-directory part of the file name of the target. If the -value of @samp{$@@} is @file{dir/foo.o} then @samp{$(@@F)} is -@file{foo.o}. @samp{$(@@F)} is equivalent to @samp{$(notdir $@@)}. - -@vindex $(*D) -@vindex *D @r{(automatic variable)} -@item $(*D) -@vindex $(*F) -@vindex *F @r{(automatic variable)} -@itemx $(*F) -The directory part and the file-within-directory -part of the stem; @file{dir} and @file{foo} in this example. - -@vindex $(%D) -@vindex %D @r{(automatic variable)} -@item $(%D) -@vindex $(%F) -@vindex %F @r{(automatic variable)} -@itemx $(%F) -The directory part and the file-within-directory part of the target -archive member name. This makes sense only for archive member targets -of the form @file{@var{archive}(@var{member})} and is useful only when -@var{member} may contain a directory name. (@xref{Archive Members, -,Archive Members as Targets}.) - -@vindex $( tar-`sed -e '/version_string/!d' \ - -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ - -e q - version.c`.shar.Z -@end group - -@group -dist: $(SRCS) $(AUX) - echo tar-`sed \ - -e '/version_string/!d' \ - -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ - -e q - version.c` > .fname - -rm -rf `cat .fname` - mkdir `cat .fname` - ln $(SRCS) $(AUX) `cat .fname` - tar chZf `cat .fname`.tar.Z `cat .fname` - -rm -rf `cat .fname` .fname -@end group - -@group -tar.zoo: $(SRCS) $(AUX) - -rm -rf tmp.dir - -mkdir tmp.dir - -rm tar.zoo - for X in $(SRCS) $(AUX) ; do \ - echo $$X ; \ - sed 's/$$/^M/' $$X \ - > tmp.dir/$$X ; done - cd tmp.dir ; zoo aM ../tar.zoo * - -rm -rf tmp.dir -@end group -@end example - -@node Concept Index, Name Index, Complex Makefile, Top -@unnumbered Index of Concepts - -@printindex cp - -@node Name Index, , Concept Index, Top -@unnumbered Index of Functions, Variables, & Directives - -@printindex fn - -@summarycontents -@contents -@bye diff --git a/misc.c b/misc.c index 868d3bc..ee0a597 100644 --- a/misc.c +++ b/misc.c @@ -520,13 +520,11 @@ end_of_token_w32 (s, stopchar) char * next_token (s) - char *s; + const char *s; { - register char *p = s; - - while (isblank ((unsigned char)*p)) - ++p; - return p; + while (isblank ((unsigned char)*s)) + ++s; + return (char *)s; } /* Find the next token in PTR; return the address of it, and store the diff --git a/read.c b/read.c index 6b66a81..3578ca8 100644 --- a/read.c +++ b/read.c @@ -42,23 +42,20 @@ struct passwd *getpwnam PARAMS ((char *name)); #endif #endif /* !WINDOWS32 */ -/* A `struct linebuffer' is a structure which holds a line of text. - `readline' reads a line from a stream into a linebuffer - and works regardless of the length of the line. */ +/* A 'struct ebuffer' controls the origin of the makefile we are currently + eval'ing. +*/ -struct linebuffer +struct ebuffer { - /* Note: This is the number of bytes malloc'ed for `buffer' - It does not indicate `buffer's real length. - Instead, a null char indicates end-of-string. */ - unsigned int size; - char *buffer; + char *buffer; /* Start of the current line in the buffer. */ + char *bufnext; /* Start of the next line in the buffer. */ + char *bufstart; /* Start of the entire buffer. */ + unsigned int size; /* Malloc'd size of buffer. */ + FILE *fp; /* File, or NULL if this is an internal buffer. */ + struct floc floc; /* Info on the file in fp (if any). */ }; -#define initbuffer(lb) (lb)->buffer = (char *) xmalloc ((lb)->size = 200) -#define freebuffer(lb) free ((lb)->buffer) - - /* Types of "words" that can be read in a makefile. */ enum make_word_type { @@ -93,7 +90,7 @@ static char *default_include_directories[] = { #if defined(WINDOWS32) && !defined(INCLUDEDIR) /* - * This completly up to the user when they install MSVC or other packages. + * This completely up to the user when they install MSVC or other packages. * This is defined as a placeholder. */ #define INCLUDEDIR "." @@ -118,18 +115,19 @@ static unsigned int max_incl_len; /* The filename and pointer to line number of the makefile currently being read in. */ -const struct floc *reading_file; +const struct floc *reading_file = 0; /* The chain of makefiles read by read_makefile. */ static struct dep *read_makefiles = 0; -static int read_makefile PARAMS ((char *filename, int flags)); -static unsigned long readline PARAMS ((struct linebuffer *linebuffer, - FILE *stream, const struct floc *flocp)); +static int eval_makefile PARAMS ((char *filename, int flags)); +static int eval PARAMS ((struct ebuffer *buffer, int flags)); + +static long readline PARAMS ((struct ebuffer *ebuf)); static void do_define PARAMS ((char *name, unsigned int namelen, - enum variable_origin origin, FILE *infile, - struct floc *flocp)); + enum variable_origin origin, + struct ebuffer *ebuf)); static int conditional_line PARAMS ((char *line, const struct floc *flocp)); static void record_files PARAMS ((struct nameseq *filenames, char *pattern, char *pattern_percent, struct dep *deps, unsigned int cmds_started, char *commands, @@ -150,6 +148,11 @@ read_all_makefiles (makefiles) { unsigned int num_makefiles = 0; + /* Create *_LIST variables, to hold the makefiles, targets, and variables + we will be reading. */ + + define_variable ("MAKEFILE_LIST", sizeof ("MAKEFILE_LIST")-1, "", o_file, 0); + DB (DB_BASIC, (_("Reading makefiles...\n"))); /* If there's a non-null variable MAKEFILES, its value is a list of @@ -180,7 +183,7 @@ read_all_makefiles (makefiles) if (*p != '\0') *p++ = '\0'; name = xstrdup (name); - if (read_makefile (name, + if (eval_makefile (name, RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE) < 2) free (name); } @@ -196,7 +199,7 @@ read_all_makefiles (makefiles) struct dep *tail = read_makefiles; register struct dep *d; - if (! read_makefile (*makefiles, 0)) + if (! eval_makefile (*makefiles, 0)) perror_with_name ("", *makefiles); /* Find the right element of read_makefiles. */ @@ -231,7 +234,7 @@ read_all_makefiles (makefiles) if (*p != 0) { - if (! read_makefile (*p, 0)) + if (! eval_makefile (*p, 0)) perror_with_name ("", *p); } else @@ -265,74 +268,23 @@ read_all_makefiles (makefiles) return read_makefiles; } -/* Read file FILENAME as a makefile and add its contents to the data base. - - FLAGS contains bits as above. - - FILENAME is added to the `read_makefiles' chain. - - Returns 0 if a file was not found or not read. - Returns 1 if FILENAME was found and read. - Returns 2 if FILENAME was read, and we kept a reference (don't free it). */ - -static int -read_makefile (filename, flags) +int +eval_makefile (filename, flags) char *filename; int flags; { - static char *collapsed = 0; - static unsigned int collapsed_length = 0; - register FILE *infile; - struct linebuffer lb; - unsigned int commands_len = 200; - char *commands; - unsigned int commands_idx = 0; - unsigned int cmds_started, tgts_started; - char *p; - char *p2; - int len, reading_target; - int ignoring = 0, in_ignored_define = 0; - int no_targets = 0; /* Set when reading a rule without targets. */ - struct floc fileinfo; - char *passed_filename = filename; - - struct nameseq *filenames = 0; struct dep *deps; - unsigned int nlines = 0; - int two_colon = 0; - char *pattern = 0, *pattern_percent; - + struct ebuffer ebuf; + const struct floc *curfile; int makefile_errno; -#if defined (WINDOWS32) || defined (__MSDOS__) - int check_again; -#endif + int r; -#define record_waiting_files() \ - do \ - { \ - if (filenames != 0) \ - { \ - struct floc fi; \ - fi.filenm = fileinfo.filenm; \ - fi.lineno = tgts_started; \ - record_files (filenames, pattern, pattern_percent, deps, \ - cmds_started, commands, commands_idx, two_colon, \ - &fi, !(flags & RM_NO_DEFAULT_GOAL)); \ - } \ - filenames = 0; \ - commands_idx = 0; \ - if (pattern) { free(pattern); pattern = 0; } \ - } while (0) - - fileinfo.filenm = filename; - fileinfo.lineno = 1; - - pattern_percent = 0; - cmds_started = tgts_started = fileinfo.lineno; + ebuf.floc.filenm = filename; + ebuf.floc.lineno = 1; if (ISDB (DB_VERBOSE)) { - printf (_("Reading makefile `%s'"), fileinfo.filenm); + printf (_("Reading makefile `%s'"), filename); if (flags & RM_NO_DEFAULT_GOAL) printf (_(" (no default goal)")); if (flags & RM_INCLUDED) @@ -355,21 +307,21 @@ read_makefile (filename, flags) filename = expanded; } - infile = fopen (filename, "r"); + ebuf.fp = fopen (filename, "r"); /* Save the error code so we print the right message later. */ makefile_errno = errno; /* If the makefile wasn't found and it's either a makefile from the `MAKEFILES' variable or an included makefile, search the included makefile search path for this makefile. */ - if (infile == 0 && (flags & RM_INCLUDED) && *filename != '/') + if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/') { register unsigned int i; for (i = 0; include_directories[i] != 0; ++i) { char *name = concat (include_directories[i], "/", filename); - infile = fopen (name, "r"); - if (infile == 0) + ebuf.fp = fopen (name, "r"); + if (ebuf.fp == 0) free (name); else { @@ -391,15 +343,14 @@ read_makefile (filename, flags) if (flags & RM_DONTCARE) deps->file->dontcare = 1; } - if (filename != passed_filename) + if (filename != ebuf.floc.filenm) free (filename); filename = deps->file->name; deps->changed = flags; - deps = 0; /* If the makefile can't be found at all, give up entirely. */ - if (infile == 0) + if (ebuf.fp == 0) { /* If we did some searching, errno has the error from the last attempt, rather from FILENAME itself. Restore it in case the @@ -408,28 +359,148 @@ read_makefile (filename, flags) return 0; } - reading_file = &fileinfo; + /* Add this makefile to the list. */ + do_variable_definition (&ebuf.floc, "MAKEFILE_LIST", filename, o_file, + f_append, 0); + + /* Evaluate the makefile */ + + ebuf.size = 200; + ebuf.buffer = ebuf.bufnext = ebuf.bufstart = xmalloc (ebuf.size); + + curfile = reading_file; + reading_file = &ebuf.floc; + + r = eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL)); + + reading_file = curfile; + + return r; +} + +int +eval_buffer (buffer) + char *buffer; +{ + struct ebuffer ebuf; + const struct floc *curfile; + int r; + + /* Evaluate the buffer */ + + ebuf.size = strlen (buffer); + ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer; + ebuf.fp = NULL; + + ebuf.floc = *reading_file; + + curfile = reading_file; + reading_file = &ebuf.floc; + + r = eval (&ebuf, 1); + + reading_file = curfile; + + return r; +} + + +/* Read file FILENAME as a makefile and add its contents to the data base. + + SET_DEFAULT is true if we are allowed to set the default goal. + + FILENAME is added to the `read_makefiles' chain. + + Returns 0 if a file was not found or not read. + Returns 1 if FILENAME was found and read. + Returns 2 if FILENAME was read, and we kept a reference (don't free it). */ + +static int +eval (ebuf, set_default) + struct ebuffer *ebuf; + int set_default; +{ + static char *collapsed = 0; + static unsigned int collapsed_length = 0; + unsigned int commands_len = 200; + char *commands; + unsigned int commands_idx = 0; + unsigned int cmds_started, tgts_started; + int ignoring = 0, in_ignored_define = 0; + int no_targets = 0; /* Set when reading a rule without targets. */ + struct nameseq *filenames = 0; + struct dep *deps = 0; + long nlines = 0; + int two_colon = 0; + char *pattern = 0, *pattern_percent; + struct floc *fstart; + struct floc fi; + +#if defined (WINDOWS32) || defined (__MSDOS__) + int check_again; +#endif + +#define record_waiting_files() \ + do \ + { \ + if (filenames != 0) \ + { \ + fi.lineno = tgts_started; \ + record_files (filenames, pattern, pattern_percent, deps, \ + cmds_started, commands, commands_idx, two_colon, \ + &fi, set_default); \ + } \ + filenames = 0; \ + commands_idx = 0; \ + no_targets = 0; \ + if (pattern) { free(pattern); pattern = 0; } \ + } while (0) + + pattern_percent = 0; + cmds_started = tgts_started = 1; + + fstart = &ebuf->floc; + fi.filenm = ebuf->floc.filenm; /* Loop over lines in the file. The strategy is to accumulate target names in FILENAMES, dependencies in DEPS and commands in COMMANDS. These are used to define a rule - when the start of the next rule (or eof) is encountered. */ + when the start of the next rule (or eof) is encountered. + + When you see a "continue" in the loop below, that means we are moving on + to the next line _without_ ending any rule that we happen to be working + with at the moment. If you see a "goto rule_complete", then the + statement we just parsed also finishes the previous rule. */ - initbuffer (&lb); commands = xmalloc (200); - while (!feof (infile)) + while (1) { - fileinfo.lineno += nlines; - nlines = readline (&lb, infile, &fileinfo); + int linelen; + char *line; + int len; + char *p; + char *p2; + + /* Grab the next line to be evaluated */ + ebuf->floc.lineno += nlines; + nlines = readline (ebuf); + + /* If there is nothing left to eval, we're done. */ + if (nlines < 0) + break; + + /* If this line is empty, skip it. */ + line = ebuf->buffer; + if (line[0] == '\0') + continue; + + linelen = strlen (line); /* Check for a shell command line first. If it is not one, we can stop treating tab specially. */ - if (lb.buffer[0] == '\t') + if (line[0] == '\t') { - /* This line is a probably shell command. */ - unsigned int len; - if (no_targets) /* Ignore the commands in a rule with no targets. */ continue; @@ -445,17 +516,16 @@ read_makefile (filename, flags) continue; /* Append this command line to the line being accumulated. */ - p = lb.buffer; if (commands_idx == 0) - cmds_started = fileinfo.lineno; - len = strlen (p); - if (len + 1 + commands_idx > commands_len) + cmds_started = ebuf->floc.lineno; + + if (linelen + 1 + commands_idx > commands_len) { - commands_len = (len + 1 + commands_idx) * 2; - commands = (char *) xrealloc (commands, commands_len); + commands_len = (linelen + 1 + commands_idx) * 2; + commands = xrealloc (commands, commands_len); } - bcopy (p, &commands[commands_idx], len); - commands_idx += len; + bcopy (line, &commands[commands_idx], linelen); + commands_idx += linelen; commands[commands_idx++] = '\n'; continue; @@ -464,25 +534,26 @@ read_makefile (filename, flags) /* This line is not a shell command line. Don't worry about tabs. */ - if (collapsed_length < lb.size) + if (collapsed_length < linelen+1) { - collapsed_length = lb.size; + collapsed_length = linelen+1; if (collapsed != 0) free (collapsed); collapsed = (char *) xmalloc (collapsed_length); } - strcpy (collapsed, lb.buffer); + strcpy (collapsed, line); /* Collapse continuation lines. */ collapse_continuations (collapsed); remove_comments (collapsed); /* Compare a word, both length and contents. */ -#define word1eq(s, l) (len == l && strneq (s, p, l)) +#define word1eq(s) (len == sizeof(s)-1 && strneq (s, p, sizeof(s)-1)) p = collapsed; while (isspace ((unsigned char)*p)) ++p; + if (*p == '\0') - /* This line is completely empty. */ + /* This line is completely empty--ignore it. */ continue; /* Find the end of the first token. Note we don't need to worry about @@ -490,20 +561,21 @@ read_makefile (filename, flags) * be equal to "export:"). */ for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2) - {} + ; len = p2 - p; - /* Find the start of the second token. If it's a `:' remember it, - since it can't be a preprocessor token--this allows targets named - `ifdef', `export', etc. */ - reading_target = 0; + /* Find the start of the second token. If it looks like a target or + variable definition it can't be a preprocessor token so skip + them--this allows variables/targets named `ifdef', `export', etc. */ while (isspace ((unsigned char)*p2)) ++p2; - if (*p2 == '\0') - p2 = NULL; - else if (p2[0] == ':' && p2[1] == '\0') + + if ((p2[0] == ':' || p2[0] == '+' || p2[0] == '=') && p2[1] == '\0') { - reading_target = 1; + /* It can't be a preprocessor token so skip it if we're ignoring */ + if (ignoring) + continue; + goto skip_conditionals; } @@ -512,36 +584,34 @@ read_makefile (filename, flags) following lines. */ if (!in_ignored_define - && (word1eq ("ifdef", 5) || word1eq ("ifndef", 6) - || word1eq ("ifeq", 4) || word1eq ("ifneq", 5) - || word1eq ("else", 4) || word1eq ("endif", 5))) + && (word1eq ("ifdef") || word1eq ("ifndef") + || word1eq ("ifeq") || word1eq ("ifneq") + || word1eq ("else") || word1eq ("endif"))) { - int i = conditional_line (p, &fileinfo); - if (i >= 0) - ignoring = i; - else - fatal (&fileinfo, _("invalid syntax in conditional")); + int i = conditional_line (p, fstart); + if (i < 0) + fatal (fstart, _("invalid syntax in conditional")); + + ignoring = i; continue; } - if (word1eq ("endef", 5)) + if (word1eq ("endef")) { - if (in_ignored_define) - in_ignored_define = 0; - else - fatal (&fileinfo, _("extraneous `endef'")); + if (!in_ignored_define) + fatal (fstart, _("extraneous `endef'")); + in_ignored_define = 0; continue; } - if (word1eq ("define", 6)) + if (word1eq ("define")) { if (ignoring) in_ignored_define = 1; else { - p2 = next_token (p + 6); if (*p2 == '\0') - fatal (&fileinfo, _("empty variable name")); + fatal (fstart, _("empty variable name")); /* Let the variable name be the whole rest of the line, with trailing blanks stripped (comments have already been @@ -550,16 +620,16 @@ read_makefile (filename, flags) p = strchr (p2, '\0'); while (isblank ((unsigned char)p[-1])) --p; - do_define (p2, p - p2, o_file, infile, &fileinfo); + do_define (p2, p - p2, o_file, ebuf); } continue; } - if (word1eq ("override", 8)) + if (word1eq ("override")) { - p2 = next_token (p + 8); if (*p2 == '\0') - error (&fileinfo, _("empty `override' directive")); + error (fstart, _("empty `override' directive")); + if (strneq (p2, "define", 6) && (isblank ((unsigned char)p2[6]) || p2[6] == '\0')) { @@ -569,7 +639,7 @@ read_makefile (filename, flags) { p2 = next_token (p2 + 6); if (*p2 == '\0') - fatal (&fileinfo, _("empty variable name")); + fatal (fstart, _("empty variable name")); /* Let the variable name be the whole rest of the line, with trailing blanks stripped (comments have already been @@ -578,65 +648,76 @@ read_makefile (filename, flags) p = strchr (p2, '\0'); while (isblank ((unsigned char)p[-1])) --p; - do_define (p2, p - p2, o_override, infile, &fileinfo); + do_define (p2, p - p2, o_override, ebuf); } } else if (!ignoring - && !try_variable_definition (&fileinfo, p2, o_override, 0)) - error (&fileinfo, _("invalid `override' directive")); + && !try_variable_definition (fstart, p2, o_override, 0)) + error (fstart, _("invalid `override' directive")); continue; } - skip_conditionals: if (ignoring) /* Ignore the line. We continue here so conditionals can appear in the middle of a rule. */ continue; - if (!reading_target && word1eq ("export", 6)) + if (word1eq ("export")) { - struct variable *v; - p2 = next_token (p + 6); + /* 'export' by itself causes everything to be exported. */ if (*p2 == '\0') - export_all_variables = 1; - v = try_variable_definition (&fileinfo, p2, o_file, 0); - if (v != 0) - v->export = v_export; - else - { - unsigned int len; - for (p = find_next_token (&p2, &len); p != 0; - p = find_next_token (&p2, &len)) - { - v = lookup_variable (p, len); - if (v == 0) - v = define_variable_loc (p, len, "", o_file, 0, &fileinfo); - v->export = v_export; - } - } + export_all_variables = 1; + else + { + struct variable *v; + + v = try_variable_definition (fstart, p2, o_file, 0); + if (v != 0) + v->export = v_export; + else + { + unsigned int len; + for (p = find_next_token (&p2, &len); p != 0; + p = find_next_token (&p2, &len)) + { + v = lookup_variable (p, len); + if (v == 0) + v = define_variable_loc (p, len, "", o_file, 0, + fstart); + v->export = v_export; + } + } + } + goto rule_complete; } - else if (!reading_target && word1eq ("unexport", 8)) + + if (word1eq ("unexport")) { - unsigned int len; - struct variable *v; - p2 = next_token (p + 8); if (*p2 == '\0') export_all_variables = 0; - for (p = find_next_token (&p2, &len); p != 0; - p = find_next_token (&p2, &len)) - { - v = lookup_variable (p, len); - if (v == 0) - v = define_variable_loc (p, len, "", o_file, 0, &fileinfo); - v->export = v_noexport; - } + else + { + unsigned int len; + struct variable *v; + for (p = find_next_token (&p2, &len); p != 0; + p = find_next_token (&p2, &len)) + { + v = lookup_variable (p, len); + if (v == 0) + v = define_variable_loc (p, len, "", o_file, 0, fstart); + v->export = v_noexport; + } + } + goto rule_complete; } - else if (word1eq ("vpath", 5)) + + skip_conditionals: + if (word1eq ("vpath")) { char *pattern; unsigned int len; - p2 = variable_expand (p + 5); + p2 = variable_expand (p2); p = find_next_token (&p2, &len); if (p != 0) { @@ -651,22 +732,25 @@ read_makefile (filename, flags) construct_vpath_list (pattern, p); if (pattern != 0) free (pattern); + + goto rule_complete; } - else if (word1eq ("include", 7) || word1eq ("-include", 8) - || word1eq ("sinclude", 8)) + + if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude")) { /* We have found an `include' line specifying a nested makefile to be read at this point. */ - struct conditionals *save, new_conditionals; + struct conditionals *save; + struct conditionals new_conditionals; struct nameseq *files; /* "-include" (vs "include") says no error if the file does not exist. "sinclude" is an alias for this from SGI. */ - int noerror = p[0] != 'i'; + int noerror = (p[0] != 'i'); - p = allocated_variable_expand (next_token (p + (noerror ? 8 : 7))); + p = allocated_variable_expand (p2); if (*p == '\0') { - error (&fileinfo, + error (fstart, _("no file name for `%sinclude'"), noerror ? "-" : ""); continue; } @@ -699,12 +783,12 @@ read_makefile (filename, flags) free ((char *)files); files = next; - r = read_makefile (name, (RM_INCLUDED | RM_NO_TILDE + r = eval_makefile (name, (RM_INCLUDED | RM_NO_TILDE | (noerror ? RM_DONTCARE : 0))); if (!r) { if (!noerror) - error (&fileinfo, "%s: %s", name, strerror (errno)); + error (fstart, "%s: %s", name, strerror (errno)); free (name); } } @@ -717,387 +801,386 @@ read_makefile (filename, flags) /* Restore state. */ conditionals = save; - reading_file = &fileinfo; + + goto rule_complete; } -#undef word1eq - else if (try_variable_definition (&fileinfo, p, o_file, 0)) + + if (try_variable_definition (fstart, p, o_file, 0)) /* This line has been dealt with. */ - ; - else if (lb.buffer[0] == '\t') + goto rule_complete; + + if (line[0] == '\t') { - p = collapsed; /* Ignore comments. */ + p = collapsed; /* Ignore comments, etc. */ while (isblank ((unsigned char)*p)) ++p; if (*p == '\0') /* The line is completely blank; that is harmless. */ continue; + /* This line starts with a tab but was not caught above because there was no preceding target, and the line might have been usable as a variable definition. - But now it is definitely lossage. */ - fatal(&fileinfo, _("commands commence before first target")); + But now we know it is definitely lossage. */ + fatal(fstart, _("commands commence before first target")); } - else - { - /* This line describes some target files. This is complicated by - the existence of target-specific variables, because we can't - expand the entire line until we know if we have one or not. So - we expand the line word by word until we find the first `:', - then check to see if it's a target-specific variable. - In this algorithm, `lb_next' will point to the beginning of the - unexpanded parts of the input buffer, while `p2' points to the - parts of the expanded buffer we haven't searched yet. */ + /* This line describes some target files. This is complicated by + the existence of target-specific variables, because we can't + expand the entire line until we know if we have one or not. So + we expand the line word by word until we find the first `:', + then check to see if it's a target-specific variable. - enum make_word_type wtype; - enum variable_origin v_origin; - char *cmdleft, *semip, *lb_next; - unsigned int len, plen = 0; - char *colonp; + In this algorithm, `lb_next' will point to the beginning of the + unexpanded parts of the input buffer, while `p2' points to the + parts of the expanded buffer we haven't searched yet. */ - /* Record the previous rule. */ - - record_waiting_files (); - tgts_started = fileinfo.lineno; - - /* Search the line for an unquoted ; that is not after an - unquoted #. */ - cmdleft = find_char_unquote (lb.buffer, ";#", 0); - if (cmdleft != 0 && *cmdleft == '#') - { - /* We found a comment before a semicolon. */ - *cmdleft = '\0'; - cmdleft = 0; - } - else if (cmdleft != 0) - /* Found one. Cut the line short there before expanding it. */ - *(cmdleft++) = '\0'; - semip = cmdleft; - - collapse_continuations (lb.buffer); - - /* We can't expand the entire line, since if it's a per-target - variable we don't want to expand it. So, walk from the - beginning, expanding as we go, and looking for "interesting" - chars. The first word is always expandable. */ - wtype = get_next_mword(lb.buffer, NULL, &lb_next, &len); - switch (wtype) - { - case w_eol: - if (cmdleft != 0) - fatal(&fileinfo, _("missing rule before commands")); - /* This line contained something but turned out to be nothing - but whitespace (a comment?). */ - continue; - - case w_colon: - case w_dcolon: - /* We accept and ignore rules without targets for - compatibility with SunOS 4 make. */ - no_targets = 1; - continue; - - default: - break; - } - - p2 = variable_expand_string(NULL, lb_next, len); - while (1) - { - lb_next += len; - if (cmdleft == 0) - { - /* Look for a semicolon in the expanded line. */ - cmdleft = find_char_unquote (p2, ";", 0); - - if (cmdleft != 0) - { - unsigned long p2_off = p2 - variable_buffer; - unsigned long cmd_off = cmdleft - variable_buffer; - char *pend = p2 + strlen(p2); - - /* Append any remnants of lb, then cut the line short - at the semicolon. */ - *cmdleft = '\0'; - - /* One school of thought says that you shouldn't expand - here, but merely copy, since now you're beyond a ";" - and into a command script. However, the old parser - expanded the whole line, so we continue that for - backwards-compatiblity. Also, it wouldn't be - entirely consistent, since we do an unconditional - expand below once we know we don't have a - target-specific variable. */ - (void)variable_expand_string(pend, lb_next, (long)-1); - lb_next += strlen(lb_next); - p2 = variable_buffer + p2_off; - cmdleft = variable_buffer + cmd_off + 1; - } - } - - colonp = find_char_unquote(p2, ":", 0); + { + enum make_word_type wtype; + enum variable_origin v_origin; + char *cmdleft, *semip, *lb_next; + unsigned int len, plen = 0; + char *colonp; + + /* Record the previous rule. */ + + record_waiting_files (); + tgts_started = fstart->lineno; + + /* Search the line for an unquoted ; that is not after an + unquoted #. */ + cmdleft = find_char_unquote (line, ";#", 0); + if (cmdleft != 0 && *cmdleft == '#') + { + /* We found a comment before a semicolon. */ + *cmdleft = '\0'; + cmdleft = 0; + } + else if (cmdleft != 0) + /* Found one. Cut the line short there before expanding it. */ + *(cmdleft++) = '\0'; + semip = cmdleft; + + collapse_continuations (line); + + /* We can't expand the entire line, since if it's a per-target + variable we don't want to expand it. So, walk from the + beginning, expanding as we go, and looking for "interesting" + chars. The first word is always expandable. */ + wtype = get_next_mword(line, NULL, &lb_next, &len); + switch (wtype) + { + case w_eol: + if (cmdleft != 0) + fatal(fstart, _("missing rule before commands")); + /* This line contained something but turned out to be nothing + but whitespace (a comment?). */ + continue; + + case w_colon: + case w_dcolon: + /* We accept and ignore rules without targets for + compatibility with SunOS 4 make. */ + no_targets = 1; + continue; + + default: + break; + } + + p2 = variable_expand_string(NULL, lb_next, len); + while (1) + { + lb_next += len; + if (cmdleft == 0) + { + /* Look for a semicolon in the expanded line. */ + cmdleft = find_char_unquote (p2, ";", 0); + + if (cmdleft != 0) + { + unsigned long p2_off = p2 - variable_buffer; + unsigned long cmd_off = cmdleft - variable_buffer; + char *pend = p2 + strlen(p2); + + /* Append any remnants of lb, then cut the line short + at the semicolon. */ + *cmdleft = '\0'; + + /* One school of thought says that you shouldn't expand + here, but merely copy, since now you're beyond a ";" + and into a command script. However, the old parser + expanded the whole line, so we continue that for + backwards-compatiblity. Also, it wouldn't be + entirely consistent, since we do an unconditional + expand below once we know we don't have a + target-specific variable. */ + (void)variable_expand_string(pend, lb_next, (long)-1); + lb_next += strlen(lb_next); + p2 = variable_buffer + p2_off; + cmdleft = variable_buffer + cmd_off + 1; + } + } + + colonp = find_char_unquote(p2, ":", 0); #if defined(__MSDOS__) || defined(WINDOWS32) - /* The drive spec brain-damage strikes again... */ - /* Note that the only separators of targets in this context - are whitespace and a left paren. If others are possible, - they should be added to the string in the call to index. */ - while (colonp && (colonp[1] == '/' || colonp[1] == '\\') && - colonp > p2 && isalpha ((unsigned char)colonp[-1]) && - (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0)) - colonp = find_char_unquote(colonp + 1, ":", 0); + /* The drive spec brain-damage strikes again... */ + /* Note that the only separators of targets in this context + are whitespace and a left paren. If others are possible, + they should be added to the string in the call to index. */ + while (colonp && (colonp[1] == '/' || colonp[1] == '\\') && + colonp > p2 && isalpha ((unsigned char)colonp[-1]) && + (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0)) + colonp = find_char_unquote(colonp + 1, ":", 0); #endif - if (colonp != 0) - break; - - wtype = get_next_mword(lb_next, NULL, &lb_next, &len); - if (wtype == w_eol) - break; - - p2 += strlen(p2); - *(p2++) = ' '; - p2 = variable_expand_string(p2, lb_next, len); - /* We don't need to worry about cmdleft here, because if it was - found in the variable_buffer the entire buffer has already - been expanded... we'll never get here. */ - } - - p2 = next_token (variable_buffer); - - /* If the word we're looking at is EOL, see if there's _anything_ - on the line. If not, a variable expanded to nothing, so ignore - it. If so, we can't parse this line so punt. */ - if (wtype == w_eol) - { - if (*p2 != '\0') - /* There's no need to be ivory-tower about this: check for - one of the most common bugs found in makefiles... */ - fatal (&fileinfo, _("missing separator%s"), - !strneq(lb.buffer, " ", 8) ? "" - : _(" (did you mean TAB instead of 8 spaces?)")); - continue; - } - - /* Make the colon the end-of-string so we know where to stop - looking for targets. */ - *colonp = '\0'; - filenames = multi_glob (parse_file_seq (&p2, '\0', - sizeof (struct nameseq), - 1), - sizeof (struct nameseq)); - *p2 = ':'; - - if (!filenames) - { - /* We accept and ignore rules without targets for - compatibility with SunOS 4 make. */ - no_targets = 1; - continue; - } - /* This should never be possible; we handled it above. */ - assert (*p2 != '\0'); - ++p2; - - /* Is this a one-colon or two-colon entry? */ - two_colon = *p2 == ':'; - if (two_colon) - p2++; - - /* Test to see if it's a target-specific variable. Copy the rest - of the buffer over, possibly temporarily (we'll expand it later - if it's not a target-specific variable). PLEN saves the length - of the unparsed section of p2, for later. */ - if (*lb_next != '\0') - { - unsigned int l = p2 - variable_buffer; - plen = strlen (p2); - (void) variable_buffer_output (p2+plen, - lb_next, strlen (lb_next)+1); - p2 = variable_buffer + l; - } - - /* See if it's an "override" keyword; if so see if what comes after - it looks like a variable definition. */ - - wtype = get_next_mword (p2, NULL, &p, &len); - - v_origin = o_file; - if (wtype == w_static && (len == (sizeof ("override")-1) - && strneq (p, "override", len))) - { - v_origin = o_override; - wtype = get_next_mword (p+len, NULL, &p, &len); - } - - if (wtype != w_eol) - wtype = get_next_mword (p+len, NULL, NULL, NULL); - - if (wtype == w_varassign) - { - /* If there was a semicolon found, add it back, plus anything - after it. */ - if (semip) - { - *(--semip) = ';'; - variable_buffer_output (p2 + strlen (p2), - semip, strlen (semip)+1); - } - record_target_var (filenames, p, two_colon, v_origin, &fileinfo); - filenames = 0; - continue; - } - - /* This is a normal target, _not_ a target-specific variable. - Unquote any = in the dependency list. */ - find_char_unquote (lb_next, "=", 0); - - /* We have some targets, so don't ignore the following commands. */ - no_targets = 0; + if (colonp != 0) + break; - /* Expand the dependencies, etc. */ - if (*lb_next != '\0') - { - unsigned int l = p2 - variable_buffer; - (void) variable_expand_string (p2 + plen, lb_next, (long)-1); - p2 = variable_buffer + l; + wtype = get_next_mword(lb_next, NULL, &lb_next, &len); + if (wtype == w_eol) + break; - /* Look for a semicolon in the expanded line. */ - if (cmdleft == 0) - { - cmdleft = find_char_unquote (p2, ";", 0); - if (cmdleft != 0) - *(cmdleft++) = '\0'; - } - } + p2 += strlen(p2); + *(p2++) = ' '; + p2 = variable_expand_string(p2, lb_next, len); + /* We don't need to worry about cmdleft here, because if it was + found in the variable_buffer the entire buffer has already + been expanded... we'll never get here. */ + } + + p2 = next_token (variable_buffer); + + /* If the word we're looking at is EOL, see if there's _anything_ + on the line. If not, a variable expanded to nothing, so ignore + it. If so, we can't parse this line so punt. */ + if (wtype == w_eol) + { + if (*p2 != '\0') + /* There's no need to be ivory-tower about this: check for + one of the most common bugs found in makefiles... */ + fatal (fstart, _("missing separator%s"), + !strneq(line, " ", 8) ? "" + : _(" (did you mean TAB instead of 8 spaces?)")); + continue; + } + + /* Make the colon the end-of-string so we know where to stop + looking for targets. */ + *colonp = '\0'; + filenames = multi_glob (parse_file_seq (&p2, '\0', + sizeof (struct nameseq), + 1), + sizeof (struct nameseq)); + *p2 = ':'; + + if (!filenames) + { + /* We accept and ignore rules without targets for + compatibility with SunOS 4 make. */ + no_targets = 1; + continue; + } + /* This should never be possible; we handled it above. */ + assert (*p2 != '\0'); + ++p2; - /* Is this a static pattern rule: `target: %targ: %dep; ...'? */ - p = strchr (p2, ':'); - while (p != 0 && p[-1] == '\\') - { - register char *q = &p[-1]; - register int backslash = 0; - while (*q-- == '\\') - backslash = !backslash; - if (backslash) - p = strchr (p + 1, ':'); - else - break; - } + /* Is this a one-colon or two-colon entry? */ + two_colon = *p2 == ':'; + if (two_colon) + p2++; + + /* Test to see if it's a target-specific variable. Copy the rest + of the buffer over, possibly temporarily (we'll expand it later + if it's not a target-specific variable). PLEN saves the length + of the unparsed section of p2, for later. */ + if (*lb_next != '\0') + { + unsigned int l = p2 - variable_buffer; + plen = strlen (p2); + (void) variable_buffer_output (p2+plen, + lb_next, strlen (lb_next)+1); + p2 = variable_buffer + l; + } + + /* See if it's an "override" keyword; if so see if what comes after + it looks like a variable definition. */ + + wtype = get_next_mword (p2, NULL, &p, &len); + + v_origin = o_file; + if (wtype == w_static && word1eq ("override")) + { + v_origin = o_override; + wtype = get_next_mword (p+len, NULL, &p, &len); + } + + if (wtype != w_eol) + wtype = get_next_mword (p+len, NULL, NULL, NULL); + + if (wtype == w_varassign) + { + /* If there was a semicolon found, add it back, plus anything + after it. */ + if (semip) + { + *(--semip) = ';'; + variable_buffer_output (p2 + strlen (p2), + semip, strlen (semip)+1); + } + record_target_var (filenames, p, two_colon, v_origin, fstart); + filenames = 0; + continue; + } + + /* This is a normal target, _not_ a target-specific variable. + Unquote any = in the dependency list. */ + find_char_unquote (lb_next, "=", 0); + + /* We have some targets, so don't ignore the following commands. */ + no_targets = 0; + + /* Expand the dependencies, etc. */ + if (*lb_next != '\0') + { + unsigned int l = p2 - variable_buffer; + (void) variable_expand_string (p2 + plen, lb_next, (long)-1); + p2 = variable_buffer + l; + + /* Look for a semicolon in the expanded line. */ + if (cmdleft == 0) + { + cmdleft = find_char_unquote (p2, ";", 0); + if (cmdleft != 0) + *(cmdleft++) = '\0'; + } + } + + /* Is this a static pattern rule: `target: %targ: %dep; ...'? */ + p = strchr (p2, ':'); + while (p != 0 && p[-1] == '\\') + { + register char *q = &p[-1]; + register int backslash = 0; + while (*q-- == '\\') + backslash = !backslash; + if (backslash) + p = strchr (p + 1, ':'); + else + break; + } #ifdef _AMIGA - /* Here, the situation is quite complicated. Let's have a look - at a couple of targets: + /* Here, the situation is quite complicated. Let's have a look + at a couple of targets: - install: dev:make + install: dev:make - dev:make: make + dev:make: make - dev:make:: xyz + dev:make:: xyz - The rule is that it's only a target, if there are TWO :'s - OR a space around the :. - */ - if (p && !(isspace ((unsigned char)p[1]) || !p[1] - || isspace ((unsigned char)p[-1]))) - p = 0; + The rule is that it's only a target, if there are TWO :'s + OR a space around the :. + */ + if (p && !(isspace ((unsigned char)p[1]) || !p[1] + || isspace ((unsigned char)p[-1]))) + p = 0; #endif #if defined (WINDOWS32) || defined (__MSDOS__) - do { - check_again = 0; - /* For MSDOS and WINDOWS32, skip a "C:\..." or a "C:/..." */ - if (p != 0 && (p[1] == '\\' || p[1] == '/') && - isalpha ((unsigned char)p[-1]) && - (p == p2 + 1 || strchr (" \t:(", p[-2]) != 0)) { - p = strchr (p + 1, ':'); - check_again = 1; - } - } while (check_again); + do { + check_again = 0; + /* For MSDOS and WINDOWS32, skip a "C:\..." or a "C:/..." */ + if (p != 0 && (p[1] == '\\' || p[1] == '/') && + isalpha ((unsigned char)p[-1]) && + (p == p2 + 1 || strchr (" \t:(", p[-2]) != 0)) { + p = strchr (p + 1, ':'); + check_again = 1; + } + } while (check_again); #endif - if (p != 0) - { - struct nameseq *target; - target = parse_file_seq (&p2, ':', sizeof (struct nameseq), 1); - ++p2; - if (target == 0) - fatal (&fileinfo, _("missing target pattern")); - else if (target->next != 0) - fatal (&fileinfo, _("multiple target patterns")); - pattern = target->name; - pattern_percent = find_percent (pattern); - if (pattern_percent == 0) - fatal (&fileinfo, _("target pattern contains no `%%'")); - free((char *)target); - } - else - pattern = 0; - - /* Parse the dependencies. */ - deps = (struct dep *) - multi_glob (parse_file_seq (&p2, '\0', sizeof (struct dep), 1), - sizeof (struct dep)); - - commands_idx = 0; - if (cmdleft != 0) - { - /* Semicolon means rest of line is a command. */ - unsigned int len = strlen (cmdleft); - - cmds_started = fileinfo.lineno; - - /* Add this command line to the buffer. */ - if (len + 2 > commands_len) - { - commands_len = (len + 2) * 2; - commands = (char *) xrealloc (commands, commands_len); - } - bcopy (cmdleft, commands, len); - commands_idx += len; - commands[commands_idx++] = '\n'; - } - - continue; - } + if (p != 0) + { + struct nameseq *target; + target = parse_file_seq (&p2, ':', sizeof (struct nameseq), 1); + ++p2; + if (target == 0) + fatal (fstart, _("missing target pattern")); + else if (target->next != 0) + fatal (fstart, _("multiple target patterns")); + pattern = target->name; + pattern_percent = find_percent (pattern); + if (pattern_percent == 0) + fatal (fstart, _("target pattern contains no `%%'")); + free((char *)target); + } + else + pattern = 0; + + /* Parse the dependencies. */ + deps = (struct dep *) + multi_glob (parse_file_seq (&p2, '\0', sizeof (struct dep), 1), + sizeof (struct dep)); + + commands_idx = 0; + if (cmdleft != 0) + { + /* Semicolon means rest of line is a command. */ + unsigned int len = strlen (cmdleft); + + cmds_started = fstart->lineno; + + /* Add this command line to the buffer. */ + if (len + 2 > commands_len) + { + commands_len = (len + 2) * 2; + commands = (char *) xrealloc (commands, commands_len); + } + bcopy (cmdleft, commands, len); + commands_idx += len; + commands[commands_idx++] = '\n'; + } + + continue; + } /* We get here except in the case that we just read a rule line. Record now the last rule we read, so following spurious commands are properly diagnosed. */ + rule_complete: record_waiting_files (); - no_targets = 0; } +#undef word1eq + if (conditionals->if_cmds) - fatal (&fileinfo, _("missing `endif'")); + fatal (fstart, _("missing `endif'")); /* At eof, record the last rule. */ record_waiting_files (); - freebuffer (&lb); free ((char *) commands); - fclose (infile); - - reading_file = 0; return 1; } + /* Execute a `define' directive. The first line has already been read, and NAME is the name of - the variable to be defined. The following lines remain to be read. - LINENO, INFILE and FILENAME refer to the makefile being read. - The value returned is LINENO, updated for lines read here. */ + the variable to be defined. The following lines remain to be read. */ static void -do_define (name, namelen, origin, infile, flocp) +do_define (name, namelen, origin, ebuf) char *name; unsigned int namelen; enum variable_origin origin; - FILE *infile; - struct floc *flocp; + struct ebuffer *ebuf; { - struct linebuffer lb; - unsigned int nlines = 0; + struct floc defstart; + long nlines = 0; + int nlevels = 1; unsigned int length = 100; - char *definition = (char *) xmalloc (100); - register unsigned int idx = 0; - register char *p; + char *definition = (char *) xmalloc (length); + unsigned int idx = 0; + char *p; /* Expand the variable name. */ char *var = (char *) alloca (namelen + 1); @@ -1105,55 +1188,82 @@ do_define (name, namelen, origin, infile, flocp) var[namelen] = '\0'; var = variable_expand (var); - initbuffer (&lb); - while (!feof (infile)) + defstart = ebuf->floc; + + while (1) { unsigned int len; + char *line; - flocp->lineno += nlines; - nlines = readline (&lb, infile, flocp); + ebuf->floc.lineno += nlines; + nlines = readline (ebuf); - collapse_continuations (lb.buffer); + /* If there is nothing left to eval, we're done. */ + if (nlines < 0) + break; - p = next_token (lb.buffer); - len = strlen (p); - if ((len == 5 || (len > 5 && isblank ((unsigned char)p[5]))) - && strneq (p, "endef", 5)) - { - p += 5; - remove_comments (p); - if (*next_token (p) != '\0') - error (flocp, _("Extraneous text after `endef' directive")); - /* Define the variable. */ - if (idx == 0) - definition[0] = '\0'; - else - definition[idx - 1] = '\0'; - (void) define_variable_loc (var, strlen (var), definition, origin, - 1, flocp); - free (definition); - freebuffer (&lb); - return; - } - else - { - len = strlen (lb.buffer); - /* Increase the buffer size if necessary. */ - if (idx + len + 1 > length) - { - length = (idx + len) * 2; - definition = (char *) xrealloc (definition, length + 1); - } + line = ebuf->buffer; - bcopy (lb.buffer, &definition[idx], len); - idx += len; - /* Separate lines with a newline. */ - definition[idx++] = '\n'; - } + collapse_continuations (line); + + /* If the line doesn't begin with a tab, test to see if it introduces + another define, or ends one. */ + + /* Stop if we find an 'endef' */ + if (line[0] != '\t') + { + p = next_token (line); + len = strlen (p); + + /* If this is another 'define', increment the level count. */ + if ((len == 6 || (len > 6 && isblank ((unsigned char)p[6]))) + && strneq (p, "define", 6)) + ++nlevels; + + /* If this is an 'endef', decrement the count. If it's now 0, + we've found the last one. */ + else if ((len == 5 || (len > 5 && isblank ((unsigned char)p[5]))) + && strneq (p, "endef", 5)) + { + p += 5; + remove_comments (p); + if (*next_token (p) != '\0') + error (&ebuf->floc, + _("Extraneous text after `endef' directive")); + + if (--nlevels == 0) + { + /* Define the variable. */ + if (idx == 0) + definition[0] = '\0'; + else + definition[idx - 1] = '\0'; + + /* Always define these variables in the global set. */ + define_variable_global (var, strlen (var), definition, + origin, 1, &defstart); + free (definition); + return; + } + } + } + + /* Otherwise add this line to the variable definition. */ + len = strlen (line); + if (idx + len + 1 > length) + { + length = (idx + len) * 2; + definition = (char *) xrealloc (definition, length + 1); + } + + bcopy (line, &definition[idx], len); + idx += len; + /* Separate lines with a newline. */ + definition[idx++] = '\n'; } /* No `endef'!! */ - fatal (flocp, _("missing `endef', unterminated `define'")); + fatal (&defstart, _("missing `endef', unterminated `define'")); /* NOTREACHED */ return; @@ -2131,25 +2241,74 @@ parse_file_seq (stringp, stopchar, size, strip) return new; } -/* Read a line of text from STREAM into LINEBUFFER. - Combine continuation lines into one line. - Return the number of actual lines read (> 1 if hacked continuation lines). +/* Find the next line of text in an eval buffer, combining continuation lines + into one line. + Return the number of actual lines read (> 1 if continuation lines). + Returns -1 if there's nothing left in the buffer. + + After this function, ebuf->buffer points to the first character of the + line we just found. + */ + +/* Read a line of text from a STRING. + Since we aren't really reading from a file, don't bother with linenumbers. */ static unsigned long -readline (linebuffer, stream, flocp) - struct linebuffer *linebuffer; - FILE *stream; - const struct floc *flocp; +readstring (ebuf) + struct ebuffer *ebuf; +{ + char *p; + + /* If there is nothing left in this buffer, return 0. */ + if (ebuf->bufnext > ebuf->bufstart + ebuf->size) + return -1; + + /* Set up a new starting point for the buffer, and find the end of the + next logical line (taking into account backslash/newline pairs). */ + + p = ebuf->buffer = ebuf->bufnext; + + while (1) + { + int backslash = 0; + + /* Find the next newline. Keep track of backslashes as we look. */ + for (; *p != '\n' && *p != '\0'; ++p) + if (*p == '\\') + backslash = !backslash; + + /* If we got to the end of the string or a newline with no backslash, + we're done. */ + if (*p == '\0' || !backslash) + break; + } + + /* Overwrite the newline char. */ + *p = '\0'; + ebuf->bufnext = p+1; + + return 0; +} + +static long +readline (ebuf) + struct ebuffer *ebuf; { - char *buffer = linebuffer->buffer; - register char *p = linebuffer->buffer; - register char *end = p + linebuffer->size; - register unsigned int nlines = 0; + char *buffer = ebuf->buffer; + char *p = ebuf->buffer; + char *end = p + ebuf->size; + long nlines = 0; + + /* The behaviors between string and stream buffers are different enough to + warrant different functions. Do the Right Thing. */ + + if (!ebuf->fp) + return readstring (ebuf); *p = '\0'; - while (fgets (p, end - p, stream) != 0) + while (fgets (p, end - p, ebuf->fp) != 0) { char *p2; unsigned long len; @@ -2163,7 +2322,8 @@ readline (linebuffer, stream, flocp) lossage strikes again! (xmkmf puts NULs in its makefiles.) There is nothing really to be done; we synthesize a newline so the following line doesn't appear to be part of this line. */ - error (flocp, _("warning: NUL character seen; rest of line ignored")); + error (&ebuf->floc, + _("warning: NUL character seen; rest of line ignored")); p[0] = '\n'; len = 1; } @@ -2176,11 +2336,11 @@ readline (linebuffer, stream, flocp) if (p[-1] != '\n') { unsigned long p_off = p - buffer; - linebuffer->size *= 2; - buffer = (char *) xrealloc (buffer, linebuffer->size); + ebuf->size *= 2; + buffer = (char *) xrealloc (buffer, ebuf->size); p = buffer + p_off; - end = buffer + linebuffer->size; - linebuffer->buffer = buffer; + end = buffer + ebuf->size; + ebuf->buffer = buffer; *p = '\0'; continue; } @@ -2215,19 +2375,19 @@ readline (linebuffer, stream, flocp) if (end - p <= 1) { /* Enlarge the buffer. */ - register unsigned int p_off = p - buffer; - linebuffer->size *= 2; - buffer = (char *) xrealloc (buffer, linebuffer->size); + unsigned int p_off = p - buffer; + ebuf->size *= 2; + buffer = (char *) xrealloc (buffer, ebuf->size); p = buffer + p_off; - end = buffer + linebuffer->size; - linebuffer->buffer = buffer; + end = buffer + ebuf->size; + ebuf->buffer = buffer; } } - if (ferror (stream)) - pfatal_with_name (flocp->filenm); + if (ferror (ebuf->fp)) + pfatal_with_name (ebuf->floc.filenm); - return nlines; + return nlines ? nlines : -1; } /* Parse the next "makefile word" from the input buffer, and return info diff --git a/remake.c b/remake.c index ae5f37c..084816b 100644 --- a/remake.c +++ b/remake.c @@ -706,6 +706,7 @@ notice_finished_file (file) { struct dep *d; int ran = file->command_state == cs_running; + int touched = 0; file->command_state = cs_finished; file->updated = 1; @@ -734,24 +735,36 @@ notice_finished_file (file) if (file->phony) file->update_status = 0; else - /* Should set file's modification date and do nothing else. */ - file->update_status = touch_file (file); + { + /* Should set file's modification date and do nothing else. */ + file->update_status = touch_file (file); + + /* Pretend we ran a real touch command, to suppress the + "`foo' is up to date" message. */ + commands_started++; + + /* Request for the timestamp to be updated (and distributed + to the double-colon entries). Simply setting ran=1 would + almost have done the trick, but messes up with the also_make + updating logic below. */ + touched = 1; + } } } if (file->mtime_before_update == UNKNOWN_MTIME) file->mtime_before_update = file->last_mtime; - if (ran && !file->phony) + if ((ran && !file->phony) || touched) { struct file *f; int i = 0; - /* If -n or -q and all the commands are recursive, we ran them so + /* If -n, -t, or -q and all the commands are recursive, we ran them so really check the target's mtime again. Otherwise, assume the target would have been updated. */ - if (question_flag || just_print_flag) + if (question_flag || just_print_flag || touch_flag) { for (i = file->cmds->ncommand_lines; i > 0; --i) if (! (file->cmds->lines_flags[i-1] & COMMANDS_RECURSE)) diff --git a/tests/ChangeLog b/tests/ChangeLog index b38d5db..aa5f78d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2002-07-07 Paul D. Smith + + * scripts/functions/eval: Test new function. + * scripts/functions/value: Test new function. + * scripts/variables/MAKEFILE_LIST: Test new variable. + 2002-04-28 Paul D. Smith * scripts/functions/call: New test: transitive closure diff --git a/tests/scripts/functions/eval b/tests/scripts/functions/eval new file mode 100644 index 0000000..0d5e3b8 --- /dev/null +++ b/tests/scripts/functions/eval @@ -0,0 +1,60 @@ +# -*-perl-*- + +$description = "Test the eval function."; + +$details = "This is a test of the eval function in GNU make. +This function will evaluate inline makefile syntax and incorporate the +results into its internal database.\n"; + +open(MAKEFILE,"> $makefile"); + +print MAKEFILE <<'EOF'; +define Y + all:: ; @echo $AA + A = B +endef + +X = $(eval $(value Y)) + +$(eval $(shell echo A = A)) +$(eval $(Y)) +$(eval A = C) +$(eval $(X)) +EOF + +close(MAKEFILE); + +&run_make_with_options($makefile, "", &get_logfile); + +# Create the answer to what should be produced by this Makefile +$answer = "AA\nBA\n"; + +&compare_output($answer,&get_logfile(1)); + +# Test to make sure defining variables when we have extra scope pushed works +# as expected. + +$makefile2 = &get_tmpfile; + +open(MAKEFILE,"> $makefile2"); + +print MAKEFILE <<'EOF'; +VARS = A B + +VARSET = $(1) = $(2) + +$(foreach v,$(VARS),$(eval $(call VARSET,$v,$v))) + +all: ; @echo A = $(A) B = $(B) +EOF + +close(MAKEFILE); + +&run_make_with_options($makefile2, "", &get_logfile); + +# Create the answer to what should be produced by this Makefile +$answer = "A = A B = B\n"; + +&compare_output($answer,&get_logfile(1)); + +1; diff --git a/tests/scripts/functions/value b/tests/scripts/functions/value new file mode 100644 index 0000000..8e1a6f0 --- /dev/null +++ b/tests/scripts/functions/value @@ -0,0 +1,30 @@ +# -*-perl-*- + +$description = "Test the value function."; + +$details = "This is a test of the value function in GNU make. +This function will evaluate to the value of the named variable with no +further expansion performed on it.\n"; + +open(MAKEFILE,"> $makefile"); + +print MAKEFILE <<'EOF'; +export FOO = foo + +recurse = FOO = $FOO +static := FOO = $(value FOO) + +all: ; @echo $(recurse) $(value recurse) $(static) $(value static) +EOF + +close(MAKEFILE); + +&run_make_with_options($makefile, "", &get_logfile); + +# Create the answer to what should be produced by this Makefile +$answer = "FOO = OO FOO = foo FOO = foo FOO = foo\n"; + + +&compare_output($answer,&get_logfile(1)); + +1; diff --git a/tests/scripts/variables/MAKEFILE_LIST b/tests/scripts/variables/MAKEFILE_LIST new file mode 100644 index 0000000..076e42d --- /dev/null +++ b/tests/scripts/variables/MAKEFILE_LIST @@ -0,0 +1,30 @@ +# -*-perl-*- + +$description = "Test the MAKEFILE_LIST variable."; + +$makefile2 = &get_tmpfile; + +open(MAKEFILE,"> $makefile"); +print MAKEFILE < $makefile2"); +print MAKEFILE "m2 := \$(MAKEFILE_LIST)\n"; +close(MAKEFILE); + + +&run_make_with_options($makefile, "", &get_logfile); +$answer = "$makefile\n$makefile $makefile2\n$makefile $makefile2\n"; +&compare_output($answer,&get_logfile(1)); + +1; diff --git a/tests/scripts/variables/flavors b/tests/scripts/variables/flavors index 02dca0b..7c98afd 100644 --- a/tests/scripts/variables/flavors +++ b/tests/scripts/variables/flavors @@ -37,6 +37,16 @@ define endef endif +define outer + define inner + A = B + endef +endef + +$(eval $(outer)) + +outer: ; @echo $(inner) + EOF # END of Contents of MAKEFILE @@ -64,5 +74,12 @@ $answer = "later foo bar\n"; $answer = "$makefile:23: *** empty variable name. Stop.\n"; &compare_output($answer, &get_logfile(1)); +# TEST #4 +# ------- + +&run_make_with_options($makefile, "outer", &get_logfile); +$answer = "A = B\n"; +&compare_output($answer, &get_logfile(1)); + 1; diff --git a/variable.c b/variable.c index 148e081..ca9265c 100644 --- a/variable.c +++ b/variable.c @@ -57,7 +57,7 @@ struct variable_set_list *current_variable_set_list = &global_setlist; struct variable * define_variable_in_set (name, length, value, origin, recursive, set, flocp) - char *name; + const char *name; unsigned int length; char *value; enum variable_origin origin; @@ -69,6 +69,9 @@ define_variable_in_set (name, length, value, origin, recursive, set, flocp) register unsigned int hashval; register struct variable *v; + if (set == NULL) + set = &global_variable_set; + hashval = 0; for (i = 0; i < length; ++i) HASH (hashval, name[i]); @@ -741,117 +744,27 @@ target_environment (file) return result; } -/* Try to interpret LINE (a null-terminated string) as a variable definition. - - ORIGIN may be o_file, o_override, o_env, o_env_override, - or o_command specifying that the variable definition comes - from a makefile, an override directive, the environment with - or without the -e switch, or the command line. - - See the comments for parse_variable_definition(). - - If LINE was recognized as a variable definition, a pointer to its `struct - variable' is returned. If LINE is not a variable definition, NULL is - returned. */ +/* Given a variable, a value, and a flavor, define the variable. + See the try_variable_definition() function for details on the parameters. */ struct variable * -try_variable_definition (flocp, line, origin, target_var) +do_variable_definition (flocp, varname, value, origin, flavor, target_var) const struct floc *flocp; - char *line; + const char *varname; + char *value; enum variable_origin origin; + enum variable_flavor flavor; int target_var; { - register int c; - register char *p = line; - register char *beg; - register char *end; - enum { f_bogus, - f_simple, f_recursive, f_append, f_conditional } flavor = f_bogus; - char *name, *expanded_name, *value=0, *alloc_value=NULL; + char *p, *alloc_value = NULL; struct variable *v; int append = 0; - while (1) - { - c = *p++; - if (c == '\0' || c == '#') - return 0; - if (c == '=') - { - end = p - 1; - flavor = f_recursive; - break; - } - else if (c == ':') - if (*p == '=') - { - end = p++ - 1; - flavor = f_simple; - break; - } - else - /* A colon other than := is a rule line, not a variable defn. */ - return 0; - else if (c == '+' && *p == '=') - { - end = p++ - 1; - flavor = f_append; - break; - } - else if (c == '?' && *p == '=') - { - end = p++ - 1; - flavor = f_conditional; - break; - } - else if (c == '$') - { - /* This might begin a variable expansion reference. Make sure we - don't misrecognize chars inside the reference as =, := or +=. */ - char closeparen; - int count; - c = *p++; - if (c == '(') - closeparen = ')'; - else if (c == '{') - closeparen = '}'; - else - continue; /* Nope. */ - - /* P now points past the opening paren or brace. - Count parens or braces until it is matched. */ - count = 0; - for (; *p != '\0'; ++p) - { - if (*p == c) - ++count; - else if (*p == closeparen && --count < 0) - { - ++p; - break; - } - } - } - } - - beg = next_token (line); - while (end > beg && isblank ((unsigned char)end[-1])) - --end; - p = next_token (p); - - /* Expand the name, so "$(foo)bar = baz" works. */ - name = (char *) alloca (end - beg + 1); - bcopy (beg, name, end - beg); - name[end - beg] = '\0'; - expanded_name = allocated_variable_expand (name); - - if (expanded_name[0] == '\0') - fatal (flocp, _("empty variable name")); - /* Calculate the variable's new value in VALUE. */ switch (flavor) { + default: case f_bogus: /* Should not be possible. */ abort (); @@ -860,23 +773,21 @@ try_variable_definition (flocp, line, origin, target_var) We have to allocate memory since otherwise it'll clobber the variable buffer, and we may still need that if we're looking at a target-specific variable. */ - value = alloc_value = allocated_variable_expand (p); + p = alloc_value = allocated_variable_expand (value); break; case f_conditional: /* A conditional variable definition "var ?= value". The value is set IFF the variable is not defined yet. */ - v = lookup_variable(expanded_name, strlen(expanded_name)); + v = lookup_variable (varname, strlen (varname)); if (v) - { - free(expanded_name); - return v; - } + return v; + flavor = f_recursive; /* FALLTHROUGH */ case f_recursive: /* A recursive variable definition "var = value". The value is used verbatim. */ - value = p; + p = value; break; case f_append: { @@ -885,17 +796,17 @@ try_variable_definition (flocp, line, origin, target_var) if (target_var) { append = 1; - v = lookup_variable_in_set (expanded_name, strlen (expanded_name), + v = lookup_variable_in_set (varname, strlen (varname), current_variable_set_list->set); } else - v = lookup_variable (expanded_name, strlen (expanded_name)); + v = lookup_variable (varname, strlen (varname)); if (v == 0) { /* There was no old value. This becomes a normal recursive definition. */ - value = p; + p = value; flavor = f_recursive; } else @@ -904,6 +815,7 @@ try_variable_definition (flocp, line, origin, target_var) unsigned int oldlen, newlen; + p = value; if (v->recursive) /* The previous definition of the variable was recursive. The new value is the unexpanded old and new values. */ @@ -918,10 +830,10 @@ try_variable_definition (flocp, line, origin, target_var) oldlen = strlen (v->value); newlen = strlen (p); - value = (char *) alloca (oldlen + 1 + newlen + 1); - bcopy (v->value, value, oldlen); - value[oldlen] = ' '; - bcopy (p, &value[oldlen + 1], newlen + 1); + p = (char *) alloca (oldlen + 1 + newlen + 1); + bcopy (v->value, p, oldlen); + p[oldlen] = ' '; + bcopy (value, &p[oldlen + 1], newlen + 1); } } } @@ -941,13 +853,13 @@ try_variable_definition (flocp, line, origin, target_var) your $PATH, then SHELL=/usr/local/bin/bash will have the effect of defining SHELL to be "d:/unix/bash.exe". */ if ((origin == o_file || origin == o_override) - && strcmp (expanded_name, "SHELL") == 0) + && strcmp (varname, "SHELL") == 0) { char shellpath[PATH_MAX]; extern char * __dosexec_find_on_path (const char *, char *[], char *); /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc. */ - if (__dosexec_find_on_path (value, (char **)0, shellpath)) + if (__dosexec_find_on_path (p, (char **)0, shellpath)) { char *p; @@ -956,7 +868,7 @@ try_variable_definition (flocp, line, origin, target_var) if (*p == '\\') *p = '/'; } - v = define_variable_loc (expanded_name, strlen (expanded_name), + v = define_variable_loc (varname, strlen (varname), shellpath, origin, flavor == f_recursive, flocp); } @@ -968,16 +880,16 @@ try_variable_definition (flocp, line, origin, target_var) char *fake_env[2]; size_t pathlen = 0; - shellbase = strrchr (value, '/'); - bslash = strrchr (value, '\\'); + shellbase = strrchr (p, '/'); + bslash = strrchr (p, '\\'); if (!shellbase || bslash > shellbase) shellbase = bslash; - if (!shellbase && value[1] == ':') - shellbase = value + 1; + if (!shellbase && p[1] == ':') + shellbase = p + 1; if (shellbase) shellbase++; else - shellbase = value; + shellbase = p; /* Search for the basename of the shell (with standard executable extensions) along the $PATH. */ @@ -997,12 +909,12 @@ try_variable_definition (flocp, line, origin, target_var) if (*p == '\\') *p = '/'; } - v = define_variable_loc (expanded_name, strlen (expanded_name), + v = define_variable_loc (varname, strlen (varname), shellpath, origin, flavor == f_recursive, flocp); } else - v = lookup_variable (expanded_name, strlen (expanded_name)); + v = lookup_variable (varname, strlen (varname)); free (path_string); } @@ -1010,33 +922,157 @@ try_variable_definition (flocp, line, origin, target_var) else #endif /* __MSDOS__ */ #ifdef WINDOWS32 - if ((origin == o_file || origin == o_override) - && strcmp (expanded_name, "SHELL") == 0) + if ((origin == o_file || origin == o_override) && streq (varname, "SHELL")) { - extern char* default_shell; + extern char *default_shell; - /* - * Call shell locator function. If it returns TRUE, then - * set no_default_sh_exe to indicate sh was found and - * set new value for SHELL variable. - */ - if (find_and_set_default_shell(value)) { - v = define_variable_loc (expanded_name, strlen (expanded_name), - default_shell, origin, flavor == f_recursive, - flocp); - no_default_sh_exe = 0; - } + /* Call shell locator function. If it returns TRUE, then + set no_default_sh_exe to indicate sh was found and + set new value for SHELL variable. */ + + if (find_and_set_default_shell (p)) + { + v = define_variable_in_set (varname, strlen (varname), default_shell, + origin, flavor == f_recursive, + (target_var + ? current_variable_set_list->set + : NULL), + flocp); + no_default_sh_exe = 0; + } + else + v = lookup_variable (varname, strlen (varname)); } else #endif - v = define_variable_loc (expanded_name, strlen (expanded_name), value, - origin, flavor == f_recursive, flocp); - + /* If we are defining variables inside an $(eval ...), we might have a + different variable context pushed, not the global context (maybe we're + inside a $(call ...) or something. Since this function is only ever + invoked in places where we want to define globally visible variables, + make sure we define this variable in the global set. */ + + v = define_variable_in_set (varname, strlen (varname), p, + origin, flavor == f_recursive, + (target_var + ? current_variable_set_list->set : NULL), + flocp); v->append = append; if (alloc_value) free (alloc_value); + + return v; +} + +/* Try to interpret LINE (a null-terminated string) as a variable definition. + + ORIGIN may be o_file, o_override, o_env, o_env_override, + or o_command specifying that the variable definition comes + from a makefile, an override directive, the environment with + or without the -e switch, or the command line. + + See the comments for parse_variable_definition(). + + If LINE was recognized as a variable definition, a pointer to its `struct + variable' is returned. If LINE is not a variable definition, NULL is + returned. */ + +struct variable * +try_variable_definition (flocp, line, origin, target_var) + const struct floc *flocp; + char *line; + enum variable_origin origin; + int target_var; +{ + register int c; + register char *p = line; + register char *beg; + register char *end; + enum variable_flavor flavor = f_bogus; + char *name, *expanded_name; + struct variable *v; + + while (1) + { + c = *p++; + if (c == '\0' || c == '#') + return 0; + if (c == '=') + { + end = p - 1; + flavor = f_recursive; + break; + } + else if (c == ':') + if (*p == '=') + { + end = p++ - 1; + flavor = f_simple; + break; + } + else + /* A colon other than := is a rule line, not a variable defn. */ + return 0; + else if (c == '+' && *p == '=') + { + end = p++ - 1; + flavor = f_append; + break; + } + else if (c == '?' && *p == '=') + { + end = p++ - 1; + flavor = f_conditional; + break; + } + else if (c == '$') + { + /* This might begin a variable expansion reference. Make sure we + don't misrecognize chars inside the reference as =, := or +=. */ + char closeparen; + int count; + c = *p++; + if (c == '(') + closeparen = ')'; + else if (c == '{') + closeparen = '}'; + else + continue; /* Nope. */ + + /* P now points past the opening paren or brace. + Count parens or braces until it is matched. */ + count = 0; + for (; *p != '\0'; ++p) + { + if (*p == c) + ++count; + else if (*p == closeparen && --count < 0) + { + ++p; + break; + } + } + } + } + + beg = next_token (line); + while (end > beg && isblank ((unsigned char)end[-1])) + --end; + p = next_token (p); + + /* Expand the name, so "$(foo)bar = baz" works. */ + name = (char *) alloca (end - beg + 1); + bcopy (beg, name, end - beg); + name[end - beg] = '\0'; + expanded_name = allocated_variable_expand (name); + + if (expanded_name[0] == '\0') + fatal (flocp, _("empty variable name")); + + v = do_variable_definition (flocp, expanded_name, p, + origin, flavor, target_var); + free (expanded_name); return v; diff --git a/variable.h b/variable.h index 8d4853f..483427a 100644 --- a/variable.h +++ b/variable.h @@ -31,6 +31,15 @@ enum variable_origin o_invalid /* Core dump time. */ }; +enum variable_flavor + { + f_bogus, /* Bogus (error) */ + f_simple, /* Simple definition (:=) */ + f_recursive, /* Recursive definition (=) */ + f_append, /* Appending definition (+=) */ + f_conditional /* Conditional definition (?=) */ + }; + /* Structure that represents one variable definition. Each bucket of the hash table is a chain of these, chained through `next'. */ @@ -117,6 +126,7 @@ extern void initialize_file_variables PARAMS ((struct file *file, int read)); extern void print_file_variables PARAMS ((struct file *file)); extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix)); extern void merge_variable_set_lists PARAMS ((struct variable_set_list **setlist0, struct variable_set_list *setlist1)); +extern struct variable *do_variable_definition PARAMS ((const struct floc *flocp, const char *name, char *value, enum variable_origin origin, enum variable_flavor flavor, int target_var)); extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var)); extern struct variable *lookup_variable PARAMS ((const char *name, unsigned int length)); @@ -125,7 +135,7 @@ extern struct variable *lookup_variable_in_set PARAMS ((const char *name, const struct variable_set *set)); extern struct variable *define_variable_in_set - PARAMS ((char *name, unsigned int length, char *value, + PARAMS ((const char *name, unsigned int length, char *value, enum variable_origin origin, int recursive, struct variable_set *set, const struct floc *flocp)); @@ -141,6 +151,11 @@ extern struct variable *define_variable_in_set define_variable_in_set((n),(l),(v),(o),(r),\ current_variable_set_list->set,(f)) +/* Define a variable with a location in the global variable set. */ + +#define define_variable_global(n,l,v,o,r,f) \ + define_variable_in_set((n),(l),(v),(o),(r),NULL,(f)) + /* Define a variable in FILE's variable set. */ #define define_variable_for_file(n,l,v,o,r,f) \ -- cgit v1.2.3