[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] - Make - print rule with -d flag
From: |
Duane Ellis |
Subject: |
[PATCH] - Make - print rule with -d flag |
Date: |
Sat, 14 Apr 2007 12:25:32 -0400 |
User-agent: |
Thunderbird 1.5.0.10 (Windows/20070221) |
I often debug Makefiles and often ask: where did that command (rule)
come from?
My solution has always been to use combinations of "-d" and "-p" and
attempt to sort through the copious output.
With "-p" - make prints the resulting makefile.
With "-d" - make tells you what it is doing.
With *LARGE* makefiles {for example GCC}...
Or Makefile systems that make heavy use of "include make-fragment"
(Did you know GCC uses that feature?)
Debugging becomes 'a maze of twisty passages all alike'
Attached is a *simple* ( 9 line ) patch that greatly simplifies the way
through the maze
(and to the battery/lamp-oil vending machine in the middle of the maze)
here is an example [snip] from the NEW -d output of make while building g++
The _*OLD*_ "make -d" output is available with: make -d
>> Finished prerequisites of target file `g++'.
>> Must remake target `g++'.
>> Execute:
>> # commands to execute (from `../.././gcc/cp/Make-lang.in', line 65):
>> $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
>> $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
>> gcc -g -DIN_GCC -DCROSS_COMPILE .. [SNIP] ...
--Duane
====================================
diff -Naur make-3.81/commands.c make-3.81-patch-location-print/commands.c
--- make-3.81/commands.c 2006-02-20 02:14:01.000000000 +0000
+++ make-3.81-patch-location-print/commands.c 2007-04-14 15:47:53.000000000
+0000
@@ -27,6 +27,7 @@
#include "w32err.h"
#endif
+#include "debug.h"
#if VMS
# define FILE_LIST_SEPARATOR ','
#else
@@ -372,6 +373,10 @@
/* Don't go through all the preparations if
the commands are nothing but whitespace. */
+ if( ISDB( DB_LOCATION ) ){
+ printf( _("Execute:\n") );
+ print_commands( file->cmds );
+ }
for (p = file->cmds->commands; *p != '\0'; ++p)
if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
break;
diff -Naur make-3.81/debug.h make-3.81-patch-location-print/debug.h
--- make-3.81/debug.h 2006-02-11 22:16:04.000000000 +0000
+++ make-3.81-patch-location-print/debug.h 2007-04-14 15:39:16.000000000
+0000
@@ -20,6 +20,7 @@
#define DB_VERBOSE (0x002)
#define DB_JOBS (0x004)
#define DB_IMPLICIT (0x008)
+#define DB_LOCATION (0x010)
#define DB_MAKEFILES (0x100)
#define DB_ALL (0xfff)
diff -Naur make-3.81/main.c make-3.81-patch-location-print/main.c
--- make-3.81/main.c 2006-03-20 02:36:37.000000000 +0000
+++ make-3.81-patch-location-print/main.c 2007-04-14 15:40:22.000000000
+0000
@@ -623,6 +623,9 @@
case 'm':
db_level |= DB_BASIC | DB_MAKEFILES;
break;
+ case 'p': /* as in the -p flag */
+ db_level |= DB_LOCATION;
+ break;
case 'v':
db_level |= DB_BASIC | DB_VERBOSE;
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] - Make - print rule with -d flag,
Duane Ellis <=