Compare commits

...

141 Commits
3.71 ... 3.72.6

Author SHA1 Message Date
Roland McGrath
c5af4810ff (start_job_command): Remember to call notice_finsihed_file under -n when
not recursing.  To do this, consolidate that code under the empty command
case and goto there for the -n case.
1995-02-10 23:44:03 +00:00
Richard M. Stallman
551c4322cb real-clean renamed to maintainer-clean.
Description changed too.
1995-02-07 23:45:48 +00:00
Roland McGrath
e33c50b1e2 [! STDC_HEADERS]: Don't declare qsort. Sun headers declare it int. 1995-02-07 18:36:00 +00:00
Roland McGrath
bc1e6b66f1 (read_makefile): For bogus line starting with tab, ignore it if blank after
removing comments.
1995-02-06 22:58:07 +00:00
Roland McGrath
bbd5e695f5 Cast results of alloca' to char *'. 1995-02-06 22:37:36 +00:00
Roland McGrath
f3cfccf0b8 Cast results of alloca' to char *' in two places. 1995-02-06 22:36:43 +00:00
Roland McGrath
016e1beef5 Check for mktemp. 1995-02-05 23:50:12 +00:00
Roland McGrath
21a8ec0d72 (main) [! HAVE_MKTEMP]: Use tmpnam instead of mktemp. 1995-02-05 23:49:40 +00:00
Roland McGrath
fecd9e661a (make_cv_sysconf_open_max): New check for `sysconf (_SC_OPEN_MAX)'. 1995-02-05 23:45:49 +00:00
Roland McGrath
2914c705e5 Added #undef HAVE_SYSCONF_OPEN_MAX. 1995-02-05 23:36:04 +00:00
Roland McGrath
3f506aaf90 [HAVE_SYSCONF_OPEN_MAX] (getdtablesize): Define as macro using sysconf. 1995-02-05 23:35:39 +00:00
Roland McGrath
75ea6c3ce2 (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.
1995-01-27 09:42:00 +00:00
Roland McGrath
3fb9ebf83f (debug_signal_handler): New function; toggles debug_flag.
(main): Handle SIGUSR1 with that.
1995-01-26 06:29:18 +00:00
Roland McGrath
b4890bdb1c (realclean): Remove Info files. 1995-01-16 20:46:50 +00:00
Roland McGrath
2cbfa1024a (variable_expand): Fix braino in last change. 1995-01-15 16:33:35 +00:00
Roland McGrath
258dad0f9a Fix nits in last change. 1995-01-15 16:32:10 +00:00
Roland McGrath
37358a9a82 (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.
1995-01-15 15:57:48 +00:00
Roland McGrath
e167e0a3c2 (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.
1995-01-15 15:32:37 +00:00
Roland McGrath
7879457545 (construct_command_argv_internal): Handle " quoting too, when no
backslash, $ or ` characters appear inside the quotes.
1995-01-15 13:43:48 +00:00
Roland McGrath
d525f4dd72 (union wait check): If WEXITSTATUS and WTERMSIG are defined, just use int. 1995-01-15 13:23:03 +00:00
Roland McGrath
bd19554ea7 (Foreach Function): Correccion de gramatica espanola. 1995-01-13 06:30:39 +00:00
Roland McGrath
fffc384bfc (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.
1995-01-11 00:14:53 +00:00
Roland McGrath
afd1d69e7d (clean): Don't remove Info files. 1995-01-10 11:30:56 +00:00
Roland McGrath
c1305a1a18 ($(bindir)/make): Fix typo in echo. 1995-01-10 11:29:08 +00:00
Roland McGrath
43d5fbfc88 Fix typo in comment. 1995-01-10 11:28:12 +00:00
Roland McGrath
a4642a6a57 (check): Remove gratuitous target declaration. 1995-01-10 11:27:24 +00:00
Roland McGrath
11ca7f1ead (ETAGS, CTAGS): Don't use -t. 1995-01-07 16:59:15 +00:00
Roland McGrath
4aa992616f Include config.h first. 1995-01-07 16:57:36 +00:00
Roland McGrath
ab0fb2fa6f (ar_name_equal) [cray]: Subtract 1 like [__hpux]. 1995-01-07 16:55:30 +00:00
Roland McGrath
e1dd3bfa4a (decode_switches): For --help, print usage to stdout. 1995-01-07 16:38:08 +00:00
Richard M. Stallman
86238ec9d3 install, uninstall, installdirs should not alter the build dir. 1995-01-04 19:37:36 +00:00
Roland McGrath
2e9779fdb4 (update_file_1): Do set_command_state (FILE, cs_not_started) only if old
state was deps_running.
1994-12-05 17:42:13 +00:00
Roland McGrath
b61a13463d (start_waiting_job): Use set_command_state. 1994-11-29 01:10:47 +00:00
Roland McGrath
d3b9c35c8f (CPPFLAGS): New variable.
(prefix, exec_prefix): Set from @...@.
(compilation loop): Pass $CPPFLAGS to compiler.
1994-11-28 23:06:28 +00:00
Roland McGrath
c50b75b439 (build.sh.in): Make it executable. 1994-11-28 23:02:42 +00:00
Roland McGrath
7376280c33 (globfiles): Add configure.in, configure. 1994-11-28 22:02:23 +00:00
Roland McGrath
3c767901f6 (make-$(version).tar): Rename install.sh to install-sh. 1994-11-28 20:54:38 +00:00
Roland McGrath
c6dfff5f1b (prefix, exec_prefix): Set.
(CPPFLAGS): Filter out @...@.
($(ARCH)/glob/libglob.a): Don't pass down variables.
1994-11-28 20:51:40 +00:00
Roland McGrath
74540a1e91 Abbreviate copyright years. 1994-11-28 20:50:45 +00:00
Roland McGrath
5159db0aa4 (AC_OUTPUT): Don't write glob/Makefile. 1994-11-28 20:48:43 +00:00
Roland McGrath
e495d2380d (AC_CHECK_SYMBOL): Use AC_DEFINE_UNQUOTED. 1994-11-28 20:28:26 +00:00
Roland McGrath
1ed34a0118 Don't check for ranlib. 1994-11-28 20:20:43 +00:00
Roland McGrath
e8f64b2c88 (notice_finished_file): Only mark also_make's as updated if really ran
cmds.
1994-11-23 03:42:34 +00:00
Roland McGrath
4867409da2 Put dnls before random whitespace. 1994-11-15 11:32:39 +00:00
Roland McGrath
f801fc3521 (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).
1994-11-13 10:02:19 +00:00
David J. MacKenzie
b2c0446e71 Explain reason for new filesystem layout. 1994-11-11 04:33:24 +00:00
Roland McGrath
8f98ceb724 Add #undef HAVE_UNION_WAIT. 1994-11-08 02:09:49 +00:00
Roland McGrath
dea9990bc8 Converted to Autoconf v2. 1994-11-08 02:08:24 +00:00
Roland McGrath
e4c43aab3e Test HAVE_DIRENT_H, HAVE_SYS_DIR_H, HAVE_NDIR_H instead of DIRENT, SYSDIR,
NDIR.
1994-11-08 00:14:50 +00:00
Roland McGrath
e55ed78080 (prefix, exec_prefix): Set these from @...@.
(CPPFLAGS): New variable, set from @CPPFLAGS@.
(compiling loop): Pass $CPPFLAGS before $CFLAGS.
1994-11-07 23:42:58 +00:00
Roland McGrath
ca54a0b991 Initial revision 1994-11-07 23:40:44 +00:00
Roland McGrath
e25e2fb7f5 (define_makeflags): When no flags, set WORDS to zero. 1994-11-07 18:57:56 +00:00
Roland McGrath
1a886b6359 (define_makeflags): Terminate properly when FLAGSTRING is empty. 1994-11-06 23:33:55 +00:00
Roland McGrath
b511712f25 (rcs-mark-{alpha,beta}): Let make do the globbing instead of sh. 1994-11-04 21:08:52 +00:00
Roland McGrath
30fcca501f Remove `DRAFT' from edition. 1994-11-04 20:23:23 +00:00
Roland McGrath
806dc4f7c4 (Variables/Recursion): Fix typo. 1994-11-01 08:40:19 +00:00
Roland McGrath
c0163410d2 (start_job_command): When ARGV is nil, only set update_state and call
notice_finished_file if job_next_command returns zero.
1994-11-01 08:34:10 +00:00
Roland McGrath
eac1e9ee66 Doc .DELETE_ON_ERROR.
Doc new MAKEFLAGS/MAKEOVERRIDES.
Doc .IGNORE/.SILENT with deps.
1994-11-01 08:29:31 +00:00
Roland McGrath
8ad5af7c28 (start_job_command): Call notice_finished_file for empty command line. 1994-11-01 06:18:07 +00:00
Roland McGrath
857d7ad256 (snap_deps): Set COMMANDS_SILENT for .SILENT, not COMMANDS_NOERROR. 1994-10-27 06:02:43 +00:00
Roland McGrath
612a29e0dd [alliant && i860] (FSCALE): Move defn before #ifndef FSCALE. 1994-10-27 00:34:56 +00:00
Roland McGrath
462304918c (snap_deps): Set command_flags bits in all :: entries. 1994-10-26 02:49:21 +00:00
Roland McGrath
9d36c92adb (snap_deps): Fix last change. 1994-10-24 23:44:16 +00:00
Roland McGrath
640c4ecd99 (posix_pedantic): Declare it. 1994-10-24 23:11:57 +00:00
Roland McGrath
07f09cfd88 (main): Move checks .IGNORE, .SILENT, .POSIX to snap_deps. 1994-10-24 22:57:07 +00:00
Roland McGrath
d37c9ba18a (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.
1994-10-24 22:56:27 +00:00
Roland McGrath
cc8d6cf343 (start_job_command): In FLAGS initialization, OR in
CHILD->file->command_flags.
1994-10-24 22:50:01 +00:00
Roland McGrath
4b17f0982b (struct file): New member `command_flags'. 1994-10-24 22:47:43 +00:00
Roland McGrath
dc576b2051 (Automatic Dependencies): Improve recommended sed command.
Mention -MM flag to gcc.
1994-10-24 05:05:43 +00:00
Roland McGrath
a543a2ae9f (Commands): Add warning about "blank" line starting with a tab. 1994-10-17 00:02:27 +00:00
Roland McGrath
0e352e4bf7 (switches): Bump flag values for --no-print-directory and
--warn-undefined-variables, so neither is 1 (which indicates a nonoption
argument).
1994-10-16 05:01:46 +00:00
Roland McGrath
3f8bde0f25 (main): Add missing code in .IGNORE test. 1994-10-16 03:39:35 +00:00
Roland McGrath
4308542cb1 Document $+ and $(+D), $(+F). 1994-10-10 08:10:13 +00:00
Roland McGrath
e622fcf22e (define_automatic_variables): Define +D and +F. 1994-10-10 08:08:58 +00:00
Roland McGrath
1766b7fa59 (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.
1994-10-01 08:07:35 +00:00
Roland McGrath
fa999783d7 (posix_pedantic): New variable.
(main): Set posix_pedantic if .POSIX is a target.
Fix .IGNORE and .SILENT hecks to require is_target.
1994-09-30 01:04:54 +00:00
Roland McGrath
e97d6632b5 Comment fix. 1994-09-29 19:52:49 +00:00
Roland McGrath
e3d013a79a (set_file_variables): Define new automatic variable $+, like $^ but before
calling uniquize_deps.
1994-09-29 08:23:25 +00:00
Roland McGrath
9807a2869f (reap_children): Call delete_child_targets for non-signal error if
.DELETE_ON_ERROR is a target.
1994-09-29 04:14:20 +00:00
Roland McGrath
e9521d3447 [alliant && i860] (LOAD_AVE_TYPE, FSCALE, NLIST_STRUCT): Define. 1994-09-28 21:00:06 +00:00
Roland McGrath
c62ca42327 (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.
1994-09-26 23:02:40 +00:00
Roland McGrath
2feb36f620 (quote_as_word): Actually test DOUBLE_DOLLARS, instead of always doubling. 1994-09-26 22:45:08 +00:00
Roland McGrath
f40918e005 (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.
1994-09-26 22:37:10 +00:00
Roland McGrath
b13a443fa7 [__MSDOS__]: Fixed typo. 1994-09-26 22:20:56 +00:00
Roland McGrath
e938a511be (selective_vpath_search): Reset EXISTS when stat fails. 1994-09-26 22:16:51 +00:00
David J. MacKenzie
a96d572aa6 remove CONFIG_BROKETS 1994-09-26 21:57:54 +00:00
David J. MacKenzie
990c39d973 REMOVE CONFIG_BROKETS 1994-09-26 21:56:21 +00:00
David J. MacKenzie
24d37fb493 remove CONFIG_BROKETS 1994-09-26 21:52:40 +00:00
Richard M. Stallman
c1e20276cb (getloadavg): Add OSF_ALPHA support. 1994-09-17 00:16:57 +00:00
Roland McGrath
9f71eaf6b5 Include <assert.h> and use assert instead of printfs and abort. 1994-09-10 15:04:57 +00:00
Roland McGrath
03cd08cca2 (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.
1994-09-10 07:01:10 +00:00
Roland McGrath
dc44a79020 Add HAVE_SYS_SIGLIST and HAVE__SYS_SIGLIST. 1994-09-09 07:16:54 +00:00
Roland McGrath
8ed6e13cfe (Archive Suffix Rules): Remove Next pointer. 1994-09-09 06:59:08 +00:00
Roland McGrath
b321e0f535 (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.
1994-09-09 06:45:51 +00:00
Roland McGrath
c1433e9495 (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.
1994-09-09 05:37:40 +00:00
Roland McGrath
e4a94e0210 (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.
1994-09-07 07:06:46 +00:00
Roland McGrath
9e97330bcb (start_job_command): Whenever we set CHILD->file->update_status, call
notice_finished_file instead of just set_command_state.
1994-09-07 07:02:23 +00:00
Roland McGrath
4969b416b8 (set_command_state): Actually set FILE->command_state. 1994-09-07 00:31:13 +00:00
Roland McGrath
0bd0301ae3 (set_command_state): Fix typo. 1994-09-07 00:24:10 +00:00
Roland McGrath
ff6efbadf5 (set_command_state): Declare D. 1994-09-07 00:17:57 +00:00
Roland McGrath
0b3317d2e1 Add missing ". 1994-09-07 00:15:23 +00:00
Roland McGrath
ca5a872280 Changed all assignments of command_state members to calls to
set_command_state.
1994-09-07 00:04:49 +00:00
Roland McGrath
4244f182f2 (set_command_state): New function. 1994-09-07 00:02:25 +00:00
Roland McGrath
be6e6d74bb Declare set_command_state. 1994-09-06 23:48:36 +00:00
Roland McGrath
4c0fef3dd7 (init_switches): Put a + first in options. 1994-09-06 23:13:43 +00:00
Richard M. Stallman
d3b65c3cb7 entered into RCS 1994-08-21 17:29:57 +00:00
gnu
bc48185f8e Formerly make-stds.texi.~29~ 1994-08-10 05:41:00 +00:00
Roland McGrath
6fcf219fa7 Initial revision 1994-07-25 23:47:05 +00:00
Roland McGrath
d2e23eefd2 Added trailing CRs. 1994-07-25 23:46:16 +00:00
Roland McGrath
55162a6730 Changed all uses of ':' to PATH_SEPARATOR_CHAR. 1994-07-25 23:34:32 +00:00
Roland McGrath
021ea7e61c (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.

Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
1994-07-25 23:33:26 +00:00
Roland McGrath
f663464925 (PATH_SEPARATOR_CHAR): Macro removed (now in make.h). 1994-07-25 23:28:08 +00:00
Roland McGrath
5d435e0859 (PATH_SEPARATOR_CHAR): New macro; differing defns for [__MSDOS__] and not. 1994-07-25 23:27:48 +00:00
Roland McGrath
a2ab31ba62 [__MSDOS__]: Include <process.h>.
(PATH_SEPARATOR_CHAR): New macro; differing defns for [__MSDOS__] and not.
[__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 and 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.

Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
1994-07-25 23:23:03 +00:00
Roland McGrath
da2ea1ea7f (expand_function: `shell') [__MSDOS__]: Wholly new implementation. 1994-07-25 23:06:00 +00:00
Roland McGrath
21a1b3b255 [__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.
Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
1994-07-25 23:01:19 +00:00
Roland McGrath
c8e76a708e [__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'.
Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
1994-07-25 22:54:09 +00:00
Roland McGrath
461cffc4e9 Initial revision 1994-07-25 22:48:06 +00:00
Roland McGrath
cdd25d1fb3 (fatal_error_signal) [__MSDOS__]: Just remove intermediates and exit.
Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
1994-07-25 22:47:14 +00:00
Roland McGrath
9a3666d550 (set_file_variables): Add parens in length computation in .SUFFIXES dep
loop to quiet compiler warning.  From Jim Meyering.
1994-07-25 22:09:25 +00:00
Roland McGrath
90dffad2cc (read_makefile): Free FILENAME if we allocated it. From Jim Meyering. 1994-07-25 22:07:41 +00:00
Roland McGrath
c1f2ef6d09 Update ISBN number to 1-882114-50-7 for edition 0.46.
Use new macro ISBN set at top of file.
1994-07-20 12:30:52 +00:00
Roland McGrath
51250a676d Split a shell command line in @example to avoid overfull hbox. 1994-07-08 18:33:15 +00:00
Roland McGrath
d2461a2409 (Goals): Say that only first target in first rule is default goal.
(Archive Pitfalls): New node.
1994-07-05 21:27:09 +00:00
Roland McGrath
fdea69c5fa (selective_vpath_search): Use safe_stat in place of stat. 1994-07-04 21:56:24 +00:00
Roland McGrath
7c7552336d (construct_include_path): Use safe_stat in place of stat. 1994-07-04 21:55:13 +00:00
Roland McGrath
535dcf6a22 (search_path): Use safe_stat in place of stat. 1994-07-04 21:54:18 +00:00
Roland McGrath
84091971f9 (find_directory): Use safe_stat in place of stat. 1994-07-04 21:53:25 +00:00
Roland McGrath
61da194af9 (delete_target): Use safe_stat in place of stat. 1994-07-04 21:52:28 +00:00
Roland McGrath
30c1465265 (ar_member_touch) [EINTR]: Do EINTR looping around fstat. 1994-07-04 21:51:49 +00:00
Roland McGrath
b574b8ea5a (name_mtime): Use safe_stat in place of stat.
(touch_file) [EINTR]: Do EINTR looping around fstat.
1994-07-04 21:50:03 +00:00
Roland McGrath
710e8e6f6f (safe_stat): New function, EINTR-safe wrapper around stat. 1994-07-04 21:46:58 +00:00
Roland McGrath
4a8a7637f3 (read_makefile): Check for a shell command first, and then strip leading
tabs before further checking if it's not a shell command line.
1994-06-24 10:34:03 +00:00
Roland McGrath
6348923799 Fix typo in last change. 1994-06-24 10:22:37 +00:00
Roland McGrath
660a23d649 [__arm]: Undefine POSIX.
[!__GNU_LIBRARY__ && !POSIX && !_POSIX_VERSION]: Don't declare system
functions that return int.
1994-06-24 09:45:35 +00:00
Roland McGrath
5bd9836fba (construct_command_argv_internal): After swallowing a backslash-newline
combination, if INSTRING is set goto string_char (new label) for normal
INSTRING handling code.
1994-06-24 09:40:13 +00:00
Roland McGrath
0cb47363e1 Put #include of errno.h and decl of errno before #ifndef HAVE_GETLOADAVG. 1994-06-04 05:24:48 +00:00
Roland McGrath
fff5a9ece0 Don't check for sys_siglist and _sys_siglist with AC_HAVE_FUNCS.
Instead use two AC_COMPILE_CHECKs.
1994-06-04 05:11:12 +00:00
Richard M. Stallman
e3a24fc596 [emacs]: Block input around the garbage reclamation.
Include blockinput.h.
1994-06-02 17:45:40 +00:00
Roland McGrath
bb38b0c253 [!__GNU_LIBRARY__ && !POSIX]: Also test #ifndef _POSIX_VERSION for these
declarations.
1994-05-23 22:25:30 +00:00
Roland McGrath
d2ed03e72a [GETLOADAVG_PRIVILEGED] [POSIX]: Remove bogus #ifndefs around #undefs of
HAVE_SETREUID and HAVE_SETREGID.
1994-05-23 22:20:30 +00:00
30 changed files with 1878 additions and 810 deletions

View File

@@ -45,6 +45,8 @@ include compatMakefile
MAKE = $(MAKE_COMMAND) $(MAKEOVERRIDES)
# Remove autoconf magic.
prefix = /usr/local
exec_prefix = $(prefix)
extras := $(filter-out getloadavg.o @%@,$(extras)) getloadavg.o
LOADLIBES := $(filter-out @%@,$(LOADLIBES))
ALLOCA := $(filter-out @%@,$(ALLOCA))
@@ -86,7 +88,7 @@ GLOB =
else
CPPFLAGS := $(CPPFLAGS) -Iglob
CPPFLAGS := $(filter-out @%@,$(CPPFLAGS)) -Iglob
endif # works-for-make
endif # $(libc_dir)
@@ -96,9 +98,7 @@ endif # !no_libc
$(ARCH)/%.o: %.c
$(COMPILE.c) -Iglob $< $(OUTPUT_OPTION)
$(ARCH)/glob/libglob.a: FORCE
$(MAKE) -C $(@D) $(@F) \
CC='$(CC)' CFLAGS='$(CFLAGS) -I..' \
CPPFLAGS='$(CPPFLAGS) -DHAVE_CONFIG_H'
$(MAKE) -C $(@D) $(@F)
FORCE:
objs := $(addprefix $(ARCH)/,$(objs))
prog := $(ARCH)/make
@@ -147,7 +147,7 @@ $(prog): $(objs) $(globdep) #$(addprefix $(ARCH)/,gmalloc.o mcheck.o)
$(CC) $(LDFLAGS) $^ $(globlib) $(LOADLIBES) -o $@.new
mv -f $@.new $@
globfiles = $(addprefix glob/,COPYING.LIB Makefile.in \
globfiles = $(addprefix glob/,COPYING.LIB configure.in configure Makefile.in \
glob.c fnmatch.c glob.h fnmatch.h)
$(globfiles): stamp-glob ;
stamp-glob: /home/gd/gnu/libc/posix/glob.tar
@@ -197,6 +197,7 @@ build.sh.in: build.template compatMakefile
$(patsubst $(archpfx)%,%,$(objs)))\
$(patsubst %.c,%.o,$(filter %.c,$(globfiles)))@' \
$< > $@.new
chmod a+x $@.new
mv -f $@.new $@
# Make the distribution tar files.
@@ -218,8 +219,8 @@ dist-flavor = alpha
endif
.PHONY: rcs-mark rcs-mark-alpha rcs-mark-beta
rcs-mark: rcs-mark-$(dist-flavor)
rcs-mark-alpha:;rcs -sAlpha -Nmake-$(version-): RCS/[!=]*,v
rcs-mark-beta:;rcs -sBeta -Nmake-$(version-): RCS/[!=]*,v
rcs-mark-alpha: RCS/[!=]*,v;rcs -sAlpha -Nmake-$(version-): $^
rcs-mark-beta: RCS/[!=]*,v;rcs -sBeta -Nmake-$(version-): $^
version- = $(subst .,-,$(version))
dist: local-inst
@@ -262,7 +263,7 @@ make-$(version).tar: README INSTALL COPYING ChangeLog NEWS \
acconfig.h $(srcs) remote-*.c $(globfiles) \
make.texinfo make-stds.texi \
make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags \
install.sh \
install-sh \
make.info make.info*
$(make-tar)

View File

@@ -3,3 +3,15 @@
/* Define this if the SCCS `get' command understands the `-G<file>' option. */
#undef SCCS_GET_MINUS_G
/* Define this if the C library defines the variable `sys_siglist'. */
#undef HAVE_SYS_SIGLIST
/* Define this if the C library defines the variable `_sys_siglist'. */
#undef HAVE__SYS_SIGLIST
/* Define this if you have the `union wait' type in <sys/wait.h>. */
#undef HAVE_UNION_WAIT
/* Define this if the POSIX.1 call `sysconf (_SC_OPEN_MAX)' works properly. */
#undef HAVE_SYSCONF_OPEN_MAX

View File

@@ -22,11 +22,11 @@
your main control loop, etc. to force garbage collection. */
#ifdef HAVE_CONFIG_H
#if defined (emacs) || defined (CONFIG_BROKETS)
#include <config.h>
#else
#include "config.h"
#endif
#ifdef emacs
#include "blockinput.h"
#endif
/* If compiling with GCC 2, this file's not needed. */
@@ -176,6 +176,10 @@ alloca (size)
{
register header *hp; /* Traverses linked list. */
#ifdef emacs
BLOCK_INPUT;
#endif
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth)
|| (STACK_DIR < 0 && hp->h.deep < depth))
@@ -190,6 +194,10 @@ alloca (size)
break; /* Rest are not deeper. */
last_alloca_header = hp; /* -> last valid storage. */
#ifdef emacs
UNBLOCK_INPUT;
#endif
}
if (size == 0)

View File

@@ -429,11 +429,11 @@ ar_name_equal (name, mem, truncated)
struct ar_hdr hdr;
return !strncmp (name, mem,
sizeof (hdr.ar_name) -
#ifndef __hpux
#if !defined (__hpux) && !defined (cray)
1
#else
2
#endif /* __hpux */
#endif /* !__hpux && !cray */
);
#endif
}
@@ -495,7 +495,11 @@ ar_member_touch (arname, memname)
if (AR_HDR_SIZE != write (fd, (char *) &ar_hdr, AR_HDR_SIZE))
goto lose;
/* The file's mtime is the time we we want. */
#ifdef EINTR
while (fstat (fd, &statbuf) < 0 && errno == EINTR);
#else
fstat (fd, &statbuf);
#endif
#if defined(ARFMAG) || defined(AIAMAG)
/* Advance member's time to that time */
for (i = 0; i < sizeof ar_hdr.ar_date; i++)

69
build.sh.in Normal file
View File

@@ -0,0 +1,69 @@
#!/bin/sh
# Shell script to build GNU Make in the absence of any `make' program.
# Copyright (C) 1993, 1994 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make 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, or (at your option)
# any later version.
#
# GNU Make 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 GNU Make; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# See Makefile.in for comments describing these variables.
srcdir='@srcdir@'
CC='@CC@'
CFLAGS='@CFLAGS@'
CPPFLAGS='@CPPFLAGS@'
LDFLAGS='@LDFLAGS@'
defines='@DEFS@ -DLIBDIR="${libdir}" -DINCLUDEDIR="${includedir}"'
ALLOCA='@ALLOCA@'
LOADLIBES='@LIBS@'
extras='@LIBOBJS@'
REMOTE='@REMOTE@'
# Common prefix for machine-independent installed files.
prefix=@prefix@
# Common prefix for machine-dependent installed files.
exec_prefix=@exec_prefix@
# Directory to find libraries in for `-lLIB'.
libdir=${exec_prefix}/lib
# Directory to search by default for included makefiles.
includedir=${prefix}/include
# Exit as soon as any command fails.
set -e
# These are all the objects we need to link together.
objs="commands.o job.o dir.o file.o misc.o main.o read.o remake.o rule.o implicit.o default.o variable.o expand.o function.o vpath.o version.o ar.o arscan.o signame.o getopt.o getopt1.o glob/glob.o glob/fnmatch.o remote-${REMOTE}.o ${extras} ${ALLOCA}"
# Compile the source files into those objects.
for file in `echo ${objs} | sed 's/\.o/.c/g'`; do
echo compiling ${file}...
$CC $CPPFLAGS $CFLAGS $defines -c \
-I. -I${srcdir} -I${srcdir}/glob ${srcdir}/$file
done
# The object files were actually all put in the current directory.
# Remove the source directory names from the list.
srcobjs="$objs"
objs=
for obj in $srcobjs; do
objs="$objs `basename $obj`"
done
# Link all the objects together.
echo linking make...
$CC $LDFLAGS $objs $LOADLIBES -o make.new
echo done
mv -f make.new make

View File

@@ -1,8 +1,8 @@
#!/bin/sh
# Shell script to build GNU Make in the absence of any `make' program.
# @configure_input@
# Copyright (C) 1993 Free Software Foundation, Inc.
# Copyright (C) 1993, 1994 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
srcdir='@srcdir@'
CC='@CC@'
CFLAGS='@CFLAGS@'
CPPFLAGS='@CPPFLAGS@'
LDFLAGS='@LDFLAGS@'
defines='@DEFS@ -DLIBDIR="${libdir}" -DINCLUDEDIR="${includedir}"'
ALLOCA='@ALLOCA@'
@@ -32,9 +33,9 @@ extras='@LIBOBJS@'
REMOTE='@REMOTE@'
# Common prefix for machine-independent installed files.
prefix=/usr/local
prefix='@prefix@'
# Common prefix for machine-dependent installed files.
exec_prefix=/usr/local
exec_prefix='@exec_prefix@'
# Directory to find libraries in for `-lXXX'.
libdir=${exec_prefix}/lib
# Directory to search by default for included makefiles.
@@ -49,7 +50,8 @@ objs="%objs% remote-${REMOTE}.o ${extras} ${ALLOCA}"
# Compile the source files into those objects.
for file in `echo ${objs} | sed 's/\.o/.c/g'`; do
echo compiling ${file}...
$CC $CFLAGS $defines -c -I. -I${srcdir} -I${srcdir}/glob ${srcdir}/$file
$CC $defines $CPPFLAGS $CFLAGS \
-c -I. -I${srcdir} -I${srcdir}/glob ${srcdir}/$file
done
# The object files were actually all put in the current directory.

View File

@@ -87,7 +87,7 @@ set_file_variables (file)
for (d = enter_file (".SUFFIXES")->deps; d != 0; d = d->next)
{
unsigned int slen = strlen (dep_name (d));
if (len > slen && !strncmp (dep_name (d), name + len - slen, slen))
if (len > slen && !strncmp (dep_name (d), name + (len - slen), slen))
{
file->stem = savestring (name, len - slen);
break;
@@ -116,34 +116,64 @@ set_file_variables (file)
DEFINE_VARIABLE ("@", 1, at);
DEFINE_VARIABLE ("%", 1, percent);
/* Make sure that no dependencies are repeated. This does not
really matter for the purpose of updating targets, but it
might make some names be listed twice for $^ and $?. */
uniquize_deps (file->deps);
/* Compute the values for $^ and $?. */
/* Compute the values for $^, $+, and $?. */
{
register unsigned int caret_len, qmark_len;
char *caret_value;
register unsigned int qmark_len, plus_len;
char *caret_value, *plus_value;
register char *cp;
char *qmark_value;
register char *qp;
register struct dep *d;
unsigned int len;
caret_len = qmark_len = 0;
/* Compute first the value for $+, which is supposed to contain
duplicate dependencies as they were listed in the makefile. */
plus_len = 0;
for (d = file->deps; d != 0; d = d->next)
plus_len += strlen (dep_name (d)) + 1;
len = plus_len == 0 ? 1 : plus_len;
cp = plus_value = (char *) alloca (len);
qmark_len = plus_len; /* Will be this or less. */
for (d = file->deps; d != 0; d = d->next)
{
register unsigned int i = strlen (dep_name (d)) + 1;
caret_len += i;
if (d->changed)
qmark_len += i;
char *c = dep_name (d);
#ifndef NO_ARCHIVES
if (ar_name (c))
{
c = index (c, '(') + 1;
len = strlen (c) - 1;
}
else
#endif
len = strlen (c);
bcopy (c, cp, len);
cp += len;
*cp++ = ' ';
if (! d->changed)
qmark_len -= len + 1; /* Don't space in $? for this one. */
}
len = caret_len == 0 ? 1 : caret_len;
cp = caret_value = (char *) alloca (len);
/* Kill the last space and define the variable. */
cp[cp > plus_value ? -1 : 0] = '\0';
DEFINE_VARIABLE ("+", 1, plus_value);
/* Make sure that no dependencies are repeated. This does not
really matter for the purpose of updating targets, but it
might make some names be listed twice for $^ and $?. */
uniquize_deps (file->deps);
/* Compute the values for $^ and $?. */
cp = caret_value = plus_value; /* Reuse the buffer; it's big enough. */
len = qmark_len == 0 ? 1 : qmark_len;
qp = qmark_value = (char *) alloca (len);
@@ -329,6 +359,10 @@ RETSIGTYPE
fatal_error_signal (sig)
int sig;
{
#ifdef __MSDOS__
remove_intermediates (1);
exit (1);
#else /* Not MSDOS. */
handling_fatal_signal = 1;
/* Set the handling for this signal to the default.
@@ -385,6 +419,7 @@ fatal_error_signal (sig)
will be unblocked when we return and arrive then to kill us. */
if (kill (getpid (), sig) < 0)
pfatal_with_name ("kill");
#endif /* MSDOS. */
}
/* Delete FILE unless it's precious or not actually a file (phony),
@@ -416,7 +451,7 @@ delete_target (file, on_behalf_of)
}
#endif
if (stat (file->name, &st) == 0
if (safe_stat (file->name, &st) == 0
&& S_ISREG (st.st_mode)
&& (time_t) st.st_mtime != file->last_mtime)
{

View File

@@ -1,7 +1,7 @@
# NOTE: If you have no `make' program at all to process this makefile, run
# `build.sh' instead.
#
# Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
# Copyright (C) 1988, 89, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify
@@ -30,11 +30,9 @@ srcdir = @srcdir@
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
# How to invoke ranlib. This is only used by the `glob' subdirectory.
RANLIB = @RANLIB@
# Define these for your system as follows:
# -DNO_ARCHIVES To disable `ar' archive support.
# -DNO_FLOAT To avoid using floating-point numbers.
@@ -77,9 +75,9 @@ LOADLIBES = @LIBS@
extras = @LIBOBJS@
# Common prefix for machine-independent installed files.
prefix = /usr/local
prefix = @prefix@
# Common prefix for machine-dependent installed files.
exec_prefix = $(prefix)
exec_prefix = @exec_prefix@
# Directory to install `make' in.
bindir = $(exec_prefix)/bin
@@ -119,8 +117,8 @@ MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
# Programs to make tags files.
ETAGS = etags -tw
CTAGS = ctags -tw
ETAGS = etags -w
CTAGS = ctags -w
objs = commands.o job.o dir.o file.o misc.o main.o read.o remake.o \
rule.o implicit.o default.o variable.o expand.o function.o \
@@ -144,10 +142,9 @@ srcs = $(srcdir)/commands.c $(srcdir)/job.c $(srcdir)/dir.c \
.SUFFIXES: .o .c .h .ps .dvi .info .texinfo
all: make
check: # No tests.
info: make.info
dvi: make.dvi
# Some makes apparently use .PHONY as the default goal is it is before `all'.
# Some makes apparently use .PHONY as the default goal if it is before `all'.
.PHONY: all check info dvi
make.info: make.texinfo
@@ -166,17 +163,14 @@ make: $(objs)
# -I. is needed to find config.h in the build directory.
.c.o:
$(CC) $(defines) -c -I. -I$(srcdir) -I$(srcdir)/glob \
$(CFLAGS) $< $(OUTPUT_OPTION)
$(CPPFLAGS) $(CFLAGS) $< $(OUTPUT_OPTION)
# For some losing Unix makes.
SHELL = /bin/sh
MAKE = make
glob/libglob.a: FORCE config.h
cd glob; $(MAKE) CC='$(CC)' CFLAGS='$(CFLAGS) -I..' \
CPPFLAGS='$(CPPFLAGS) -DHAVE_CONFIG_H' \
RANLIB='$(RANLIB)' \
libglob.a
cd glob; $(MAKE) libglob.a
FORCE:
tagsrcs = $(srcs) $(srcdir)/remote-*.c
@@ -201,7 +195,7 @@ $(bindir)/$(binprefix)make: make
else \
echo "$@ needs to be owned by group $(group) and setgid;"; \
echo "otherwise the \`-l' option will probably not work."; \
echo "You may need special priveleges to install $@."; \
echo "You may need special privileges to install $@."; \
fi; \
else true; fi
# Some systems can't deal with renaming onto a running binary.
@@ -247,13 +241,15 @@ check: check-loadavg
.PHONY: clean realclean distclean mostlyclean
clean: glob-clean
-rm -f make loadavg *.o core make.info* make.dvi
-rm -f make loadavg *.o core make.dvi
distclean: clean glob-realclean
-rm -f Makefile config.h config.status build.sh stamp-config
-rm -f config.log config.cache
-rm -f TAGS tags
-rm -f make.?? make.??s make.log make.toc make.*aux
-rm -f loadavg.c
realclean: distclean
-rm -f make.info*
mostlyclean: clean
.PHONY: glob-clean glob-realclean

65
configh.dos.template Normal file
View File

@@ -0,0 +1,65 @@
/* Generated automatically from configure.in by autoheader. DO NOT EDIT! */
#define INCLUDEDIR "c:/djgpp/include"
#define LIBDIR "c:/djgpp/lib"
/* Define if you have dirent.h. */
#define DIRENT
/* Define if you have the strcoll function and it is properly defined. */
#define HAVE_STRCOLL
/* Define if you have unistd.h. */
#define HAVE_UNISTD_H
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS
/* Define if `sys_siglist' is declared by <signal.h>. */
#define SYS_SIGLIST_DECLARED
/* Define if you have getdtablesize. */
#define HAVE_GETDTABLESIZE
/* Define if you have dup2. */
#define HAVE_DUP2
/* Define if you have sys_siglist. */
#undef HAVE_SYS_SIGLIST
/* Define if you have _sys_siglist. */
#undef HAVE__SYS_SIGLIST
/* Define if you have psignal. */
#define HAVE_PSIGNAL
/* Define if you have getcwd. */
#define HAVE_GETCWD
/* Define if you have sigsetmask. */
#define HAVE_SIGSETMASK
/* Define if you have setlinebuf. */
#define HAVE_SETLINEBUF
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H
/* Define if you have the <memory.h> header file. */
#define HAVE_MEMORY_H
#define INCLUDEDIR "c:/djgpp/include"
#define LIBDIR "c:/djgpp/lib"
#define SCCS_GET "get"

43
configure.bat Normal file
View File

@@ -0,0 +1,43 @@
@echo off
echo Configuring MAKE for go32
rem This batch file assumes a unix-type "sed" program
update configh.dos config.h
echo # Makefile generated by "configure.bat"> Makefile
if exist config.sed del config.sed
echo ": try_sl ">> config.sed
echo "/\\$/ { ">> config.sed
echo " N ">> config.sed
echo " s/[ ]*\\\n[ ]*/ / ">> config.sed
echo " b try_sl ">> config.sed
echo "} ">> config.sed
echo "s/@srcdir@/./ ">> config.sed
echo "s/@CC@/gcc/ ">> config.sed
echo "s/@CFLAGS@/-O2 -g -DHAVE_CONFIG_H/ ">> config.sed
echo "s/@LDFLAGS@// ">> config.sed
echo "s/@RANLIB@/ranlib/ ">> config.sed
echo "s/@DEFS@// ">> config.sed
echo "s/@REMOTE@/stub/ ">> config.sed
echo "s/@ALLOCA@// ">> config.sed
echo "s/@LIBS@// ">> config.sed
echo "s/@LIBOBJS@// ">> config.sed
echo "s/@SET_MAKE@// ">> config.sed
echo "s/^Makefile *:/_Makefile:/ ">> config.sed
echo "s/^config.h *:/_config.h:/ ">> config.sed
echo "s/^defines *=.*$/defines =/ ">> config.sed
echo "/mv -f make.new make/d ">> config.sed
echo "s/cd glob; $(MAKE)/$(MAKE) -C glob/ ">> config.sed
sed -e "s/^\"//" -e "s/\"$//" -e "s/[ ]*$//" config.sed > config2.sed
sed -f config2.sed Makefile.in >> Makefile
del config.sed
del config2.sed
cd glob
call configure
cd ..

View File

@@ -1,72 +1,107 @@
dnl Process this file with autoconf to produce a configure script.
AC_REVISION([$Id$])
AC_INIT(vpath.c) dnl A distinctive file to look for in srcdir.
AC_PREREQ(2.1)dnl dnl Minimum Autoconf version required.
AC_INIT(vpath.c)dnl dnl A distinctive file to look for in srcdir.
AC_CONFIG_HEADER(config.h)
AC_CONFIG_SUBDIRS(glob) dnl Run configure in glob subdirectory.
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g AC_SUBST(CFLAGS)
test -z "$LDFLAGS" && LDFLAGS=-g AC_SUBST(LDFLAGS)
AC_SET_MAKE
AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_CPP dnl Later checks need this.
AC_AIX
AC_ISC_POSIX
AC_MINIX
AC_STDC_HEADERS
AC_DIR_HEADER
AC_UID_T dnl Also does gid_t.
AC_GETGROUPS_T
AC_PID_T
AC_RETSIGTYPE
AC_HAVE_HEADERS(unistd.h limits.h sys/param.h fcntl.h string.h memory.h \
sys/timeb.h)
AC_MINUS_C_MINUS_O
AC_CONST dnl getopt needs this.
AC_STAT_MACROS_BROKEN
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_TYPE_UID_T dnl Also does gid_t.
AC_TYPE_GETGROUPS
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_CHECK_HEADERS(unistd.h limits.h sys/param.h fcntl.h string.h memory.h \
sys/timeb.h)
AC_PROG_CC_C_O
AC_C_CONST dnl getopt needs this.
AC_HEADER_STAT
AC_SUBST(LIBOBJS)
AC_HAVE_FUNCS(getdtablesize sys_siglist _sys_siglist psignal \
dup2 getcwd sigsetmask getgroups setlinebuf \
seteuid setegid setreuid setregid strerror)
AC_ALLOCA
AC_VFORK
AC_SETVBUF_REVERSED
AC_GETLOADAVG
AC_STRCOLL
AC_DEFUN(AC_CHECK_SYMBOL, [dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_check_symbol_$1, [dnl
AC_TRY_LINK(, [extern char *sys_siglist[]; puts(*sys_siglist);],
ac_cv_check_symbol_$1=yes, ac_cv_check_symbol_$1=no)])
if test "$ac_cv_check_symbol_$1" = yes; then
changequote(,)dnl
ac_tr_symbol=`echo $1 | tr '[a-z]' '[A-Z]'`
changequote([,])dnl
AC_DEFINE_UNQUOTED(HAVE_${ac_tr_symbol})
fi
AC_MSG_RESULT($ac_cv_check_symbol_$1)])dnl
dnl Check out the wait reality.
AC_HAVE_HEADERS(sys/wait.h) AC_HAVE_FUNCS(waitpid wait3)
AC_COMPILE_CHECK(union wait, [#include <sys/types.h>
AC_CHECK_FUNCS(getdtablesize psignal mktemp \
dup2 getcwd sigsetmask getgroups setlinebuf \
seteuid setegid setreuid setregid strerror)
AC_CHECK_SYMBOL(sys_siglist)
AC_CHECK_SYMBOL(_sys_siglist)
AC_FUNC_ALLOCA
AC_FUNC_VFORK
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_GETLOADAVG
AC_FUNC_STRCOLL
if test $ac_cv_func_getdtablesize = no; then
AC_MSG_CHECKING(for sysconf (_SC_OPEN_MAX))
AC_CACHE_VAL(make_cv_sysconf_open_max, [dnl
AC_TRY_LINK([#include <unistd.h>], [int max = sysconf (_SC_OPEN_MAX);],
[make_cv_sysconf_open_max=yes], [make_cv_sysconf_open_max=no])])
if test $make_cv_sysconf_open_max = yes; then
AC_DEFINE(HAVE_SYSCONF_OPEN_MAX)
fi
AC_MSG_RESULT($make_cv_sysconf_open_max)
fi
# Check out the wait reality.
AC_CHECK_HEADERS(sys/wait.h) AC_CHECK_FUNCS(waitpid wait3)
AC_MSG_CHECKING(for union wait)
AC_CACHE_VAL(make_cv_union_wait, [dnl
AC_TRY_LINK([#include <sys/types.h>
#include <sys/wait.h>],
[union wait status; int pid; pid = wait (&status);
[union wait status; int pid; pid = wait (&status);
#ifdef WEXITSTATUS
/* Some POSIXoid systems have both the new-style macros and the old
union wait type, and they do not work together. If union wait
conflicts with WEXITSTATUS et al, we don't want to use it at all. */
if (WEXITSTATUS (status) != 0) pid = -1;
#ifdef WTERMSIG
/* If we have WEXITSTATUS and WTERMSIG, just use them on ints. */
-- blow chunks here --
#endif
#endif
#ifdef HAVE_WAITPID
/* Make sure union wait works with waitpid. */
pid = waitpid (-1, &status, 0);
#endif
],
AC_DEFINE(HAVE_UNION_WAIT))
[make_cv_union_wait=yes], [make_cv_union_wait=no])])
if test "$make_cv_union_wait" = yes; then
AC_DEFINE(HAVE_UNION_WAIT)
fi
AC_MSG_RESULT($make_cv_union_wait)
AC_SYS_SIGLIST_DECLARED
AC_DECL_SYS_SIGLIST
# The presence of the following is not meant to imply
# that make necessarily works on those systems.
AC_DYNIX_SEQ
AC_XENIX_DIR
AC_IRIX_SUN
AC_CHECK_LIB(sun, getpwnam)
AC_SUBST(REMOTE) REMOTE=stub
AC_WITH(customs, [REMOTE=cstms
LIBS="$LIBS libcustoms.a"])
AC_ARG_WITH(customs, [export jobs with the Customs daemon (NOT SUPPORTED)],
[REMOTE=cstms LIBS="$LIBS libcustoms.a"])
echo checking for location of SCCS get command
if test -f /usr/sccs/get; then
@@ -88,7 +123,7 @@ if ( /usr/sccs/admin -n s.conftest || admin -n s.conftest ) >/dev/null 2>&1 &&
fi
rm -f s.conftest conftoast
AC_OUTPUT(Makefile build.sh glob/Makefile, [
AC_OUTPUT(Makefile build.sh, [
# Makefile uses this timestamp file to know when to remake Makefile,
# build.sh, and glob/Makefile.
touch stamp-config])

View File

@@ -1,5 +1,5 @@
/* Data base of default implicit rules for GNU Make.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -23,6 +23,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "commands.h"
#include "variable.h"
/* Define GCC_IS_NATIVE if gcc is the native development environment on
your system (gcc/bison/flex vs cc/yacc/lex). */
#ifdef __MSDOS__
#define GCC_IS_NATIVE
#endif
/* This is the default list of suffixes for suffix rules.
`.s' must come last, so that a `.o' file will be made from
@@ -133,12 +139,20 @@ static char *default_suffix_rules[] =
".c.ln",
"$(LINT.c) -C$* $<",
".y.ln",
#ifndef __MSDOS__
"$(YACC.y) $< \n $(LINT.c) -C$* y.tab.c \n $(RM) y.tab.c",
#else
"$(YACC.y) $< \n $(LINT.c) -C$* y_tab.c \n $(RM) y_tab.c",
#endif
".l.ln",
"@$(RM) $*.c\n $(LEX.l) $< > $*.c\n$(LINT.c) -i $*.c -o $@\n $(RM) $*.c",
".y.c",
#ifndef __MSDOS__
"$(YACC.y) $< \n mv -f y.tab.c $@",
#else
"$(YACC.y) $< \n mv -f y_tab.c $@",
#endif
".l.c",
"@$(RM) $@ \n $(LEX.l) $< > $@",
@@ -195,16 +209,15 @@ static char *default_suffix_rules[] =
static char *default_variables[] =
{
"AR", "ar",
#ifndef __hpux
"ARFLAGS", "rv",
#else
/* HPUX ar's f flag says to truncate the file names to archive member
name length in comparisons, so replacement notices the equality. */
"ARFLAGS", "rfv",
#endif
"AS", "as",
#ifdef GCC_IS_NATIVE
"CC", "gcc",
"CXX", "gcc",
#else
"CC", "cc",
"CXX", "g++",
#endif
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
and to the empty string if $@ does exist. */
@@ -237,7 +250,11 @@ static char *default_variables[] =
#endif /* Cray. */
"GET", SCCS_GET,
"LD", "ld",
#ifdef GCC_IS_NATIVE
"LEX", "flex",
#else
"LEX", "lex",
#endif
"LINT", "lint",
"M2C", "m2c",
#ifdef pyr
@@ -250,7 +267,11 @@ static char *default_variables[] =
"PC", "pc",
#endif /* CRAY. */
#endif /* pyr. */
#ifdef GCC_IS_NATIVE
"YACC", "bison -y",
#else
"YACC", "yacc", /* Or "bison -y" */
#endif
"MAKEINFO", "makeinfo",
"TEX", "tex",
"TEXI2DVI", "texi2dvi",

73
dir.c
View File

@@ -1,5 +1,5 @@
/* Directory hashing for GNU Make.
Copyright (C) 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -18,26 +18,26 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "make.h"
#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__)
#if defined (POSIX) || defined (HAVE_DIRENT_H) || defined (__GNU_LIBRARY__)
#include <dirent.h>
#ifndef __GNU_LIBRARY__
#define D_NAMLEN(d) strlen((d)->d_name)
#else /* GNU C library. */
#define D_NAMLEN(d) ((d)->d_namlen)
#endif /* Not GNU C library. */
#else /* Not POSIX or DIRENT. */
#else /* Not POSIX or HAVE_DIRENT_H. */
#define direct dirent
#define D_NAMLEN(d) ((d)->d_namlen)
#ifdef SYSNDIR
#ifdef HAVE_SYS_NDIR_H
#include <sys/ndir.h>
#endif /* SYSNDIR */
#ifdef SYSDIR
#endif /* HAVE_SYS_NDIR_H */
#ifdef HAVE_SYS_DIR_H
#include <sys/dir.h>
#endif /* SYSDIR */
#ifdef NDIR
#endif /* HAVE_SYS_DIR_H */
#ifdef HAVE_NDIR_H
#include <ndir.h>
#endif /* NDIR */
#endif /* POSIX or DIRENT or __GNU_LIBRARY__. */
#endif /* HAVE_NDIR_H */
#endif /* POSIX or HAVE_DIRENT_H or __GNU_LIBRARY__. */
#if defined (POSIX) && !defined (__GNU_LIBRARY__)
/* Posix does not require that the d_ino field be present, and some
@@ -47,6 +47,49 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* POSIX */
#ifdef __MSDOS__
#include <ctype.h>
static char *
dosify (filename)
char *filename;
{
static char dos_filename[14];
char *df;
int i;
if (filename == 0)
return 0;
if (strpbrk (filename, "\"*+,;<=>?[\\]|") != 0)
return filename;
df = dos_filename;
/* First, transform the name part. */
for (i = 0; *filename != '\0' && i < 8 && *filename != '.'; ++i)
*df++ = tolower (*filename++);
/* Now skip to the next dot. */
while (*filename != '\0' && *filename != '.')
++filename;
if (*filename != '\0')
{
*df++ = *filename++;
for (i = 0; *filename != '\0' && i < 3 && *filename != '.'; ++i)
*df++ = tolower (*filename++);
}
/* Look for more dots. */
while (*filename != '\0' && *filename != '.')
++filename;
if (*filename == '.')
return filename;
*df = 0;
return dos_filename;
}
#endif
/* Hash table of directories. */
#ifndef DIRECTORY_BUCKETS
@@ -136,7 +179,7 @@ find_directory (name)
/* The directory is not in the name hash table.
Find its device and inode numbers, and look it up by them. */
if (stat (name, &st) < 0)
if (safe_stat (name, &st) < 0)
/* Couldn't stat the directory. Mark this by
setting the `contents' member to a nil pointer. */
dir->contents = 0;
@@ -213,6 +256,10 @@ dir_contents_file_exists_p (dir, filename)
/* The directory could not be stat'd or opened. */
return 0;
#ifdef __MSDOS__
filename = dosify (filename);
#endif
hash = 0;
if (filename != 0)
{
@@ -404,6 +451,10 @@ file_impossible_p (filename)
/* There are no files entered for this directory. */
return 0;
#ifdef __MSDOS__
p = filename = dosify (p);
#endif
for (hash = 0; *p != '\0'; ++p)
HASH (hash, *p);
hash %= DIRFILE_BUCKETS;

208
expand.c
View File

@@ -1,5 +1,5 @@
/* Variable expansion functions for GNU Make.
Copyright (C) 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 91, 92, 93, 95 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -197,9 +197,9 @@ variable_expand (line)
char openparen = *p;
char closeparen = (openparen == '(') ? ')' : '}';
register char *beg = p + 1;
int free_beg = 0;
char *op, *begp;
char *end;
char *colon = 0;
char *end, *colon;
op = o;
begp = p;
@@ -213,10 +213,18 @@ variable_expand (line)
/* Is there a variable reference inside the parens or braces?
If so, expand it before expanding the entire reference. */
p1 = index (beg, closeparen);
end = index (beg, closeparen);
if (end == 0)
{
/* Unterminated variable reference. */
if (reading_filename != 0)
makefile_fatal (reading_filename, *reading_lineno_ptr,
"unterminated variable reference");
else
fatal ("unterminated variable reference");
}
p1 = lindex (beg, end, '$');
if (p1 != 0)
p1 = lindex (beg, p1, '$');
if (p1 != 0 && lindex (beg, p1, ':') == 0)
{
/* BEG now points past the opening paren or brace.
Count parens or braces until it is matched. */
@@ -227,133 +235,109 @@ variable_expand (line)
++count;
else if (*p == closeparen && --count < 0)
break;
else if (colon == 0 && count == 0 && *p == ':')
/* Record where we found a colon, which
indicates a substitution reference.
We want to expand the text before the
reference only. */
colon = p;
}
/* If COUNT is >= 0, there were unmatched opening parens
or braces, so we go to the simple case of a variable name
such as `$($(a)'. */
if (count < 0)
{
char *name = expand_argument (beg, colon == 0 ? p : colon);
unsigned int namelen = strlen (name);
if (colon == 0)
{
/* This is a simple reference to the expanded name. */
o = reference_variable (o, name, namelen);
free (name);
break;
}
else
{
/* This is a substitution reference to the expanded
name. We replace the pending text with a copy
containing the expanded name in place of the
original name, and then fall through to
the normal substitution reference code below. */
unsigned int restlen = strlen (colon) + 1;
beg = (char *) alloca (namelen + restlen);
bcopy (name, beg, namelen);
bcopy (colon, &beg[namelen], restlen);
/* Point COLON into the new copy. */
colon = &beg[namelen];
}
beg = expand_argument (beg, p); /* Expand the name. */
free_beg = 1; /* Remember to free BEG when finished. */
end = index (beg, '\0');
}
}
else
/* Advance P to the end of this reference. After we are
finished expanding this one, P will be incremented to
continue the scan. */
p = end;
/* This is not a reference to a built-in function and
it does not contain any variable references inside.
There are several things it could be. */
any variable references inside are now expanded.
Is the resultant text a substitution reference? */
if (colon == 0)
colon = index (beg, ':');
if (colon != 0 && lindex (beg, colon, closeparen) == 0)
colon = lindex (beg, end, ':');
if (colon != 0)
{
/* This is a substitution reference: $(FOO:A=B). */
int count;
/* This looks like a substitution reference: $(FOO:A=B). */
char *subst_beg, *subst_end, *replace_beg, *replace_end;
v = lookup_variable (beg, colon - beg);
if (v == 0)
warn_undefined (beg, colon - beg);
subst_beg = colon + 1;
count = 0;
for (p = subst_beg; *p != '\0'; ++p)
subst_end = index (subst_beg, '=');
if (subst_end == 0)
/* There is no = in sight. Punt on the substitution
reference and treat this as a variable name containing
a colon, in the code below. */
colon = 0;
else
{
if (*p == openparen)
++count;
else if (*p == closeparen)
--count;
else if (*p == '=' && count <= 0)
break;
replace_beg = subst_end + 1;
replace_end = end;
/* Extract the variable name before the colon
and look up that variable. */
v = lookup_variable (beg, colon - beg);
if (v == 0)
warn_undefined (beg, colon - beg);
if (v != 0 && *v->value != '\0')
{
char *value = (v->recursive ? recursively_expand (v)
: v->value);
char *pattern, *percent;
if (free_beg)
{
*subst_end = '\0';
pattern = subst_beg;
}
else
{
pattern = (char *) alloca (subst_end - subst_beg
+ 1);
bcopy (subst_beg, pattern, subst_end - subst_beg);
pattern[subst_end - subst_beg] = '\0';
}
percent = find_percent (pattern);
if (percent != 0)
{
char *replace;
if (free_beg)
{
*replace_end = '\0';
replace = replace_beg;
}
else
{
replace = (char *) alloca (replace_end
- replace_beg
+ 1);
bcopy (replace_beg, replace,
replace_end - replace_beg);
replace[replace_end - replace_beg] = '\0';
}
o = patsubst_expand (o, value, pattern, replace,
percent, (char *) 0);
}
else
o = subst_expand (o, value,
pattern, replace_beg,
strlen (pattern),
end - replace_beg,
0, 1);
if (v->recursive)
free (value);
}
}
if (count > 0)
/* There were unmatched opening parens. */
return initialize_variable_output ();
subst_end = p;
replace_beg = p + 1;
count = 0;
for (p = replace_beg; *p != '\0'; ++p)
{
if (*p == openparen)
++count;
else if (*p == closeparen && --count < 0)
break;
}
if (count > 0)
/* There were unmatched opening parens. */
return initialize_variable_output ();
end = p;
replace_end = p;
p = expand_argument (subst_beg, subst_end);
p1 = expand_argument (replace_beg, replace_end);
if (v != 0 && *v->value != '\0')
{
char *value = (v->recursive ? recursively_expand (v)
: v->value);
char *percent = find_percent (p);
if (percent != 0)
o = patsubst_expand (o, value, p, p1,
percent, (char *) 0);
else
o = subst_expand (o, value,
p, p1, strlen (p), strlen (p1),
0, 1);
if (v->recursive)
free (value);
}
free (p);
free (p1);
}
/* No, this must be an ordinary variable reference. */
else
{
/* Look up the value of the variable. */
end = index (beg, closeparen);
if (end == 0)
{
/* Unterminated variable reference. */
if (reading_filename != 0)
makefile_fatal (reading_filename, *reading_lineno_ptr,
"unterminated variable reference");
else
fatal ("unterminated variable reference");
}
if (colon == 0)
/* This is an ordinary variable reference.
Look up the value of the variable. */
o = reference_variable (o, beg, end - beg);
}
/* Advance p past the variable reference to resume scan. */
p = end;
if (free_beg)
free (beg);
}
break;

41
file.c
View File

@@ -383,6 +383,47 @@ snap_deps ()
f = lookup_file (".EXPORT_ALL_VARIABLES");
if (f != 0 && f->is_target)
export_all_variables = 1;
f = lookup_file (".IGNORE");
if (f != 0 && f->is_target)
{
if (f->deps == 0)
ignore_errors_flag = 1;
else
for (d = f->deps; d != 0; d = d->next)
for (f2 = d->file; f2 != 0; f2 = f2->prev)
f2->command_flags |= COMMANDS_NOERROR;
}
f = lookup_file (".SILENT");
if (f != 0 && f->is_target)
{
if (f->deps == 0)
silent_flag = 1;
else
for (d = f->deps; d != 0; d = d->next)
for (f2 = d->file; f2 != 0; f2 = f2->prev)
f2->command_flags |= COMMANDS_SILENT;
}
f = lookup_file (".POSIX");
if (f != 0 && f->is_target)
posix_pedantic = 1;
}
/* Set the `command_state' member of FILE and all its `also_make's. */
void
set_command_state (file, state)
struct file *file;
int state;
{
struct dep *d;
file->command_state = state;
for (d = file->also_make; d != 0; d = d->next)
d->file->command_state = state;
}
/* Print the data base of files. */

4
file.h
View File

@@ -25,7 +25,8 @@ struct file
struct file *next;
char *name;
struct dep *deps;
struct commands *cmds; /* Commands to execute for this target */
struct commands *cmds; /* Commands to execute for this target. */
int command_flags; /* Flags OR'd in for cmds; see commands.h. */
char *stem; /* Implicit stem, if an implicit
rule has been used */
struct dep *also_make; /* Targets that are made by making this. */
@@ -85,6 +86,7 @@ extern struct file *default_goal_file, *suffix_file, *default_file;
extern struct file *lookup_file (), *enter_file ();
extern void remove_intermediates (), snap_deps ();
extern void rename_file (), file_hash_enter ();
extern void set_command_state ();
extern time_t f_mtime ();

View File

@@ -22,6 +22,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "commands.h"
#include "job.h"
#ifdef __MSDOS__
#include <process.h>
#endif
static char *string_glob ();
/* Store into VARIABLE_BUFFER at O the result of scanning TEXT and replacing
@@ -371,6 +375,7 @@ expand_function (o, function, text, end)
else
error_prefix = "";
#ifndef __MSDOS__
if (pipe (pipedes) < 0)
{
perror_with_name (error_prefix, "pipe");
@@ -475,6 +480,69 @@ expand_function (o, function, text, end)
free (buffer);
}
#else /* MSDOS. */
{
/* MS-DOS can't do fork, but it can do spawn. However, this
means that we don't have an opportunity to reopen stdout to
trap it. Thus, we save our own stdout onto a new descriptor
and dup a temp file's descriptor onto our stdout temporarily.
After we spawn the shell program, we dup our own stdout back
to the stdout descriptor. The buffer reading is the same as
above, except that we're now reading from a file. */
int save_stdout;
int child_stdout;
char tmp_output[FILENAME_MAX];
FILE *child_stream;
unsigned int maxlen = 200;
int cc;
char *buffer;
strcpy (tmp_output, "shXXXXXX");
mktemp (tmp_output);
child_stdout = open (tmp_output,
O_WRONLY|O_CREAT|O_TRUNC|O_TEXT, 0644);
save_stdout = dup (1);
dup2 (child_stdout, 1);
spawnvp (P_WAIT, argv[0], argv);
dup2 (save_stdout, 1);
close (child_stdout);
close (save_stdout);
child_stdout = open (tmp_output, O_RDONLY|O_TEXT, 0644);
buffer = xmalloc (maxlen);
i = 0;
do
{
if (i == maxlen)
{
maxlen += 512;
buffer = (char *) xrealloc (buffer, maxlen + 1);
}
cc = read (child_stdout, &buffer[i], maxlen - i);
if (cc > 0)
i += cc;
} while (cc > 0);
close (child_stdout);
unlink (tmp_output);
if (i > 0)
{
if (buffer[i - 1] == '\n')
buffer[--i] = '\0';
else
buffer[i] = '\0';
p = buffer;
while ((p = index (p, '\n')) != 0)
*p++ = ' ';
o = variable_buffer_output (o, buffer, i);
}
free (buffer);
}
#endif /* Not MSDOS. */
free (text);
break;

View File

@@ -1,5 +1,5 @@
/* Get the system load averages.
Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93
Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -59,6 +59,11 @@
We also #define LDAV_PRIVILEGED if a program will require
special installation to be able to call getloadavg. */
/* This should always be first. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
/* Both the Emacs and non-Emacs sections want this. Some
@@ -69,20 +74,17 @@
#endif
#ifdef HAVE_CONFIG_H
#if defined (emacs) || defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
/* Exclude all the code except the test program at the end
if the system has its own `getloadavg' function. */
if the system has its own `getloadavg' function.
The declaration of `errno' is needed by the test program
as well as the function itself, so it comes first. */
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#ifndef HAVE_GETLOADAVG
@@ -141,6 +143,7 @@
#if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
#define OSF_ALPHA
#include <sys/table.h>
#endif
#if defined (__osf__) && (defined (mips) || defined (__mips__))
@@ -203,6 +206,10 @@
#define LOAD_AVE_TYPE long
#endif
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
#define LOAD_AVE_TYPE long
#endif
#endif /* No LOAD_AVE_TYPE. */
#ifdef OSF_ALPHA
@@ -212,6 +219,13 @@
#define FSCALE 1024.0
#endif
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
/* <sys/param.h> defines an incorrect value for FSCALE on an
Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
#undef FSCALE
#define FSCALE 100.0
#endif
#ifndef FSCALE
@@ -289,7 +303,7 @@
#define NLIST_STRUCT
#endif
#ifdef tex4300
#ifdef tek4300
#define NLIST_STRUCT
#endif
@@ -297,6 +311,10 @@
#define NLIST_STRUCT
#endif
#if defined(alliant) && defined(i860) /* Alliant FX/2800 */
#define NLIST_STRUCT
#endif
#endif /* defined (NLIST_STRUCT) */
@@ -331,11 +349,6 @@
#endif
#include <stdio.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
/* LOAD_AVE_TYPE should only get defined if we're going to use the
nlist method. */
@@ -699,6 +712,18 @@ getloadavg (loadavg, nelem)
: (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
#endif /* OSF_MIPS */
#if !defined (LDAV_DONE) && defined (OSF_ALPHA)
#define LDAV_DONE
struct tbl_loadavg load_ave;
table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
for (elem = 0; elem < nelem; elem++)
loadavg[elem]
= (load_ave.tl_lscale == 0
? load_ave.tl_avenrun.d[elem]
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
#endif /* OSF_ALPHA */
#if !defined (LDAV_DONE) && defined (VMS)
/* VMS specific code -- read from the Load Ave driver. */

View File

@@ -262,7 +262,7 @@ pattern_search (file, archive, depth, recursions)
}
/* If we have found a matching rule that won't match all filenames,
retroactively reject any "terminal" rules that do always match. */
retroactively reject any non-"terminal" rules that do always match. */
if (specific_rule_matched)
for (i = 0; i < nrules; ++i)
if (!tryrules[i]->terminal)

340
job.c
View File

@@ -1,5 +1,5 @@
/* Job execution and handling for GNU Make.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -21,13 +21,21 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "job.h"
#include "file.h"
#include "variable.h"
/* Default path to search for executables. */
static char default_path[] = ":/bin:/usr/bin";
#include <assert.h>
/* Default shell to use. */
char default_shell[] = "/bin/sh";
#ifdef __MSDOS__
#include <process.h>
static int dos_pid = 123;
static int dos_status;
static char *dos_bname;
static char *dos_bename;
static int dos_batch_file;
#endif /* MSDOS. */
/* If NGROUPS_MAX == 0 then try other methods for finding a real value. */
#if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
#undef NGROUPS_MAX
@@ -114,6 +122,9 @@ extern int setgid (), getgid ();
#ifdef HAVE_GETDTABLESIZE
extern int getdtablesize ();
#else
#ifdef HAVE_SYSCONF_OPEN_MAX
#define getdtablesize() ((int) sysconf (_SC_OPEN_MAX))
#else
#include <sys/param.h>
#define getdtablesize() NOFILE
#if !defined (NOFILE) && defined (NOFILES_MAX)
@@ -122,6 +133,7 @@ extern int getdtablesize ();
#endif
#endif
#endif
#endif
extern int getloadavg ();
extern int start_remote_job_p ();
@@ -260,6 +272,7 @@ reap_children (block, err)
}
else if (pid == 0)
{
#ifndef __MSDOS__
/* No remote children. Check for local children. */
if (any_local)
@@ -308,6 +321,14 @@ reap_children (block, err)
exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
coredump = WCOREDUMP (status);
}
#else /* MSDOS. */
/* Life is very different on MSDOS. */
pid = dos_pid - 1;
status = dos_status;
exit_code = dos_status;
exit_sig = 0;
coredump = 0;
#endif /* Not MSDOS. */
}
else
/* We got a remote child. */
@@ -359,9 +380,15 @@ reap_children (block, err)
{
/* The commands failed. Write an error message,
delete non-precious targets, and abort. */
static int delete_on_error = -1;
child_error (c->file->name, exit_code, exit_sig, coredump, 0);
c->file->update_status = 1;
if (exit_sig != 0)
if (delete_on_error == -1)
{
struct file *f = lookup_file (".DELETE_ON_ERROR");
delete_on_error = f != 0 && f->is_target;
}
if (exit_sig != 0 || delete_on_error)
delete_child_targets (c);
}
else
@@ -383,7 +410,6 @@ reap_children (block, err)
Since there are more commands that wanted to be run,
the target was not completely remade. So we treat
this as if a command had failed. */
c->file->command_state = cs_finished;
c->file->update_status = 1;
}
else
@@ -394,32 +420,33 @@ reap_children (block, err)
by start_remote_job_p. */
c->remote = start_remote_job_p ();
start_job_command (c);
if (c->file->command_state == cs_running)
/* We successfully started the new command.
Loop to reap more children. */
continue;
}
}
switch (c->file->command_state)
{
case cs_running:
/* Successfully started. Loop to reap more children. */
continue;
case cs_finished:
if (c->file->update_status != 0)
/* We failed to start the commands. */
delete_child_targets (c);
break;
default:
error ("internal error: `%s' has bogus command_state \
%d in reap_children",
c->file->name, (int) c->file->command_state);
abort ();
break;
}
else
/* There are no more commands. We got through them all
without an unignored error. Now the target has been
successfully updated. */
c->file->update_status = 0;
}
/* When we get here, all the commands for C->file are finished
(or aborted) and C->file->update_status contains 0 or 1. But
C->file->command_state is still cs_running if all the commands
ran; notice_finish_file looks for cs_running to tell it that
it's interesting to check the file's modtime again now. */
if (! handling_fatal_signal)
/* Notice if the target of the commands has been changed. */
/* Notice if the target of the commands has been changed.
This also propagates its values for command_state and
update_status to its also_make files. */
notice_finished_file (c->file);
if (debug_flag)
@@ -475,6 +502,13 @@ free_child (child)
}
#ifdef POSIX
#ifdef __MSDOS__
void
unblock_sigs ()
{
return;
}
#else
extern sigset_t fatal_signal_set;
void
@@ -485,6 +519,7 @@ unblock_sigs ()
sigprocmask (SIG_SETMASK, &empty, (sigset_t *) 0);
}
#endif
#endif
/* Start a job to run the commands specified in CHILD.
CHILD is updated to reflect the commands and ID of the child process. */
@@ -495,9 +530,14 @@ start_job_command (child)
{
static int bad_stdin = -1;
register char *p;
int flags = child->file->cmds->lines_flags[child->command_line - 1];
int flags;
char **argv;
/* Combine the flags parsed for the line itself with
the flags specified globally for this target. */
flags = (child->file->command_flags
| child->file->cmds->lines_flags[child->command_line - 1]);
p = child->command_ptr;
child->noerror = flags & COMMANDS_NOERROR;
while (*p != '\0')
@@ -519,7 +559,7 @@ start_job_command (child)
if (question_flag && !(flags & COMMANDS_RECURSE))
{
child->file->update_status = 1;
child->file->command_state = cs_finished;
notice_finished_file (child->file);
return;
}
@@ -552,9 +592,16 @@ start_job_command (child)
if (argv == 0)
{
next_command:
/* This line has no commands. Go to the next. */
if (job_next_command (child))
start_job_command (child);
else
{
/* No more commands. All done. */
child->file->update_status = 0;
notice_finished_file (child->file);
}
return;
}
@@ -578,9 +625,7 @@ start_job_command (child)
{
free (argv[0]);
free ((char *) argv);
if (job_next_command (child))
start_job_command (child);
return;
goto next_command;
}
/* Flush the output streams so they won't have things written twice. */
@@ -618,6 +663,8 @@ start_job_command (child)
if (child->environment == 0)
child->environment = target_environment (child->file);
#ifndef __MSDOS__
/* start_waiting_job has set CHILD->remote if we can start a remote job. */
if (child->remote)
{
@@ -641,6 +688,8 @@ start_job_command (child)
{
/* Fork the child process. */
char **parent_environ;
#ifdef POSIX
(void) sigprocmask (SIG_BLOCK, &fatal_signal_set, (sigset_t *) 0);
#else
@@ -650,7 +699,9 @@ start_job_command (child)
#endif
child->remote = 0;
parent_environ = environ;
child->pid = vfork ();
environ = parent_environ; /* Restore value child may have clobbered. */
if (child->pid == 0)
{
/* We are the child side. */
@@ -667,10 +718,26 @@ start_job_command (child)
}
}
#else /* MSDOS. */
dos_status = spawnvpe (P_WAIT, argv[0], argv, child->environment);
++dead_children;
child->pid = dos_pid++;
if (dos_batch_file)
{
dos_batch_file = 0;
remove (dos_bname); /* Ignore errors. */
if (access (dos_bename, 0))
dos_status = 1;
else
dos_status = 0;
remove (dos_bename);
}
#endif /* Not MSDOS. */
/* We are the parent side. Set the state to
say the commands are running and return. */
child->file->command_state = cs_running;
set_command_state (child->file, cs_running);
/* Free the storage used by the child's argument list. */
@@ -681,7 +748,7 @@ start_job_command (child)
error:
child->file->update_status = 2;
child->file->command_state = cs_finished;
notice_finished_file (child->file);
}
/* Try to start a child running.
@@ -704,7 +771,7 @@ start_waiting_job (c)
{
/* Put this child on the chain of children waiting
for the load average to go down. */
c->file->command_state = cs_running;
set_command_state (c->file, cs_running);
c->next = waiting_jobs;
waiting_jobs = c;
return 0;
@@ -727,15 +794,18 @@ start_waiting_job (c)
unblock_sigs ();
break;
case cs_not_started:
/* All the command lines turned out to be empty. */
c->file->update_status = 0;
/* FALLTHROUGH */
case cs_finished:
notice_finished_file (c->file);
free_child (c);
break;
default:
error ("internal error: `%s' command_state == %d in new_job",
c->file->name, (int) c->file->command_state);
abort ();
assert (c->file->command_state == cs_finished);
break;
}
@@ -881,8 +951,11 @@ new_job (file)
/* Fetch the first command line to be run. */
if (! job_next_command (c))
/* There were no commands! */
free_child (c);
{
/* There were no commands! */
free_child (c);
c->file->update_status = 0;
}
else
{
/* The job is now primed. Start it running. */
@@ -910,8 +983,6 @@ job_next_command (child)
{
/* There are no more lines to be expanded. */
child->command_ptr = 0;
child->file->command_state = cs_finished;
child->file->update_status = 0;
return 0;
}
else
@@ -924,6 +995,9 @@ job_next_command (child)
static int
load_too_high ()
{
#ifdef __MSDOS__
return 1;
#else
extern int getloadavg ();
double load;
@@ -949,6 +1023,7 @@ load_too_high ()
user_access ();
return load >= max_load_average;
#endif
}
/* Start jobs that are waiting for the load to be lower. */
@@ -1001,6 +1076,11 @@ child_execute_job (stdin_fd, stdout_fd, argv, envp)
exec_command (argv, envp);
}
#if 0
/* Default path to search for executables. */
static char default_path[] = ":/bin:/usr/bin";
/* Search PATH for FILE.
If successful, store the full pathname in PROGRAM and return 1.
If not sucessful, return zero. */
@@ -1012,7 +1092,13 @@ search_path (file, path, program)
if (path == 0 || path[0] == '\0')
path = default_path;
if (index (file, '/') != 0)
if (
#ifdef __MSDOS__
strpbrk (file, "/\\:")
#else
index (file, '/')
#endif
!= 0)
{
strcpy (program, file);
return 1;
@@ -1049,7 +1135,7 @@ search_path (file, path, program)
int perm;
char *p;
p = index (path, ':');
p = index (path, PATH_SEPARATOR_CHAR);
if (p == 0)
p = path + strlen (path);
@@ -1062,7 +1148,7 @@ search_path (file, path, program)
bcopy (file, program + (p - path) + 1, len);
}
if (stat (program, &st) == 0
if (safe_stat (program, &st) == 0
&& S_ISREG (st.st_mode))
{
if (st.st_uid == geteuid ())
@@ -1093,6 +1179,7 @@ search_path (file, path, program)
return 0;
}
#endif /* search_path commented out */
/* Replace the current process with one running the command in ARGV,
with environment ENVP. This function does not return. */
@@ -1101,82 +1188,65 @@ void
exec_command (argv, envp)
char **argv, **envp;
{
char *shell, *path;
PATH_VAR (program);
register char **ep;
shell = path = 0;
for (ep = envp; *ep != 0; ++ep)
{
if (shell == 0 && !strncmp(*ep, "SHELL=", 6))
shell = &(*ep)[6];
else if (path == 0 && !strncmp(*ep, "PATH=", 5))
path = &(*ep)[5];
else if (path != 0 && shell != 0)
break;
}
/* Be the user, permanently. */
child_access ();
if (!search_path (argv[0], path, program))
error ("%s: Command not found", argv[0]);
else
/* Run the program. */
environ = envp;
execvp (argv[0], argv);
switch (errno)
{
/* Run the program. */
execve (program, argv, envp);
case ENOENT:
error ("%s: Command not found", argv[0]);
break;
case ENOEXEC:
{
/* The file is not executable. Try it as a shell script. */
extern char *getenv ();
char *shell;
char **new_argv;
int argc;
if (errno == ENOEXEC)
{
PATH_VAR (shell_program);
char *shell_path;
if (shell == 0)
shell_path = default_shell;
else
{
if (search_path (shell, path, shell_program))
shell_path = shell_program;
else
{
shell_path = 0;
error ("%s: Shell program not found", shell);
}
}
shell = getenv ("SHELL");
if (shell == 0)
shell = default_shell;
if (shell_path != 0)
{
char **new_argv;
int argc;
argc = 1;
while (argv[argc] != 0)
++argc;
argc = 1;
while (argv[argc] != 0)
++argc;
new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
new_argv[0] = shell;
new_argv[1] = program;
while (argc > 0)
{
new_argv[1 + argc] = argv[argc];
--argc;
}
new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
new_argv[0] = shell_path;
new_argv[1] = program;
while (argc > 0)
{
new_argv[1 + argc] = argv[argc];
--argc;
}
execvp (shell, new_argv);
if (errno == ENOENT)
error ("%s: Shell program not found", shell);
else
perror_with_name ("execvp: ", shell);
break;
}
execve (shell_path, new_argv, envp);
perror_with_name ("execve: ", shell_path);
}
}
else
perror_with_name ("execve: ", program);
default:
perror_with_name ("execvp: ", argv[0]);
break;
}
_exit (127);
}
/* Figure out the argument list necessary to run LINE as a command.
Try to avoid using a shell. This routine handles only ' quoting.
Starting quotes may be escaped with a backslash. If any of the
characters in sh_chars[] is seen, or any of the builtin commands
listed in sh_cmds[] is the first word of a line, the shell is used.
/* Figure out the argument list necessary to run LINE as a command. Try to
avoid using a shell. This routine handles only ' quoting, and " quoting
when no backslash, $ or ` characters are seen in the quotes. Starting
quotes may be escaped with a backslash. If any of the characters in
sh_chars[] is seen, or any of the builtin commands listed in sh_cmds[]
is the first word of a line, the shell is used.
If RESTP is not NULL, *RESTP is set to point to the first newline in LINE.
If *RESTP is NULL, newlines will be ignored.
@@ -1189,12 +1259,22 @@ construct_command_argv_internal (line, restp, shell, ifs)
char *line, **restp;
char *shell, *ifs;
{
#ifdef __MSDOS__
static char sh_chars[] = "\"|<>";
static char *sh_cmds[] = { "break", "call", "cd", "chcp", "chdir", "cls",
"copy", "ctty", "date", "del", "dir", "echo",
"erase", "exit", "for", "goto", "if", "if", "md",
"mkdir", "path", "pause", "prompt", "rem", "ren",
"rename", "set", "shift", "time", "type",
"ver", "verify", "vol", ":", 0 };
#else
static char sh_chars[] = "#;\"*?[]&|<>(){}$`^";
static char *sh_cmds[] = { "cd", "eval", "exec", "exit", "login",
"logout", "set", "umask", "wait", "while", "for",
"case", "if", ":", ".", "break", "continue",
"export", "read", "readonly", "shift", "times",
"trap", "switch", 0 };
#endif
register int i;
register char *p;
register char *ap;
@@ -1241,9 +1321,10 @@ construct_command_argv_internal (line, restp, shell, ifs)
if (instring)
{
string_char:
/* Inside a string, just copy any char except a closing quote
or a backslash-newline combination. */
if (*p == '\'')
if (*p == instring)
instring = 0;
else if (*p == '\\' && p[1] == '\n')
goto swallow_escaped_newline;
@@ -1253,6 +1334,10 @@ construct_command_argv_internal (line, restp, shell, ifs)
*restp = p;
goto end_of_line;
}
/* Backslash, $, and ` are special inside double quotes.
If we see any of those, punt. */
else if (instring == '"' && index ("\\$`", *p) != 0)
goto slow;
else
*ap++ = *p;
}
@@ -1292,7 +1377,7 @@ construct_command_argv_internal (line, restp, shell, ifs)
strcpy (p, p + 1);
if (instring)
*ap++ = *p;
goto string_char;
else
{
if (ap != new_argv[i])
@@ -1310,7 +1395,8 @@ construct_command_argv_internal (line, restp, shell, ifs)
break;
case '\'':
instring = 1;
case '"':
instring = *p;
break;
case '\n':
@@ -1401,6 +1487,34 @@ construct_command_argv_internal (line, restp, shell, ifs)
free (new_argv);
}
#ifdef __MSDOS__
{
FILE *batch;
dos_batch_file = 1;
if (dos_bname == 0)
{
dos_bname = tempnam (".", "mk");
for (i = 0; dos_bname[i] != '\0'; ++i)
if (dos_bname[i] == '/')
dos_bname[i] = '\\';
dos_bename = (char *) xmalloc (strlen (dos_bname) + 5);
strcpy (dos_bename, dos_bname);
strcat (dos_bname, ".bat");
strcat (dos_bename, ".err");
}
batch = fopen(bename, "w"); /* Create a file. */
if (batch != NULL)
fclose (batch);
batch = fopen (dos_bname, "w");
fputs ("@echo off\n", batch);
fputs (line, batch);
fprintf (batch, "\nif errorlevel 1 del %s\n", dos_bename);
fclose (batch);
new_argv = (char **) xmalloc(2 * sizeof(char *));
new_argv[0] = strdup (bname);
new_argv[1] = 0;
}
#else /* Not MSDOS. */
{
/* SHELL may be a multi-word command. Construct a command line
"SHELL -c LINE", with all special chars in LINE escaped.
@@ -1447,7 +1561,7 @@ construct_command_argv_internal (line, restp, shell, ifs)
continue;
}
if (*p == '\\' || *p == '\''
if (*p == '\\' || *p == '\'' || *p == '"'
|| isspace (*p)
|| index (sh_chars, *p) != 0)
*ap++ = '\\';
@@ -1458,15 +1572,17 @@ construct_command_argv_internal (line, restp, shell, ifs)
new_argv = construct_command_argv_internal (new_line, (char **) NULL,
(char *) 0, (char *) 0);
}
#endif /* MSDOS. */
return new_argv;
}
/* Figure out the argument list necessary to run LINE as a command.
Try to avoid using a shell. This routine handles only ' quoting.
Starting quotes may be escaped with a backslash. If any of the
characters in sh_chars[] is seen, or any of the builtin commands
listed in sh_cmds[] is the first word of a line, the shell is used.
/* Figure out the argument list necessary to run LINE as a command. Try to
avoid using a shell. This routine handles only ' quoting, and " quoting
when no backslash, $ or ` characters are seen in the quotes. Starting
quotes may be escaped with a backslash. If any of the characters in
sh_chars[] is seen, or any of the builtin commands listed in sh_cmds[]
is the first word of a line, the shell is used.
If RESTP is not NULL, *RESTP is set to point to the first newline in LINE.
If *RESTP is NULL, newlines will be ignored.

565
main.c
View File

@@ -1,5 +1,5 @@
/* Argument parsing and main program of GNU Make.
Copyright (C) 1988, 89, 90, 91, 94 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 94, 1995 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -46,6 +46,7 @@ static void log_working_directory ();
static void print_data_base (), print_version ();
static void decode_switches (), decode_env_switches ();
static void define_makeflags ();
static char *quote_as_word ();
/* The structure that describes an accepted command switch. */
@@ -271,13 +272,13 @@ static const struct command_switch switches[] =
{ 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0,
"print-directory", 0,
"Print the current directory" },
{ 1, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
{ 2, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
"no-print-directory", 0,
"Turn off -w, even if it was turned on implicitly" },
{ 'W', string, (char *) &new_files, 0, 0, 0, 0, 0,
"what-if", "FILE",
"Consider FILE to be infinitely new" },
{ 2, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
{ 3, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
"warn-undefined-variables", 0,
"Warn when an undefined variable is referenced" },
{ '\0', }
@@ -304,14 +305,28 @@ static struct option long_option_aliases[] =
#define DESCRIPTION_COLUMN 30
/* List of non-switch arguments. */
/* List of goal targets. */
struct stringlist *other_args = 0;
static struct dep *goals, *lastgoal;
/* List of variables which were defined on the command line
(or, equivalently, in MAKEFLAGS). */
struct command_variable
{
struct command_variable *next;
struct variable *variable;
};
static struct command_variable *command_variables;
/* The name we were invoked with. */
char *program;
/* Our current directory before processing any -C options. */
char *directory_before_chdir;
/* Our current directory after processing all -C options. */
char *starting_directory;
@@ -331,6 +346,11 @@ struct file *default_goal_file;
This is zero if the makefiles do not define .DEFAULT. */
struct file *default_file;
/* Nonzero if we have seen the magic `.POSIX' target.
This turns on pedantic compliance with POSIX.2. */
int posix_pedantic;
/* Mask of signals that are being caught with fatal_error_signal. */
@@ -377,6 +397,15 @@ enter_command_line_file (name)
return enter_file (savestring (name, strlen (name)));
}
/* Toggle -d on receipt of SIGUSR1. */
static RETSIGTYPE
debug_signal_handler (sig)
int sig;
{
debug_flag = ! debug_flag;
}
int
main (argc, argv, envp)
int argc;
@@ -387,14 +416,9 @@ main (argc, argv, envp)
extern RETSIGTYPE fatal_error_signal (), child_handler ();
register struct file *f;
register unsigned int i;
register char *cmd_defs;
register unsigned int cmd_defs_len, cmd_defs_idx;
char **p;
struct dep *goals = 0;
register struct dep *lastgoal;
struct dep *read_makefiles;
PATH_VAR (current_directory);
char *directory_before_chdir;
default_goal_file = 0;
reading_filename = 0;
@@ -464,6 +488,12 @@ main (argc, argv, envp)
else
{
program = rindex (argv[0], '/');
#ifdef __MSDOS__
if (program == 0)
program = rindex (argv[0], '\\');
if (program == 0)
program = rindex (argv[0], ':');
#endif
if (program == 0)
program = argv[0];
else
@@ -490,8 +520,8 @@ main (argc, argv, envp)
strlen (current_directory));
/* Read in variables from the environment. It is important that this be
done before `MAKE' and `MAKEOVERRIDES' are figured out so their
definitions will not be ones from the environment. */
done before $(MAKE) is are figured out so its definitions will not be
one from the environment. */
for (i = 0; envp[i] != 0; ++i)
{
@@ -531,76 +561,7 @@ main (argc, argv, envp)
if (print_version_flag)
die (0);
/* Search for command line arguments that define variables,
and do the definitions. Also save up the text of these
arguments in CMD_DEFS so we can put them into the values
of $(MAKEOVERRIDES) and $(MAKE). */
cmd_defs_len = 200;
cmd_defs = (char *) xmalloc (cmd_defs_len);
cmd_defs_idx = 0;
for (i = 1; other_args->list[i] != 0; ++i)
{
if (other_args->list[i][0] == '\0')
/* Ignore empty arguments, so they can't kill enter_file. */
continue;
/* Try a variable definition. */
if (try_variable_definition ((char *) 0, 0,
other_args->list[i], o_command))
{
/* It succeeded. The variable is already defined.
Backslash-quotify it and append it to CMD_DEFS, then clobber it
to 0 in the list so that it won't be taken for a goal target. */
register char *p = other_args->list[i];
unsigned int l = strlen (p);
if (cmd_defs_idx + (l * 2) + 1 > cmd_defs_len)
{
if (l * 2 > cmd_defs_len)
cmd_defs_len += l * 2;
else
cmd_defs_len *= 2;
cmd_defs = (char *) xrealloc (cmd_defs, cmd_defs_len);
}
while (*p != '\0')
{
if (index ("^;'\"*?[]$<>(){}|&~`\\ \t\r\n\f\v", *p) != 0)
cmd_defs[cmd_defs_idx++] = '\\';
cmd_defs[cmd_defs_idx++] = *p++;
}
cmd_defs[cmd_defs_idx++] = ' ';
}
else
{
/* It was not a variable definition, so it is a target to be made.
Enter it as a file and add it to the dep chain of goals. */
f = enter_command_line_file (other_args->list[i]);
f->cmd_target = 1;
if (goals == 0)
{
goals = (struct dep *) xmalloc (sizeof (struct dep));
lastgoal = goals;
}
else
{
lastgoal->next = (struct dep *) xmalloc (sizeof (struct dep));
lastgoal = lastgoal->next;
}
lastgoal->name = 0;
lastgoal->file = f;
}
}
if (cmd_defs_idx > 0)
{
cmd_defs[cmd_defs_idx - 1] = '\0';
(void) define_variable ("MAKEOVERRIDES", 13, cmd_defs, o_default, 0);
}
free (cmd_defs);
#ifndef __MSDOS__
/* Set the "MAKE_COMMAND" variable to the name we were invoked with.
(If it is a relative pathname with a slash, prepend our directory name
so the result will run the same program regardless of the current dir.
@@ -610,17 +571,62 @@ main (argc, argv, envp)
if (current_directory[0] != '\0'
&& argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0)
argv[0] = concat (current_directory, "/", argv[0]);
#endif
/* The extra indirection through $(MAKE_COMMAND) is done
for hysterical raisins. */
(void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);
(void) define_variable ("MAKE", 4, "$(MAKE_COMMAND)", o_default, 1);
/* Append the command-line variable definitions gathered above
so sub-makes will get them as command-line definitions. */
if (command_variables != 0)
{
struct command_variable *cv;
struct variable *v;
unsigned int len = 0;
char *value, *p;
(void) define_variable ("MAKE", 4,
"$(MAKE_COMMAND) $(MAKEOVERRIDES)", o_default, 1);
/* Figure out how much space will be taken up by the command-line
variable definitions. */
for (cv = command_variables; cv != 0; cv = cv->next)
{
v = cv->variable;
len += 2 * strlen (v->name);
if (! v->recursive)
++len;
++len;
len += 2 * strlen (v->value);
}
/* Now allocate a buffer big enough and fill it. */
p = value = (char *) alloca (len);
for (cv = command_variables; cv != 0; cv = cv->next)
{
v = cv->variable;
p = quote_as_word (p, v->name, 0);
if (! v->recursive)
*p++ = ':';
*p++ = '=';
p = quote_as_word (p, v->value, 0);
*p++ = ' ';
}
p[-1] = '\0'; /* Kill the final space and terminate. */
/* Define an unchangeable variable with a name that no POSIX.2
makefile could validly use for its own variable. */
(void) define_variable ("-*-command-variables-*-", 23,
value, o_automatic, 0);
/* Define the variable; this will not override any user definition.
Normally a reference to this variable is written into the value of
MAKEFLAGS, allowing the user to override this value to affect the
exported value of MAKEFLAGS. In POSIX-pedantic mode, we cannot
allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so
a reference to this hidden variable is written instead. */
(void) define_variable ("MAKEOVERRIDES", 13,
"${-*-command-variables-*-}", o_env, 1);
}
/* If there were -C flags, move ourselves about. */
if (directories != 0)
for (i = 0; directories->list[i] != 0; ++i)
{
@@ -694,11 +700,16 @@ main (argc, argv, envp)
/* This makefile is standard input. Since we may re-exec
and thus re-read the makefiles, we read standard input
into a temporary file and read from that. */
static char name[] = "/tmp/GmXXXXXX";
FILE *outfile;
/* Make a unique filename. */
#ifdef HAVE_MKTEMP
static char name[] = "/tmp/GmXXXXXX";
(void) mktemp (name);
#else
static char name[L_tmpnam];
(void) tmpnam ();
#endif
outfile = fopen (name, "w");
if (outfile == 0)
@@ -747,6 +758,11 @@ main (argc, argv, envp)
(void) signal (SIGCLD, child_handler);
#endif
/* Let the user send us SIGUSR1 to toggle the -d flag during the run. */
#ifdef SIGUSR1
(void) signal (SIGUSR1, debug_signal_handler);
#endif
/* Define the initial list of suffixes for old-style rules. */
set_default_suffixes ();
@@ -788,12 +804,8 @@ main (argc, argv, envp)
define_makeflags (1, 0);
ignore_errors_flag |= lookup_file (".IGNORE") != 0;
silent_flag |= lookup_file (".SILENT") != 0;
/* Make each `struct dep' point at the
`struct file' for the file depended on. */
/* Make each `struct dep' point at the `struct file' for the file
depended on. Also do magic for special targets. */
snap_deps ();
@@ -1123,7 +1135,7 @@ main (argc, argv, envp)
/* Parsing of arguments, decoding of switches. */
static char options[sizeof (switches) / sizeof (switches[0]) * 3];
static char options[1 + sizeof (switches) / sizeof (switches[0]) * 3];
static struct option long_options[(sizeof (switches) / sizeof (switches[0])) +
(sizeof (long_option_aliases) /
sizeof (long_option_aliases[0]))];
@@ -1141,6 +1153,11 @@ init_switches ()
return;
p = options;
/* Return switch and non-switch args in order, regardless of
POSIXLY_CORRECT. Non-switch args are returned as option 1. */
*p++ = '-';
for (i = 0; switches[i].c != '\0'; ++i)
{
long_options[i].name = (switches[i].long_name == 0 ? "" :
@@ -1195,15 +1212,6 @@ decode_switches (argc, argv, env)
register struct stringlist *sl;
register int c;
if (!env)
{
other_args = (struct stringlist *) xmalloc (sizeof (struct stringlist));
other_args->max = argc + 1;
other_args->list = (char **) xmalloc ((argc + 1) * sizeof (char *));
other_args->idx = 1;
other_args->list[0] = argv[0];
}
/* getopt does most of the parsing for us.
First, get its vectors set up. */
@@ -1215,10 +1223,65 @@ decode_switches (argc, argv, env)
/* Reset getopt's state. */
optind = 0;
while ((c = getopt_long (argc, argv,
options, long_options, (int *) 0)) != EOF)
c = 0;
while (optind < argc)
{
if (c == '?')
if (c == EOF)
{
/* There are no more options according to getting getopt, but
there are some arguments left. Since we have asked for
non-option arguments to be returned in order, I think this
only happens when there is a "--" argument to prevent later
argument from being options. Since getopt has finished its
job, just update its state variables for the next argument and
set C as if it had returned 1, indicating a non-option
argument. */
optarg = argv[optind++];
c = 1;
}
else
/* Parse the next argument. */
c = getopt_long (argc, argv, options, long_options, (int *) 0);
if (c == 1)
{
/* Non-option argument. It might be a variable definition. */
struct variable *v;
v = try_variable_definition ((char *) 0, 0, optarg, o_command);
if (v != 0)
{
/* It is indeed a variable definition. Record a pointer to
the variable for later use in define_makeflags. */
struct command_variable *cv
= (struct command_variable *) xmalloc (sizeof (*cv));
cv->variable = v;
cv->next = command_variables;
command_variables = cv;
}
else if (! env)
{
/* Not an option or variable definition; it must be a goal
target! Enter it as a file and add it to the dep chain of
goals. */
struct file *f = enter_command_line_file (optarg);
f->cmd_target = 1;
if (goals == 0)
{
goals = (struct dep *) xmalloc (sizeof (struct dep));
lastgoal = goals;
}
else
{
lastgoal->next
= (struct dep *) xmalloc (sizeof (struct dep));
lastgoal = lastgoal->next;
}
lastgoal->name = 0;
lastgoal->file = f;
}
}
else if (c == '?')
/* Bad option. We will print a usage message and die later.
But continue to parse the other options so the user can
see all he did wrong. */
@@ -1320,29 +1383,19 @@ positive integral argument",
}
}
if (!env)
{
/* Collect the remaining args in the `other_args' string list. */
while (optind < argc)
{
char *arg = argv[optind++];
if (arg[0] != '-' || arg[1] != '\0')
other_args->list[other_args->idx++] = arg;
}
other_args->list[other_args->idx] = 0;
}
if (!env && (bad || print_usage_flag))
{
/* Print a nice usage message. */
FILE *usageto;
if (print_version_flag)
print_version ();
fprintf (stderr, "Usage: %s [options] [target] ...\n", program);
usageto = bad ? stderr : stdout;
fputs ("Options:\n", stderr);
fprintf (usageto, "Usage: %s [options] [target] ...\n", program);
fputs ("Options:\n", usageto);
for (cs = switches; cs->c != '\0'; ++cs)
{
char buf[1024], shortarg[50], longarg[50], *p;
@@ -1413,11 +1466,11 @@ positive integral argument",
line with the description, leaving at least two spaces.
Print it on its own line instead. */
{
fprintf (stderr, "%s\n", buf);
fprintf (usageto, "%s\n", buf);
buf[0] = '\0';
}
fprintf (stderr, "%*s%s.\n",
fprintf (usageto, "%*s%s.\n",
- DESCRIPTION_COLUMN,
buf, cs->description);
}
@@ -1437,7 +1490,7 @@ decode_env_switches (envar, len)
unsigned int len;
{
char *varref = (char *) alloca (2 + len + 2);
char *value, *args;
char *value, *p;
int argc;
char **argv;
@@ -1455,37 +1508,95 @@ decode_env_switches (envar, len)
if (len == 0)
return;
/* Make a copy of the value in ARGS, where we will munge it.
If it does not begin with a dash, prepend one.
We must allocate lasting storage for this (and we never free it) because
decode_switches may save pointers into it for string-valued switches. */
args = (char *) xmalloc (1 + len + 2);
if (value[0] != '-')
args[0] = '-';
bcopy (value, value[0] == '-' ? args : &args[1], len + 1);
/* Write an extra null terminator so our loop below will
never be in danger of looking past the end of the string. */
args[(value[0] == '-' ? 0 : 1) + len + 1] = '\0';
/* Allocate a vector that is definitely big enough. */
argv = (char **) alloca ((1 + len + 1) * sizeof (char *));
/* Allocate a buffer to copy the value into while we split it into words
and unquote it. We must use permanent storage for this because
decode_switches may store pointers into the passed argument words. */
p = (char *) xmalloc (2 * len);
/* getopt will look at the arguments starting at ARGV[1].
Prepend a spacer word. */
argv[0] = 0;
argc = 1;
do
argv[argc] = p;
while (*value != '\0')
{
argv[argc++] = args;
args = end_of_token (args);
*args++ = '\0';
} while (*args != '\0');
argv[argc] = 0;
if (*value == '\\')
++value; /* Skip the backslash. */
else if (isblank (*value))
{
/* End of the word. */
*p++ = '\0';
argv[++argc] = p;
do
++value;
while (isblank (*value));
continue;
}
*p++ = *value++;
}
*p = '\0';
argv[++argc] = 0;
if (argc == 2 && argv[1][0] != '-')
{
/* There is just one word in the value, and it is not a switch.
Either this is the single-word form and we should prepend a dash
before calling decode_switches, or this is the multi-word form and
there is no dash because it is a variable definition. */
struct variable *v;
v = try_variable_definition ((char *) 0, 0, argv[1], o_command);
if (v != 0)
{
/* It was indeed a variable definition, and now it has been
processed. There is nothing for decode_switches to do.
Record a pointer to the variable for later use in
define_makeflags. */
struct command_variable *cv
= (struct command_variable *) xmalloc (sizeof (*cv));
cv->variable = v;
cv->next = command_variables;
command_variables = cv;
return;
}
/* It wasn't a variable definition, so it's some switches without a
leading dash. Add one and pass it along to decode_switches. We
need permanent storage for this in case decode_switches saves
pointers into the value. */
argv[1] = concat ("-", argv[1], "");
}
/* Parse those words. */
decode_switches (argc, argv, 1);
}
/* Quote the string IN so that it will be interpreted as a single word with
no magic by the shell; if DOUBLE_DOLLARS is nonzero, also double dollar
signs to avoid variable expansion in make itself. Write the result into
OUT, returning the address of the next character to be written.
Allocating space for OUT twice the length of IN (thrice if
DOUBLE_DOLLARS is nonzero) is always sufficient. */
static char *
quote_as_word (out, in, double_dollars)
char *out, *in;
int double_dollars;
{
while (*in != '\0')
{
if (index ("^;'\"*?[]$<>(){}|&~`\\ \t\r\n\f\v", *in) != 0)
*out++ = '\\';
if (double_dollars && *in == '$')
*out++ = '$';
*out++ = *in++;
}
return out;
}
/* Define the MAKEFLAGS and MFLAGS variables to reflect the settings of the
command switches. Include options with args if ALL is nonzero.
Don't include options with the `no_makefile' flag set if MAKEFILE. */
@@ -1494,8 +1605,12 @@ static void
define_makeflags (all, makefile)
int all, makefile;
{
static const char ref[] = "$(MAKEOVERRIDES)";
static const char posixref[] = "$(-*-command-variables-*-)";
register const struct command_switch *cs;
char *flagstring;
register char *p;
unsigned int words;
struct variable *v;
/* We will construct a linked list of `struct flag's describing
@@ -1508,7 +1623,6 @@ define_makeflags (all, makefile)
struct flag *next;
const struct command_switch *cs;
char *arg;
unsigned int arglen;
};
struct flag *flags = 0;
unsigned int flagslen = 0;
@@ -1517,13 +1631,12 @@ define_makeflags (all, makefile)
struct flag *new = (struct flag *) alloca (sizeof (struct flag)); \
new->cs = cs; \
new->arg = (ARG); \
new->arglen = (LEN); \
new->next = flags; \
flags = new; \
if (new->arg == 0) \
++flagslen; /* Just a single flag letter. */ \
else \
flagslen += 1 + 1 + 1 + 1 + new->arglen; /* " -x foo" */ \
flagslen += 1 + 1 + 1 + 1 + 3 * (LEN); /* " -x foo" */ \
if (!isalnum (cs->c)) \
/* This switch has no single-letter version, so we use the long. */ \
flagslen += 2 + strlen (cs->long_name); \
@@ -1607,79 +1720,114 @@ define_makeflags (all, makefile)
break;
}
flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ". */
#undef ADD_FLAG
if (flags == 0)
/* No flags. Use a string of two nulls so [1] works below. */
flagstring = "\0";
else
/* Construct the value in FLAGSTRING.
We allocate enough space for a preceding dash and trailing null. */
flagstring = (char *) alloca (1 + flagslen + 1);
p = flagstring;
words = 1;
*p++ = '-';
while (flags != 0)
{
/* Construct the value in FLAGSTRING.
We allocate enough space for a preceding dash and trailing null. */
register char *p;
flagstring = (char *) alloca (1 + flagslen + 1);
p = flagstring;
*p++ = '-';
do
/* Add the flag letter or name to the string. */
if (!isalnum (flags->cs->c))
{
/* Add the flag letter or name to the string. */
if (!isalnum (flags->cs->c))
*p++ = '-';
strcpy (p, flags->cs->long_name);
p += strlen (p);
}
else
*p++ = flags->cs->c;
if (flags->arg != 0)
{
/* A flag that takes an optional argument which in this case is
omitted is specified by ARG being "". We must distinguish
because a following flag appended without an intervening " -"
is considered the arg for the first. */
if (flags->arg[0] != '\0')
{
*p++ = '-';
strcpy (p, flags->cs->long_name);
p += strlen (p);
/* Add its argument too. */
*p++ = !isalnum (flags->cs->c) ? '=' : ' ';
p = quote_as_word (p, flags->arg, 1);
}
else
*p++ = flags->cs->c;
if (flags->arg != 0)
{
/* A flag that takes an optional argument which in this case
is omitted is specified by ARG being "" and ARGLEN being 0.
We must distinguish because a following flag appended without
an intervening " -" is considered the arg for the first. */
if (flags->arglen > 0)
{
/* Add its argument too. */
*p++ = !isalnum (flags->cs->c) ? '=' : ' ';
bcopy (flags->arg, p, flags->arglen);
p += flags->arglen;
}
/* Write a following space and dash, for the next flag. */
*p++ = ' ';
*p++ = '-';
}
else if (!isalnum (flags->cs->c))
{
/* Long options must each go in their own word,
so we write the following space and dash. */
*p++ = ' ';
*p++ = '-';
}
flags = flags->next;
} while (flags != 0);
if (p[-1] == '-')
/* Kill the final space and dash. */
p -= 2;
/* Terminate the string. */
*p = '\0';
++words;
/* Write a following space and dash, for the next flag. */
*p++ = ' ';
*p++ = '-';
}
else if (!isalnum (flags->cs->c))
{
++words;
/* Long options must each go in their own word,
so we write the following space and dash. */
*p++ = ' ';
*p++ = '-';
}
flags = flags->next;
}
if (all && command_variables != 0)
{
/* Now write a reference to $(MAKEOVERRIDES), which contains all the
command-line variable definitions. */
if (p == &flagstring[1])
/* No flags written, so elide the leading dash already written. */
p = flagstring;
else
{
/* Separate the variables from the switches with a "--" arg. */
if (p[-1] != '-')
{
/* We did not already write a trailing " -". */
*p++ = ' ';
*p++ = '-';
}
/* There is a trailing " -"; fill it out to " -- ". */
*p++ = '-';
*p++ = ' ';
}
/* Copy in the string. */
if (posix_pedantic)
{
bcopy (posixref, p, sizeof posixref - 1);
p += sizeof posixref - 1;
}
else
{
bcopy (ref, p, sizeof ref - 1);
p += sizeof ref - 1;
}
}
else if (p == &flagstring[1])
{
words = 0;
--p;
}
else if (p[-1] == '-')
/* Kill the final space and dash. */
p -= 2;
/* Terminate the string. */
*p = '\0';
v = define_variable ("MAKEFLAGS", 9,
/* On Sun, the value of MFLAGS starts with a `-' but
the value of MAKEFLAGS lacks the `-'.
Be compatible with this unless FLAGSTRING starts
with a long option `--foo', since removing the
first dash would result in the bogus `-foo'. */
flagstring[1] == '-' ? flagstring : &flagstring[1],
/* If there is just a single word of switches,
omit the leading dash unless it is a single
long option with two leading dashes. */
&flagstring[(words == 1 && command_variables == 0
&& flagstring[1] != '-')
? 1 : 0],
/* This used to use o_env, but that lost when a
makefile defined MAKEFLAGS. Makefiles set
MAKEFLAGS to add switches, but we still want
to redefine its value with the full set of
switches. Of course, an override or command
definition will still take precedence. */
o_file, 0);
o_file, 1);
if (! all)
/* The first time we are called, set MAKEFLAGS to always be exported.
We should not do this again on the second call, because that is
@@ -1687,7 +1835,7 @@ define_makeflags (all, makefile)
v->export = v_export;
/* Since MFLAGS is not parsed for flags, there is no reason to
override any makefile redefinition. */
(void) define_variable ("MFLAGS", 6, flagstring, o_env, 0);
(void) define_variable ("MFLAGS", 6, flagstring, o_env, 1);
}
/* Print version information. */
@@ -1755,6 +1903,13 @@ die (status)
dying = 1;
/* Try to move back to the original directory. This is essential on
MS-DOS (where there is really only one process), and on Unix it
puts core files in the original directory instead of the -C
directory. */
if (directory_before_chdir != 0)
chdir (directory_before_chdir);
if (print_version_flag)
print_version ();

View File

@@ -32,6 +32,20 @@ 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
@@ -43,33 +57,34 @@ The distinction between @file{./} and @file{$(srcdir)/} is important
when using the @samp{--srcdir} option to @file{configure}. A rule of
the form:
@example
@smallexample
foo.1 : foo.man sedscript
sed -e sedscript foo.man > foo.1
@end example
@end smallexample
@noindent
will fail when the current directory is not the source directory,
because @file{foo.man} and @file{sedscript} are not in the current
directory.
Relying on @samp{VPATH} to find the source file will work in the case
where there is a single dependency file, since the @file{make} automatic
variable @samp{$<} will represent the source file wherever it is. A
makefile target like
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 @file{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
@example
@smallexample
foo.o : bar.c
$(CC) $(CFLAGS) -I. -I$(srcdir) -c bar.c -o foo.o
@end example
$(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
@end smallexample
@noindent
should instead be written as
@example
@smallexample
foo.o : bar.c
$(CC) $(CFLAGS) $< -o $@@
@end example
$(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@@
@end smallexample
@noindent
in order to allow @samp{VPATH} to work correctly. When the target has
@@ -77,10 +92,10 @@ 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:
@example
@smallexample
foo.1 : foo.man sedscript
sed -s $(srcdir)/sedscript $(srcdir)/foo.man > foo.1
@end example
sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@@
@end smallexample
@node Utilities in Makefiles
@section Utilities in Makefiles
@@ -107,12 +122,21 @@ user can substitute alternatives. Here are some of the programs we
mean:
@example
ar bison cc flex install ld lex make ranlib yacc
ar bison cc flex install ld lex
make makeinfo ranlib texi2dvi yacc
@end example
When you use @code{ranlib}, you should test whether it exists, and run
it only if it exists, so that the distribution will work on systems that
don't have @code{ranlib}.
Use the following @code{make} variables:
@example
$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LEX)
$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
@end example
When you use @code{ranlib}, you should make sure nothing bad happens if
the system does not have @code{ranlib}. Arrange to ignore an error
from that command, and print a message before the command to tell the
user that failure of the @code{ranlib} command does not mean a problem.
If you use symbolic links, you should implement a fallback for systems
that don't have symbolic links.
@@ -129,29 +153,70 @@ 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
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.
@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 then run that
test.
simple test to verify that a program is properly installed, this target
should run that test.
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.
In the future, when we have a standard way of installing info files,
@samp{install} targets will be the proper place to do so.
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 script that edits the Info @file{dir} file to add or update the
menu entry for the given Info file; it will be 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
$(infodir)/foo.info: foo.info
# 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 $@@; \
# 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 --infodir=$(infodir) $$d/foo.info; \
else true; fi
@end smallexample
@item uninstall
Delete all the installed files that the @samp{install} target would
create (but not the noninstalled files such as @samp{make all} would
create).
This rule should not modify the directories where compilation is done,
only the directories where files are installed.
@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
@@ -171,50 +236,68 @@ 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 realclean
Delete everything from the current directory that can be reconstructed
with this Makefile. This typically includes everything deleted by
distclean, plus more: C source files produced by Bison, tags tables,
info files, and so on.
@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.
One exception, however: @samp{make realclean} should not delete
@file{configure} even if @file{configure} can be remade using a rule in
the Makefile. More generally, @samp{make realclean} should not delete
anything that needs to exist in order to run @file{configure}
and then begin to build the program.
The reason we say ``almost everything'' is that @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} 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
@code{maintainer-clean} should start with these two:
@example
@@echo "This command is intended for maintainers to use;"
@@echo "it deletes files that may require special tools to rebuild."
@end example
@item TAGS
Update a tags table for this program.
@item info
Generate any info files needed. The best way to write the rules is as
Generate any Info files needed. The best way to write the rules is as
follows:
@example
info: foo.info
@smallexample
info: foo.info
foo.info: $(srcdir)/foo.texi $(srcdir)/chap1.texi $(srcdir)/chap2.texi
foo.info: foo.texi chap1.texi chap2.texi
$(MAKEINFO) $(srcdir)/foo.texi
@end example
@end smallexample
@noindent
You must define the variable @code{MAKEINFO} in the Makefile.
It should run the Makeinfo program, which is part of the Texinfo2 distribution.
You must define the variable @code{MAKEINFO} in the Makefile. It should
run the @code{makeinfo} program, which is part of the Texinfo
distribution.
@item dvi
Generate DVI files for all TeXinfo documentation.
For example:
@example
@smallexample
dvi: foo.dvi
foo.dvi: $(srcdir)/foo.texi $(srcdir)/chap1.texi $(srcdir)/chap2.texi
foo.dvi: foo.texi chap1.texi chap2.texi
$(TEXI2DVI) $(srcdir)/foo.texi
@end example
@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 Texinfo2
run the program @code{texi2dvi}, which is part of the Texinfo
distribution. Alternatively, write just the dependencies, and allow GNU
Make to provide the command.
@@ -243,6 +326,37 @@ 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; 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 Command Variables
@section Variables for Specifying Commands
@@ -274,12 +388,12 @@ 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:
@example
@smallexample
CFLAGS = -g
ALL_CFLAGS = $(CFLAGS) -I.
ALL_CFLAGS = -I. $(CFLAGS)
.c.o:
$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $<
@end example
$(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
@@ -287,11 +401,15 @@ 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.
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 variables @code{INSTALL_PROGRAM} and
@code{INSTALL_DATA}. (The default for each of these should be
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:
@@ -311,48 +429,123 @@ installed.
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:
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}
(at least for now).
When building the complete GNU system, the prefix will be empty and
@file{/usr} will be a symbolic link to @file{/}.
@item exec_prefix
A prefix used in constructing the default values of the some of the
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)}.
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.
@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}.
@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}.
@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}.
@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 of 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}. 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}.
@c rewritten to avoid overfull hbox --tower
Do not install executables
@c 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}.
@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}.
@item libdir
The directory for installing executable files to be run by the program
rather than by users. Object files and libraries of object code should
also go in this directory. The idea is that this directory is used for
files that pertain to a specific machine architecture, but need not be
in the path for commands. The value of @code{libdir} should normally be
The directory for object files and libraries of object code. Do not
install executables here, they probably belong in @file{$(libexecdir)}
instead. The value of @code{libdir} should normally be
@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}.
@item datadir
The directory for installing read-only data files which the programs
refer to while they run. This directory is used for files which are
independent of the type of machine being used. This should normally be
@file{/usr/local/lib}, but write it as @file{$(prefix)/lib}.
@item statedir
The directory for installing data files which the programs modify while
they run. These files should be independent of the type of machine
being used, and it should be possible to share them among machines at a
network installation. This should normally be @file{/usr/local/lib},
but write it as @file{$(prefix)/lib}.
@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}.
@item includedir
@c rewritten to avoid overfull hbox --roland
@@ -384,14 +577,19 @@ 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.
The way to tell whether @file{foo.h} came from the Foo package is to put
a magic string in the file---part of a comment---and grep for that
string.
To tell whether @file{foo.h} came from the Foo package, put a magic
string in the file---part of a comment---and grep for that string.
@end table
Unix-style man pages are installed in one of the following:
@table @samp
@item mandir
The directory for installing the man pages (if any) for this package.
It should include the suffix for the proper section of the
manual---usually @samp{1} for a utility.
manual---usually @samp{1} for a utility. It will normally be
@file{/usr/local/man/man1}, but you should write it as
@file{$(prefix)/man/man1}.
@item man1dir
The directory for installing section 1 man pages.
@@ -408,13 +606,20 @@ application only.}
@item manext
The file name extension for the installed man page. This should contain
a period followed by the appropriate digit.
a period followed by the appropriate digit; it should normally be @samp{.1}.
@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}.
@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.
@@ -422,7 +627,7 @@ variable is normally inserted by the @code{configure} shell script.
For example:
@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.
@@ -432,10 +637,10 @@ 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.
libdir = $(exec_prefix)/lib
libexecdir = $(exec_prefix)/libexec
# Where to put the Info files.
infodir = $(prefix)/info
@end example
@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

