diff options
author | Paul Smith <psmith@gnu.org> | 2019-08-25 17:11:10 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2019-08-26 07:54:09 -0400 |
commit | 2273ab7069b83669daeb4b36515631a73b80b5ee (patch) | |
tree | 3ece7a7a719018e789758b469fb3b60b50f26fd9 | |
parent | 2e388a18a196abef4e846517a686d436e614cd12 (diff) | |
download | make-git-2273ab7069b83669daeb4b36515631a73b80b5ee.tar.gz |
Update maintainer mode to support debug wait points.
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.
-rwxr-xr-x | build_w32.bat | 10 | ||||
-rw-r--r-- | src/main.c | 25 | ||||
-rw-r--r-- | src/makeint.h | 10 | ||||
-rw-r--r-- | src/misc.c | 22 |
4 files changed, 46 insertions, 21 deletions
diff --git a/build_w32.bat b/build_w32.bat index abe66359..16aa9a44 100755 --- a/build_w32.bat +++ b/build_w32.bat @@ -38,6 +38,12 @@ set O=obj set ARCH=x64
set DEBUG=N
+if exist maintMakefile (
+ set MAINT=Y
+) else (
+ set MAINT=N
+)
+
:ParseSW
if "%1" == "--debug" goto SetDebug
if "%1" == "--without-guile" goto NoGuile
@@ -72,6 +78,8 @@ shift goto ParseSW
:DoneSW
+if "%MAINT%" == "Y" echo - Enabling maintainer mode
+
if "%COMPILER%" == "gcc" goto FindGcc
:: Find a compiler. Visual Studio requires a lot of effort to locate :-/.
@@ -151,6 +159,7 @@ set LINKOPTS= if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug
if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"
if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG
+if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"
:: Show the compiler version that we found
:: Unfortunately this also shows a "usage" note; I can't find anything better.
echo.
@@ -162,6 +171,7 @@ set OUTDIR=.\GccRel set OPTS=-O2
if "%DEBUG%" == "Y" set OPTS=-O0
if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
+if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
:: Show the compiler version that we found
echo.
%COMPILER% --version
@@ -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(); @@ -1338,6 +1332,9 @@ main (int argc, char **argv, char **envp) #ifdef MAKE_LOAD " load" #endif +#ifdef MAKE_MAINTAINER_MODE + " maintainer" +#endif ; define_variable_cname (".FEATURES", features, o_default, 0); @@ -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); diff --git a/src/makeint.h b/src/makeint.h index dd6e894f..3b0f1f19 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -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 @@ -405,6 +405,28 @@ free_ns_chain (struct nameseq *ns) } +#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 + + + /* Provide support for temporary files. */ #ifndef HAVE_STDLIB_H |