http://www.gnu.org/software/make/manual/html_mono/make.html#SEC20
"After all makefiles have been checked, if any have actually been
changed, make starts with a clean slate and reads all the makefiles
over again. (It will also attempt to update each of them over again,
but normally this will not change them again, since they are already
up to date.)"
This doesn't work. I actually have to call Make myself to restart
it, but then I MUST kill make also by using /bin/false. This then
error results all makes and is really a very unclean way of making
make exit.
Two things...
1> it would be nice if there was a $(REMAKE) or something which
could forcably invoke - remove all makefiles, and reload them, or a
$(EXIT) which would cause make to end its execution.
2> The following makefile doesn't really work right.... the 'y'
makefile is built using 'x's which were read at include time, even if
'x' itself is updated...
The attached source 'echoto' program just gathers command line
parameters and echos them into a file. If a -c option is used it
writes a tab character... I needed this cause I couldn't figure out
how to do...
@echo '<tab>@echo <tab>hey we made it >>y' >> x
the second tab in there kept going away...
The normal steps this Makefile executes...
Might have to handbuild echoto...
fakeall:
build echoto if it doesn't already exist.
include x
x:Makefile (and a couple extra files to touch)
if makefile has changed, rebuild x...
content of x:
include y
y: x Makefile (extra)
echo fakeall: >y
echo \t echo hey we made it: <TICKS>
<TICKS> is a value read by the main makefile, and is built
written verbatim expanded into X, which causes an update to TICKS= to
rebuild Y with the appropriate value.
include ticks
ticks: Makefile (extra touchable flies)
echo TICKS=(roman numerate next tick) >> ticks
echo Current Tick: $(TICK)
So, if makefile or one of the extra files (bob, dillon for the two I
chose) is changed, ticks is incremented, it's new value is output
into ticks, and the current value is printed.
The first pass, include for ticks and x fail to get included (they do
not exist), ticks is created, and a new value for TICKS is created.
(It is not reloaded at this point) then X is created with the current
blank value for TICKS, which in turn creates y with the current rules
for x.
(touch Makefile)
ticks is updated (prints the prior value, writes the current), x is
updated, using the prior value of TICKS (again, not the newly
computed value), then Y is updated using the prior rules for x, not
the newly output ones. [ TICKS=II, x echos "we made it: I" > y, y
still has 'we made it: <blank'
(touch Makefile)
ticks is updated, x is updated using the originally loaded ticks, and
y is created using the originally loaded x, not the one which gets
updated after ticks is updated...
This is a log of the state of the system after the second touch is done.
M:\tmp\makemake>make
Prior Ticks : II (echos prior value)
hey we made it:I (is created from x, and reflects that value)
M:\tmp\makemake>type ticks
TICKS=III (TICKS really was updated to III, since prior was II
that's okay)
M:\tmp\makemake>type x
include y
y: x bob
@echo fakeall: >y
@./echoto -c y @echo hey we made it:II (this is prior TICKS,
not curent TICKS which is defined in the ticks file)
M:\tmp\makemake>type y
fakeall:
@echo hey we made it:I (this is the prior prior TICKS from
two touches ago)
------------------------------------------------------------------------
#include <stdio.h>
int main( int argc, char **argv )
{
int n;
int iscmd = 0;
char cmd[8192];
if( argc < 2 )
{
printf( "usage: echoto [-x] <output> <command line.....>\n" );
printf( "usage: c : prefix with a tab character..\n" );
return 1;
}
n = 1;
while( argv[n][0] == '-' )
{
int c = 1;
while( argv[n] && argv[n][c] ) switch( argv[n][c] )
{
case 'c':
case 'C':
iscmd = 1;
c++;
break;
default:
printf( "Unknown option: %c\n", argv[n][c] );
c++;
break;
}
n++;
}
{
int ofs = 0;
FILE *out = fopen( argv[n], "at+" );
if( !out )
out =fopen( argv[n], "wt" );
if( !out )
{
printf( "echoto: Failed to open %s for output\n", argv[n] );
return 1;
}
if( iscmd )
fprintf( out, "\t" );
for( n++; n < argc; n++ )
{
fprintf( out, "%s ", argv[n] );
}
fprintf( out, "\n" );
fclose( out );
}
return 0;
}
------------------------------------------------------------------------
ifdef __LINUX__
EXEC:=$(QUIET)exec
else
EXIT:=$(QUIET)exit
endif
# need this if $(REMAKE) cause /bin/false deletes this...
.PRECIOUS: x y
MAKEFILE=$(word 1,$(MAKEFILE_LIST))
#$(warning remake will be: $(MAKE) -s -C $(CURDIR) -f $(MAKEFILE)
$(MAKECMDGOALS))
define REMAKE @--$(QUIETCMD)$(MAKE) -s -C $(CURDIR) -f
$(MAKEFILE) $(MAKECMDGOALS)
@/bin/false
endef
.PHONY: fakeall all
fakeall: all
#fakeall:echoto
#echoto: echoto.c
# @gcc -o $@ $<
include ticks
#.PHONY:ticks
ticks: Makefile bob dillon
@echo TICKS=$(patsubst %ILI,%L,$(patsubst %XXXXIX,%IL,$(patsubst
%IXI,%X,$(patsubst %VIV,%IX,$(patsubst %IVI,%V,$(patsubst
%IIII,%IV,$(TICKS)I))))))>ticks
@echo Prior Ticks : $(TICKS)
# $(REMAKE)
include x
bob dillon: @echo . >$@;
x:Makefile bob dillon @echo include y >x
@echo y: $@ $? >>x
@echoto -c x @echo fakeall: \>y @echoto -c x @./echoto -c y
@echo hey we made it:$(TICKS)
# @echo ' $$(REMAKE)' >>x
# $(REMAKE)
Makefile: ;
------------------------------------------------------------------------
_______________________________________________
Bug-make mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-make