25
make.h
View File

@@ -1,5 +1,5 @@
/* Miscellaneous global declarations and portability cruft for GNU Make.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -67,7 +67,7 @@ extern int errno;
#endif
/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
#if (defined (butterfly) || \
#if (defined (butterfly) || defined (__arm) || \
(defined (__mips) && defined (_SYSTYPE_SVR3)) || \
(defined (sequent) && defined (i386)))
#undef POSIX
@@ -173,7 +173,6 @@ extern unsigned int get_path_max ();
extern char *malloc (), *realloc ();
extern void free ();
extern void qsort ();
extern void abort (), exit ();
#endif /* Standard headers. */
@@ -252,6 +251,12 @@ extern char *alloca ();
#define ENUM_BITFIELD(bits)
#endif
#ifdef __MSDOS__
#define PATH_SEPARATOR_CHAR ';'
#else
#define PATH_SEPARATOR_CHAR ':'
#endif
extern void die ();
extern void message (), fatal (), error ();
extern void makefile_error (), makefile_fatal ();
@@ -299,17 +304,12 @@ extern void user_access (), make_access (), child_access ();
#include <vfork.h>
#endif
#if !defined (__GNU_LIBRARY__) && !defined (POSIX)
/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
because such systems often declare the in header files anyway. */
#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION)
#ifdef HAVE_SIGSETMASK
extern int sigsetmask ();
extern int sigblock ();
#endif
extern int kill ();
extern int atoi ();
extern long int atol ();
extern int unlink (), stat (), fstat ();
extern int pipe (), close (), read (), write (), open ();
extern long int lseek ();
#endif /* Not GNU C library or POSIX. */
@@ -330,6 +330,7 @@ extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
extern int env_overrides, no_builtin_rules_flag, print_version_flag;
extern int print_directory_flag, warn_undefined_variables_flag;
extern int posix_pedantic;
extern unsigned int job_slots;
extern double max_load_average;

