mirror of
https://github.com/mirror/make.git
synced 2025-03-27 12:31:23 +08:00
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.
This commit is contained in:
parent
2e388a18a1
commit
2273ab7069
@ -38,6 +38,12 @@ set O=obj
|
|||||||
set ARCH=x64
|
set ARCH=x64
|
||||||
set DEBUG=N
|
set DEBUG=N
|
||||||
|
|
||||||
|
if exist maintMakefile (
|
||||||
|
set MAINT=Y
|
||||||
|
) else (
|
||||||
|
set MAINT=N
|
||||||
|
)
|
||||||
|
|
||||||
:ParseSW
|
:ParseSW
|
||||||
if "%1" == "--debug" goto SetDebug
|
if "%1" == "--debug" goto SetDebug
|
||||||
if "%1" == "--without-guile" goto NoGuile
|
if "%1" == "--without-guile" goto NoGuile
|
||||||
@ -72,6 +78,8 @@ shift
|
|||||||
goto ParseSW
|
goto ParseSW
|
||||||
|
|
||||||
:DoneSW
|
:DoneSW
|
||||||
|
if "%MAINT%" == "Y" echo - Enabling maintainer mode
|
||||||
|
|
||||||
if "%COMPILER%" == "gcc" goto FindGcc
|
if "%COMPILER%" == "gcc" goto FindGcc
|
||||||
|
|
||||||
:: Find a compiler. Visual Studio requires a lot of effort to locate :-/.
|
:: 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 OUTDIR=.\WinDebug
|
||||||
if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"
|
if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"
|
||||||
if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG
|
if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG
|
||||||
|
if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"
|
||||||
:: Show the compiler version that we found
|
:: Show the compiler version that we found
|
||||||
:: Unfortunately this also shows a "usage" note; I can't find anything better.
|
:: Unfortunately this also shows a "usage" note; I can't find anything better.
|
||||||
echo.
|
echo.
|
||||||
@ -162,6 +171,7 @@ set OUTDIR=.\GccRel
|
|||||||
set OPTS=-O2
|
set OPTS=-O2
|
||||||
if "%DEBUG%" == "Y" set OPTS=-O0
|
if "%DEBUG%" == "Y" set OPTS=-O0
|
||||||
if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
|
if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
|
||||||
|
if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
|
||||||
:: Show the compiler version that we found
|
:: Show the compiler version that we found
|
||||||
echo.
|
echo.
|
||||||
%COMPILER% --version
|
%COMPILER% --version
|
||||||
|
25
src/main.c
25
src/main.c
@ -192,12 +192,6 @@ int db_level = 0;
|
|||||||
|
|
||||||
char *output_sync_option = 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. */
|
/* Environment variables override makefile definitions. */
|
||||||
|
|
||||||
int env_overrides = 0;
|
int env_overrides = 0;
|
||||||
@ -425,9 +419,6 @@ static const struct command_switch switches[] =
|
|||||||
{ 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
|
{ 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" },
|
{ 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" },
|
||||||
{ 'd', flag, &debug_flag, 1, 1, 0, 0, 0, 0 },
|
{ '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', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", },
|
||||||
{ 'E', strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
|
{ 'E', strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
|
||||||
{ 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" },
|
{ '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;
|
no_default_sh_exe = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Useful for attaching debuggers, etc. */
|
||||||
|
SPIN ("main-entry");
|
||||||
|
|
||||||
output_init (&make_sync);
|
output_init (&make_sync);
|
||||||
|
|
||||||
initialize_stopchar_map();
|
initialize_stopchar_map();
|
||||||
@ -1337,6 +1331,9 @@ main (int argc, char **argv, char **envp)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef MAKE_LOAD
|
#ifdef MAKE_LOAD
|
||||||
" load"
|
" load"
|
||||||
|
#endif
|
||||||
|
#ifdef MAKE_MAINTAINER_MODE
|
||||||
|
" maintainer"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -1523,16 +1520,6 @@ main (int argc, char **argv, char **envp)
|
|||||||
makelevel = 0;
|
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. */
|
/* Set always_make_flag if -B was given and we've not restarted already. */
|
||||||
always_make_flag = always_make_set && (restarts == 0);
|
always_make_flag = always_make_set && (restarts == 0);
|
||||||
|
|
||||||
|
@ -598,6 +598,14 @@ typedef int (*load_func_t)(const floc *flocp);
|
|||||||
int load_file (const floc *flocp, const char **filename, int noerror);
|
int load_file (const floc *flocp, const char **filename, int noerror);
|
||||||
void unload_file (const char *name);
|
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,
|
/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
|
||||||
because such systems often declare them in header files anyway. */
|
because such systems often declare them in header files anyway. */
|
||||||
|
|
||||||
@ -726,7 +734,6 @@ extern unsigned int commands_started;
|
|||||||
|
|
||||||
extern int handling_fatal_signal;
|
extern int handling_fatal_signal;
|
||||||
|
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
|
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
|
||||||
#endif
|
#endif
|
||||||
@ -734,7 +741,6 @@ extern int handling_fatal_signal;
|
|||||||
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
|
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define MAKE_SUCCESS 0
|
#define MAKE_SUCCESS 0
|
||||||
#define MAKE_TROUBLE 1
|
#define MAKE_TROUBLE 1
|
||||||
#define MAKE_FAILURE 2
|
#define MAKE_FAILURE 2
|
||||||
|
22
src/misc.c
22
src/misc.c
@ -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. */
|
/* Provide support for temporary files. */
|
||||||
|
|
||||||
#ifndef HAVE_STDLIB_H
|
#ifndef HAVE_STDLIB_H
|
||||||
|
Loading…
Reference in New Issue
Block a user