I have a set of programs to start/stop, with certain dependencies among each
other. I would want to use make to start and stop them, since it handles
dependencies autmatically.
I thought of separating all the deps in a separate include file, and put in
the main makefile only the commands for starting/stopping/restarting them.
I use timestamp files to record start/stop events.
Example of the include file:
program1.start:
program2.start: program1.start
program1.stop: program2.stop
program2.stop:
etc (this is customizable).
In another part of the makefile, I put the commands to start and stop the
programs:
%.start:
��������<script that starts the program and creates file .start>
%.stop:
��������<script that stops the program, removes file .start and creates
file .stop>
So, "make program2.start" does what one wants, taking care of the deps
starting program1 first. The same holds for "make program1.stop".
On the other hand, restarting a program requires stopping all the programs
that depend on it, restarting the program, and restarting the deps stopped
before. To implement this, I was thinking to do the following (%.start not
modified):
%.stop:
��������<script that stops the program, removes file .start and creates
the file .stop; if RESTART = 1, also creates .stopped_dep file
for the stopped program>
.PHONY: %.restart %.restartdeps
%.restart: RESTART = 1 � �# pattern-specific variable: if my understanding is
� � � � � � � � � � � � � # correct, this should only affect this target and
� � � � � � � � � � � � � # all its dependencies
%.restart: %.stop %.start %.restartdeps
%.restartdeps: $(patsubst %.stopped_dep, %.start, $(wildcard *.stopped_dep))
The idea is: %.restart sets RESTART=1, so all stopped services also get
their .stopped_dep file, that %.restartdeps sees and can invoke %.start on
each of them.
But I'm not sure at all about the correctness of my solution, since I suspect
there's a simpler way to do a restart. Furthermore, doing a "make
program1.restart" aborts with the message
make: *** No rule to make target `program1.restart'. Stop.
Any help will be greatly appreciated.
Thanks
D
_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/help-make