View File

@@ -8,10 +8,11 @@
@c FSF publishers: format makebook.texi instead of using this file directly.
@set RCSID $Id$
@set EDITION 0.45
@set VERSION 3.71 Beta
@set UPDATED 11 May 1994
@set UPDATE-MONTH May 1994
@set EDITION 0.47
@set VERSION 3.72 Beta
@set UPDATED 1 November 1994
@set UPDATE-MONTH November 1994
@set ISBN 1-882114-50-7
@c finalout
@@ -71,7 +72,7 @@ Published by the Free Software Foundation @*
675 Massachusetts Avenue, @*
Cambridge, MA 02139 USA @*
Printed copies are available for $20 each. @*
ISBN 1-882114-16-7 @*
ISBN @value{ISBN} @*
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -2140,24 +2141,28 @@ match that file's name.
@findex .IGNORE
@item .IGNORE
Simply by being mentioned as a target, @code{.IGNORE} says to ignore
errors in execution of commands. The dependencies and commands for
@code{.IGNORE} are not meaningful.
If you specify dependencies 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.
@samp{.IGNORE} exists for historical compatibility. Since
@code{.IGNORE} 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}.
If mentioned as a target with no dependencies, @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 .SILENT
@item .SILENT
Simply by being mentioned as a target, @code{.SILENT} says not to
print commands before executing them. The dependencies and commands
for @code{.SILENT} are not meaningful.
If you specify dependencies for @code{.SILENT}, then @code{make} will
not the print commands to remake those particular files before executing
them. The commands for @code{.SILENT} are not meaningful.
@samp{.SILENT} exists for historical compatibility. We recommend you
use the more selective ways to silence specific commands.
If mentioned as a target with no dependencies, @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}).
@@ -2581,7 +2586,8 @@ called @file{@var{name}.d} from a C source file called @file{@var{name}.c}:
@example
@group
%.d: %.c
$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< | sed '\''s/$*.o/& $@@/g'\'' > $@@'
$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
| sed '\''s/$*\\.o[ :]*/& $@@/g'\'' > $@@'
@end group
@end example
@@ -2594,6 +2600,12 @@ shell exits with the status of the last command in the pipeline
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 dependencies 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):
@@ -2641,11 +2653,13 @@ with no further work from you. @xref{Remaking Makefiles}.
@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
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-dependencies line with a
semicolon in between. Blank lines and lines of just comments may appear
among the command lines; they are ignored.
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
@@ -2711,7 +2725,7 @@ actually doing them.
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} has the same effect
@code{.SILENT} without dependencies has the same effect
(@pxref{Special Targets, ,Special Built-in Target Names}).
@code{.SILENT} is essentially obsolete since @samp{@@} is more flexible.@refill
@@ -2900,10 +2914,10 @@ This causes @code{rm} to continue even if it is unable to remove a file.
@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. These ways of ignoring errors are
obsolete because @samp{-} is more flexible.
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 dependencies. 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,
@@ -2916,6 +2930,7 @@ 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
@@ -2937,11 +2952,28 @@ 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 timestamp 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)
@@ -3032,28 +3064,6 @@ is @samp{cd subdir; /bin/make}. If you use a special version of
executed for recursive invocations.
@cindex @code{cd} (shell command)
Also, any arguments that define variable values are added to @code{MAKE},
so the sub-@code{make} gets them too. Thus, if you do @samp{make
CFLAGS=-O}, so that all C compilations will be optimized, the
sub-@code{make} is run with @samp{cd subdir; /bin/make CFLAGS=-O}.@refill
@vindex MAKE_COMMAND
@vindex MAKEOVERRIDES
The @code{MAKE} variable actually just refers to two other variables
which contain these special values. In fact, @code{MAKE} is always
defined as @samp{$(MAKE_COMMAND) $(MAKEOVERRIDES)}. The variable
@code{MAKE_COMMAND} is the file name with which @code{make} was invoked
(such as @file{/bin/make}, above). The variable @code{MAKEOVERRIDES}
contains definitions for the variables defined on the command line; in
the above example, its value is @samp{CFLAGS=-O}. If you @emph{do not}
want these variable definitions done in all recursive @code{make}
invocations, you can redefine the @code{MAKEOVERRIDES} variable to
remove them. You do this in any of the normal ways for defining
variables: in a makefile (@pxref{Setting, ,Setting Variables}); on the command
line with an argument like @samp{MAKEOVERRIDES=}
(@pxref{Overriding, ,Overriding Variables}); or with an environment variable
(@pxref{Environment, ,Variables from the Environment}).
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.
@@ -3096,9 +3106,9 @@ commands, is propagated to the subsystem.@refill
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 sub-@code{make}'s makefile unless
you use the @samp{-e} switch
(@pxref{Options Summary, ,Summary of Options}).@refill
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
@@ -3116,6 +3126,15 @@ 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
@@ -3264,6 +3283,15 @@ 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{-I}, and recursion
@@ -3313,13 +3341,39 @@ 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 in 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 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:
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:
@@ -5346,12 +5400,12 @@ variable names because many strange things are valid variable names, but
are probably not what you intended. For example,
@smallexample
files := $(foreach Es escrito en espanol!,b c ch,$(find_files))
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{Es escrito en espanol!} (es un nombre bastante largo,
whose name is @samp{Esta escrito en espanol!} (es un nombre bastante largo,
no?), but it is more likely to be a mistake.
@node Origin Function, Shell Function, Foreach Function, Functions
@@ -5581,7 +5635,9 @@ dependencies of goals, or dependencies of dependencies 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.
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,
@@ -7106,6 +7162,14 @@ the value of @code{$^} contains just one copy of the name.
@cindex dependencies, list of all
@cindex list of all dependencies
@vindex $+
@vindex + @r{(automatic variable)}
@item $+
This is like @samp{$^}, but dependencies 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 $*
@@ -7620,6 +7684,7 @@ main use is as subroutine libraries for linking.
@menu
* 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.
@end menu
@@ -7676,7 +7741,7 @@ example, @w{@samp{foolib(*.o)}} expands to all existing members of the
@file{foolib} archive whose names end in @samp{.o}; perhaps
@samp{@w{foolib(hack.o)} @w{foolib(kludge.o)}}.
@node Archive Update, Archive Suffix Rules, Archive Members, Archives
@node Archive Update
@section Implicit Rule for Archive Member Targets
Recall that a target that looks like @file{@var{a}(@var{m})} stands for the
@@ -7766,7 +7831,24 @@ files into the archive, as described in the preceding section.
This is not necessary when using the GNU @code{ar} program, which
updates the @file{__.SYMDEF} member automatically.
@node Archive Suffix Rules, , Archive Update, Archives
@node Archive Pitfalls
@section Dangers When Using Archives
@cindex archive, and parallel execution
@cindex parallel execution, and archive update
@cindex archive, and @code{-j}
@cindex @code{-j}, and archive update
It is important to be careful when using parallel execution (the
@code{-j} switch; @pxref{Parallel, ,Parallel Execution}) and archives.
If multiple @code{ar} commands run at the same time on the same archive
file, they will not know about each other and can corrupt the file.
Possibly a future version of @code{make} will provide a mechanism to
circumvent this problem by serializing all commands that operate on the
same archive file. But for the time being, you must either write your
makefiles to avoid this problem in some other way, or not use @code{-j}.
@node Archive Suffix Rules, , Archive Pitfalls, Archives
@section Suffix Rules for Archive Files
@cindex suffix rule, for archive
@cindex archive, suffix rule for
@@ -7912,8 +7994,9 @@ same time. @xref{Chained Rules, ,Chains of Implicit Rules}.
@item
The automatic variable @code{$^} containing a list of all dependencies
of the current target. We did not invent this, but we have no idea who did.
@xref{Automatic, ,Automatic Variables}.
of the current target. We did not invent this, but we have no idea who
did. @xref{Automatic, ,Automatic Variables}. The automatic variable
@code{$+} is a simple extension of @code{$^}.
@item
The ``what if'' flag (@samp{-W} in GNU @code{make}) was (as far as we know)
@@ -8381,9 +8464,11 @@ For dependencies which are archive members, only
the member named is used (@pxref{Archives}).
@item $^
@itemx $+
The names of all the dependencies, with spaces between them. For
dependencies which are archive members, only the member named is used
(@pxref{Archives}).
(@pxref{Archives}). The value of @code{$^} omits duplicate
dependencies, while @code{$+} retains them and preserves their order.
@item $*
The stem with which an implicit rule matches
@@ -8409,6 +8494,10 @@ The directory part and the file-within-directory part of @code{$<}.
@itemx $(^F)
The directory part and the file-within-directory part of @code{$^}.
@item $(+D)
@itemx $(+F)
The directory part and the file-within-directory part of @code{$+}.
@item $(?D)
@itemx $(?F)
The directory part and the file-within-directory part of @code{$?}.

24
misc.c
View File

@@ -461,12 +461,8 @@ dep_name (dep)
setregid functions, but they don't work as in BSD and only the POSIX.1
way works. */
#ifndef HAVE_SETREUID
#undef HAVE_SETREUID
#endif
#ifndef HAVE_SETREGID
#undef HAVE_SETREGID
#endif
#else /* Not POSIX. */
@@ -720,3 +716,23 @@ get_path_max ()
return value;
}
#endif
/* On some systems, stat can return EINTR. */
int
safe_stat (name, buf)
char *name;
struct stat *buf;
{
int ret;
#ifdef EINTR
do
#endif
ret = stat (name, buf);
#ifdef EINTR
while (ret < 0 && errno == EINTR);
#endif
return ret;
}

