]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Update maintainer mode to support debug wait points.
authorPaul Smith <psmith@gnu.org>
Sun, 25 Aug 2019 21:11:10 +0000 (17:11 -0400)
committerPaul Smith <psmith@gnu.org>
Mon, 26 Aug 2019 11:54:09 +0000 (07:54 -0400)
Make a spin() method available when compiled in maintainer mode.
If a file exists in the working directory with a specific name,
make will sleep until the file is deleted.

Ensure that maintainer mode is enabled on Windows, using the same
algorithm we use on POSIX / autoconf systems.

* build_w32.bat: If maintMakefile exists, enable maintainer mode.
* src/main.c (main): Replace Windows-only suspend flag with spin().
* src/makeint.h: A SPIN() macro calls spin() in maintainer mode.
* src/misc.c (spin): If a spin file exists sleep until it's deleted.

build_w32.bat
src/main.c
src/makeint.h
src/misc.c

index abe66359bd232863065bc37070ea6cca8c0c9971..16aa9a44944b38f04b30701b5f551940fd10c780 100755 (executable)
@@ -38,6 +38,12 @@ set O=obj
 set ARCH=x64\r
 set DEBUG=N\r
 \r
+if exist maintMakefile (\r
+    set MAINT=Y\r
+) else (\r
+    set MAINT=N\r
+)\r
+\r
 :ParseSW\r
 if "%1" == "--debug" goto SetDebug\r
 if "%1" == "--without-guile" goto NoGuile\r
@@ -72,6 +78,8 @@ shift
 goto ParseSW\r
 \r
 :DoneSW\r
+if "%MAINT%" == "Y" echo - Enabling maintainer mode\r
+\r
 if "%COMPILER%" == "gcc" goto FindGcc\r
 \r
 :: Find a compiler.  Visual Studio requires a lot of effort to locate :-/.\r
@@ -151,6 +159,7 @@ set LINKOPTS=
 if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug\r
 if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"\r
 if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG\r
+if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"\r
 :: Show the compiler version that we found\r
 :: Unfortunately this also shows a "usage" note; I can't find anything better.\r
 echo.\r
@@ -162,6 +171,7 @@ set OUTDIR=.\GccRel
 set OPTS=-O2\r
 if "%DEBUG%" == "Y" set OPTS=-O0\r
 if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug\r
+if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"\r
 :: Show the compiler version that we found\r
 echo.\r
 %COMPILER% --version\r
index afc7fd97785bb07dd262cb9eb4ae88afcc3fb4a6..3e9a9056d5743eb29292921269bf1c8280d3577b 100644 (file)
@@ -192,12 +192,6 @@ int db_level = 0;
 
 char *output_sync_option = 0;
 
-#ifdef WINDOWS32
-/* Suspend make in main for a short time to allow debugger to attach */
-
-int suspend_flag = 0;
-#endif
-
 /* Environment variables override makefile definitions.  */
 
 int env_overrides = 0;
@@ -425,9 +419,6 @@ static const struct command_switch switches[] =
     { 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
     { 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" },
     { 'd', flag, &debug_flag, 1, 1, 0, 0, 0, 0 },
-#ifdef WINDOWS32
-    { 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
-#endif
     { 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", },
     { 'E', strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
     { 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" },
@@ -1081,6 +1072,9 @@ main (int argc, char **argv, char **envp)
   no_default_sh_exe = 1;
 #endif
 
+  /* Useful for attaching debuggers, etc.  */
+  SPIN ("main-entry");
+
   output_init (&make_sync);
 
   initialize_stopchar_map();
@@ -1337,6 +1331,9 @@ main (int argc, char **argv, char **envp)
 #endif
 #ifdef MAKE_LOAD
                            " load"
+#endif
+#ifdef MAKE_MAINTAINER_MODE
+                           " maintainer"
 #endif
                            ;
 
@@ -1523,16 +1520,6 @@ main (int argc, char **argv, char **envp)
       makelevel = 0;
   }
 
-#ifdef WINDOWS32
-  if (suspend_flag)
-    {
-      fprintf (stderr, "%s (pid = %ld)\n", argv[0], GetCurrentProcessId ());
-      fprintf (stderr, _("%s is suspending for 30 seconds..."), argv[0]);
-      Sleep (30 * 1000);
-      fprintf (stderr, _("done sleep(30). Continuing.\n"));
-    }
-#endif
-
   /* Set always_make_flag if -B was given and we've not restarted already.  */
   always_make_flag = always_make_set && (restarts == 0);
 
index dd6e894fbf2ee99d7390242fc44df1eb7044c516..3b0f1f192d055d957c8d1f54bed89406c4b16cbe 100644 (file)
@@ -598,6 +598,14 @@ typedef int (*load_func_t)(const floc *flocp);
 int load_file (const floc *flocp, const char **filename, int noerror);
 void unload_file (const char *name);
 
+/* Maintainer mode support */
+#ifdef MAKE_MAINTAINER_MODE
+# define SPIN(_s) spin (_s)
+void spin (const char* suffix);
+#else
+# define SPIN(_s)
+#endif
+
 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
    because such systems often declare them in header files anyway.  */
 
@@ -726,7 +734,6 @@ extern unsigned int commands_started;
 
 extern int handling_fatal_signal;
 
-
 #ifndef MIN
 #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
 #endif
@@ -734,7 +741,6 @@ extern int handling_fatal_signal;
 #define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
 #endif
 
-
 #define MAKE_SUCCESS 0
 #define MAKE_TROUBLE 1
 #define MAKE_FAILURE 2
index 7a1b9d9c242ed9bdcb1607543cb6d88bae998b63..a0f889804dc8c2063a49f6f5ea11180274827dca 100644 (file)
@@ -405,6 +405,28 @@ free_ns_chain (struct nameseq *ns)
 }
 \f
 
+#ifdef MAKE_MAINTAINER_MODE
+
+void spin(const char* type)
+{
+  char filenm[256];
+  struct stat dummy;
+
+  sprintf (filenm, ".make-spin-%s", type);
+
+  if (stat (filenm, &dummy) == 0)
+    {
+      fprintf (stderr, "SPIN on %s\n", filenm);
+      do
+        sleep (1);
+      while (stat (filenm, &dummy) == 0);
+    }
+}
+
+#endif
+
+\f
+
 /* Provide support for temporary files.  */
 
 #ifndef HAVE_STDLIB_H