summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-09-21 17:24:59 -0400
committerPaul Smith <psmith@gnu.org>2013-09-21 17:24:59 -0400
commit6c3e88e60f2c7d2bff3aa1967afcc59f27626c48 (patch)
tree2f5d702aa25de4f1815eed3f57b8b43cbf0dca35 /main.c
parent9cd01958da86a68d0e47defcb9745ab373ef3d79 (diff)
downloadgunmake-6c3e88e60f2c7d2bff3aa1967afcc59f27626c48.tar.gz
Ensure that output generated while reading makefiles is synced.
Diffstat (limited to 'main.c')
-rw-r--r--main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/main.c b/main.c
index bd8b478..f0a7174 100644
--- a/main.c
+++ b/main.c
@@ -550,6 +550,11 @@ int clock_skew_detected;
#endif
unsigned short stopchar_map[UCHAR_MAX + 1] = {0};
+/* If output-sync is enabled we'll collect all the output generated due to
+ options, while reading makefiles, etc. */
+
+struct output make_sync;
+
/* Mask of signals that are being caught with fatal_error_signal. */
@@ -1041,6 +1046,7 @@ main (int argc, char **argv, char **envp)
struct dep *read_files;
PATH_VAR (current_directory);
unsigned int restarts = 0;
+ unsigned int syncing = 0;
#ifdef WINDOWS32
char *unix_path = NULL;
char *windows32_path = NULL;
@@ -1052,6 +1058,8 @@ main (int argc, char **argv, char **envp)
no_default_sh_exe = 1;
#endif
+ output_init (&make_sync);
+
initialize_stopchar_map();
#ifdef SET_STACK_SIZE
@@ -1390,6 +1398,13 @@ main (int argc, char **argv, char **envp)
decode_env_switches (STRING_SIZE_TUPLE ("GNUMAKEFLAGS"));
decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
+ /* In output sync mode we need to sync any output generated by reading the
+ makefiles, such as in $(info ...) or stderr from $(shell ...) etc. */
+
+ syncing = make_sync.syncout = (output_sync == OUTPUT_SYNC_LINE
+ || output_sync == OUTPUT_SYNC_TARGET);
+ OUTPUT_SET (&make_sync);
+
#if 0
/* People write things like:
MFLAGS="CC=gcc -pipe" "CFLAGS=-g"
@@ -1399,6 +1414,16 @@ main (int argc, char **argv, char **envp)
decode_switches (argc, argv, 0);
+ /* Reset in case the switches changed our minds. */
+ syncing = (output_sync == OUTPUT_SYNC_LINE
+ || output_sync == OUTPUT_SYNC_TARGET);
+
+ if (make_sync.syncout && ! syncing)
+ output_close (&make_sync);
+
+ make_sync.syncout = syncing;
+ OUTPUT_SET (&make_sync);
+
/* Figure out the level of recursion. */
{
struct variable *v = lookup_variable (STRING_SIZE_TUPLE (MAKELEVEL_NAME));
@@ -1907,6 +1932,16 @@ main (int argc, char **argv, char **envp)
decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
#endif
+ /* Reset in case the switches changed our minds. */
+ syncing = (output_sync == OUTPUT_SYNC_LINE
+ || output_sync == OUTPUT_SYNC_TARGET);
+
+ if (make_sync.syncout && ! syncing)
+ output_close (&make_sync);
+
+ make_sync.syncout = syncing;
+ OUTPUT_SET (&make_sync);
+
/* If we've disabled builtin rules, get rid of them. */
if (no_builtin_rules_flag && ! old_builtin_rules_flag)
{
@@ -2077,6 +2112,11 @@ main (int argc, char **argv, char **envp)
/* Initialize the remote job module. */
remote_setup ();
+ /* Dump any output we've collected. */
+
+ OUTPUT_UNSET ();
+ output_close (&make_sync);
+
if (read_files != 0)
{
/* Update any makefiles if necessary. */
@@ -3358,6 +3398,13 @@ die (int status)
clean_jobserver (status);
+ if (output_context)
+ {
+ assert (output_context == &make_sync);
+ OUTPUT_UNSET ();
+ output_close (&make_sync);
+ }
+
output_close (NULL);
/* Try to move back to the original directory. This is essential on