107
read.c
View File

@@ -1,5 +1,5 @@
/* Reading and parsing of makefiles for GNU Make.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -240,6 +240,7 @@ read_makefile (filename, flags)
char *p2;
int ignoring = 0, in_ignored_define = 0;
int no_targets = 0; /* Set when reading a rule without targets. */
char *passed_filename = filename;
struct nameseq *filenames = 0;
struct dep *deps;
@@ -288,7 +289,6 @@ read_makefile (filename, flags)
if (!(flags & RM_NO_TILDE) && filename[0] == '~')
{
char *expanded = tilde_expand (filename);
/* This is a possible memory leak, but I don't care. */
if (expanded != 0)
filename = expanded;
}
@@ -330,6 +330,8 @@ read_makefile (filename, flags)
if (flags & RM_DONTCARE)
deps->file->dontcare = 1;
}
if (filename != passed_filename)
free (filename);
filename = deps->file->name;
deps->changed = flags;
deps = 0;
@@ -360,6 +362,47 @@ read_makefile (filename, flags)
lineno += nlines;
nlines = readline (&lb, infile, filename, lineno);
/* Check for a shell command line first.
If it is not one, we can stop treating tab specially. */
if (lb.buffer[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;
/* If there is no preceding rule line, don't treat this line
as a command, even though it begins with a tab character.
SunOS 4 make appears to behave this way. */
if (filenames != 0)
{
if (ignoring)
/* Yep, this is a shell command, and we don't care. */
continue;
/* Append this command line to the line being accumulated. */
p = lb.buffer;
if (commands_idx == 0)
commands_started = lineno;
len = strlen (p);
if (len + 1 + commands_idx > commands_len)
{
commands_len = (len + 1 + commands_idx) * 2;
commands = (char *) xrealloc (commands, commands_len);
}
bcopy (p, &commands[commands_idx], len);
commands_idx += len;
commands[commands_idx++] = '\n';
continue;
}
}
/* This line is not a shell command line. Don't worry about tabs. */
if (collapsed_length < lb.size)
{
collapsed_length = lb.size;
@@ -372,17 +415,20 @@ read_makefile (filename, flags)
collapse_continuations (collapsed);
remove_comments (collapsed);
p = collapsed;
while (isspace (*p) && *p != '\t')
++p;
/* We cannot consider a line containing just a tab to be empty
because it might constitute an empty command for a target. */
if (*p == '\0' && lb.buffer[0] != '\t')
continue;
/* strncmp is first to avoid dereferencing out into space. */
#define word1eq(s, l) (!strncmp (s, p, l) \
&& (p[l] == '\0' || isblank (p[l])))
p = collapsed;
while (isspace (*p))
++p;
if (*p == '\0')
/* This line is completely empty. */
continue;
/* We must first check for conditional and `define' directives before
ignoring anything, since they control what we will do with
following lines. */
if (!in_ignored_define
&& (word1eq ("ifdef", 5) || word1eq ("ifndef", 6)
|| word1eq ("ifeq", 4) || word1eq ("ifneq", 5)
@@ -458,40 +504,7 @@ read_makefile (filename, flags)
/* Ignore the line. We continue here so conditionals
can appear in the middle of a rule. */
continue;
else if (lb.buffer[0] == '\t')
{
/* This line is a shell command. */
unsigned int len;
if (no_targets)
/* Ignore the commands in a rule with no targets. */
continue;
/* If there is no preceding rule line, don't treat this line
as a command, even though it begins with a tab character.
SunOS 4 make appears to behave this way. */
if (filenames != 0)
{
/* Append this command line to the line being accumulated. */
p = lb.buffer;
if (commands_idx == 0)
commands_started = lineno;
len = strlen (p);
if (len + 1 + commands_idx > commands_len)
{
commands_len = (len + 1 + commands_idx) * 2;
commands = (char *) xrealloc (commands, commands_len);
}
bcopy (p, &commands[commands_idx], len);
commands_idx += len;
commands[commands_idx++] = '\n';
continue;
}
}
if (word1eq ("export", 6))
else if (word1eq ("export", 6))
{
struct variable *v;
p2 = next_token (p + 6);
@@ -618,7 +631,7 @@ read_makefile (filename, flags)
;
else if (lb.buffer[0] == '\t')
{
p = lb.buffer;
p = collapsed; /* Ignore comments. */
while (isblank (*p))
++p;
if (*p == '\0')
@@ -1788,7 +1801,7 @@ construct_include_path (arg_dirs)
dir = expanded;
}
if (stat (dir, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
if (safe_stat (dir, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
{
if (idx == max - 1)
{
@@ -1805,7 +1818,7 @@ construct_include_path (arg_dirs)
/* Now add at the end the standard default dirs. */
for (i = 0; default_include_directories[i] != 0; ++i)
if (stat (default_include_directories[i], &stbuf) == 0
if (safe_stat (default_include_directories[i], &stbuf) == 0
&& S_ISDIR (stbuf.st_mode))
dirs[idx++] = default_include_directories[i];

View File

@@ -1,5 +1,5 @@
/* Basic dependency engine for GNU Make.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "job.h"
#include "dep.h"
#include "file.h"
#include <assert.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
@@ -277,9 +278,7 @@ update_file (file, depth)
return 0;
default:
error ("internal error: `%s' command_state == %d in update_file",
f->name, (int) f->command_state);
abort ();
assert (f->command_state == cs_running);
break;
}
}
@@ -468,7 +467,7 @@ update_file_1 (file, depth)
if (running)
{
file->command_state = cs_deps_running;
set_command_state (file, cs_deps_running);
--depth;
DEBUGPR ("The dependencies of `%s' are being made.\n");
return 0;
@@ -478,9 +477,8 @@ update_file_1 (file, depth)
if (dep_status != 0)
{
file->command_state = cs_finished;
file->update_status = dep_status;
file->updated = 1;
notice_finished_file (file);
depth--;
@@ -493,7 +491,16 @@ update_file_1 (file, depth)
return dep_status;
}
file->command_state = cs_not_started;
if (file->command_state == cs_deps_running)
/* The commands for some deps were running on the last iteration, but
they have finished now. Reset the command_state to not_started to
simplify later bookkeeping. It is important that we do this only
when the prior state was cs_deps_running, because that prior state
was definitely propagated to FILE's also_make's by set_command_state
(called above), but in another state an also_make may have
independently changed to finished state, and we would confuse that
file's bookkeeping (updated, but not_started is bogus state). */
set_command_state (file, cs_not_started);
/* Now record which dependencies are more
recent than this file, so we can define $?. */
@@ -549,9 +556,7 @@ update_file_1 (file, depth)
if (!must_make)
{
DEBUGPR ("No need to remake target `%s'.\n");
file->command_state = cs_finished;
file->update_status = 0;
file->updated = 1;
notice_finished_file (file);
return 0;
}
@@ -574,13 +579,9 @@ update_file_1 (file, depth)
case 0:
DEBUGPR ("Successfully remade target file `%s'.\n");
break;
case -1:
error ("internal error: `%s' update_status is -1 at cs_finished!",
file->name);
abort ();
default:
error ("internal error: `%s' update_status invalid!", file->name);
abort ();
assert (file->update_status == 0 || file->update_status == 1);
break;
}
file->updated = 1;
@@ -596,18 +597,19 @@ notice_finished_file (file)
register struct file *file;
{
struct dep *d;
int ran = file->command_state == cs_running;
file->command_state = cs_finished;
file->updated = 1;
if (touch_flag
/* The update status will be:
-1 if no commands were run;
0 if some commands (+ or ${MAKE}) were run and won;
-1 if this target was not remade;
0 if 0 or more commands (+ or ${MAKE}) were run and won;
1 if some commands were run and lost.
The only time we don't want to touch the target is if
it had some recursive commands, and they lost. */
&& file->update_status != 1)
We touch the target if it has commands which either were not run
or won when they ran (i.e. status is 0). */
&& file->update_status == 0)
{
if (file->cmds != 0 && file->cmds->any_recurse)
{
@@ -629,7 +631,7 @@ notice_finished_file (file)
}
}
if (!file->phony)
if (ran && !file->phony)
{
struct file *f;
@@ -645,7 +647,7 @@ notice_finished_file (file)
f->last_mtime = file->last_mtime;
}
if (file->update_status != -1)
if (ran && file->update_status != -1)
/* We actually tried to update FILE, which has
updated its also_make's as well (if it worked).
If it didn't work, it wouldn't work again for them.
@@ -656,7 +658,7 @@ notice_finished_file (file)
d->file->updated = 1;
d->file->update_status = file->update_status;
if (!d->file->phony)
if (ran && !d->file->phony)
/* Fetch the new modification time.
We do this instead of just invalidating the cached time
so that a vpath_search can happen. Otherwise, it would
@@ -738,7 +740,7 @@ check_dep (file, depth, this_mtime, must_make_ptr)
/* Record that some of FILE's dependencies are still being made.
This tells the upper levels to wait on processing it until
the commands are finished. */
file->command_state = cs_deps_running;
set_command_state (file, cs_deps_running);
lastd = d;
d = d->next;
@@ -777,8 +779,16 @@ touch_file (file)
{
struct stat statbuf;
char buf;
int status;
if (fstat (fd, &statbuf) < 0)
#ifdef EINTR
do
#endif
status = fstat (fd, &statbuf);
#ifdef EINTR
while (status < 0 && errno == EINTR);
#endif
if (status < 0)
TOUCH_ERROR ("touch: fstat: ");
/* Rewrite character 0 same as it already is. */
if (read (fd, &buf, 1) < 0)
@@ -843,6 +853,9 @@ remake_file (file)
execute_file_commands (file);
return;
}
else
/* This tells notice_finished_file it is ok to touch the file. */
file->update_status = 0;
}
/* This does the touching under -t. */
@@ -971,7 +984,7 @@ name_mtime (name)
{
struct stat st;
if (stat (name, &st) < 0)
if (safe_stat (name, &st) < 0)
return (time_t) -1;
return (time_t) st.st_mtime;

View File

@@ -20,14 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <signal.h>
#ifdef HAVE_CONFIG_H
#if defined (emacs) || defined (CONFIG_BROKETS)
/* We use <config.h> instead of "config.h" so that a compilation
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
#include <config.h>
#else
#include "config.h"
#endif
#endif
/* Some systems do not define NSIG in <signal.h>. */

View File

@@ -387,12 +387,14 @@ define_automatic_variables ()
define_variable ("<D", 2, "$(patsubst %/,%,$(dir $<))", o_automatic, 1);
define_variable ("?D", 2, "$(patsubst %/,%,$(dir $?))", o_automatic, 1);
define_variable ("^D", 2, "$(patsubst %/,%,$(dir $^))", o_automatic, 1);
define_variable ("+D", 2, "$(patsubst %/,%,$(dir $+))", o_automatic, 1);
define_variable ("@F", 2, "$(notdir $@)", o_automatic, 1);
define_variable ("%F", 2, "$(notdir $%)", o_automatic, 1);
define_variable ("*F", 2, "$(notdir $*)", o_automatic, 1);
define_variable ("<F", 2, "$(notdir $<)", o_automatic, 1);
define_variable ("?F", 2, "$(notdir $?)", o_automatic, 1);
define_variable ("^F", 2, "$(notdir $^)", o_automatic, 1);
define_variable ("+F", 2, "$(notdir $+)", o_automatic, 1);
}
int export_all_variables;

19
vpath.c
View File

@@ -1,5 +1,5 @@
/* Implementation of pattern-matching file search paths for GNU Make.
Copyright (C) 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -177,7 +177,7 @@ construct_vpath_list (pattern, dirpath)
maxelem = 2;
p = dirpath;
while (*p != '\0')
if (*p++ == ':' || isblank (*p))
if (*p++ == PATH_SEPARATOR_CHAR || isblank (*p))
++maxelem;
vpath = (char **) xmalloc (maxelem * sizeof (char *));
@@ -185,7 +185,7 @@ construct_vpath_list (pattern, dirpath)
/* Skip over any initial colons and blanks. */
p = dirpath;
while (*p == ':' || isblank (*p))
while (*p == PATH_SEPARATOR_CHAR || isblank (*p))
++p;
elem = 0;
@@ -196,7 +196,7 @@ construct_vpath_list (pattern, dirpath)
/* Find the end of this entry. */
v = p;
while (*p != '\0' && *p != ':' && !isblank (*p))
while (*p != '\0' && *p != PATH_SEPARATOR_CHAR && !isblank (*p))
++p;
len = p - v;
@@ -225,7 +225,7 @@ construct_vpath_list (pattern, dirpath)
}
/* Skip over colons and blanks between entries. */
while (*p == ':' || isblank (*p))
while (*p == PATH_SEPARATOR_CHAR || isblank (*p))
++p;
}
@@ -419,7 +419,7 @@ selective_vpath_search (path, file, mtime_ptr)
*n = '/';
if (!exists_in_cache /* Makefile-mentioned file need not exist. */
|| stat (name, &st) == 0) /* Does it really exist? */
|| safe_stat (name, &st) == 0) /* Does it really exist? */
{
/* We have found a file.
Store the name we found into *FILE for the caller. */
@@ -434,6 +434,8 @@ selective_vpath_search (path, file, mtime_ptr)
return 1;
}
else
exists = 0;
}
}
@@ -461,7 +463,7 @@ print_vpath_data_base ()
for (i = 0; v->searchpath[i] != 0; ++i)
printf ("%s%c", v->searchpath[i],
v->searchpath[i + 1] == 0 ? '\n' : ':');
v->searchpath[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
}
if (vpaths == 0)
@@ -479,6 +481,7 @@ print_vpath_data_base ()
fputs ("\n# General (`VPATH' variable) search path:\n# ", stdout);
for (i = 0; path[i] != 0; ++i)
printf ("%s%c", path[i], path[i + 1] == 0 ? '\n' : ':');
printf ("%s%c", path[i],
path[i + 1] == 0 ? '\n' : PATH_SEPARATOR_CHAR);
}
}