help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to enfore execution of some commands.


From: Cristian Zoicas
Subject: how to enfore execution of some commands.
Date: Thu, 18 Dec 2003 10:08:44 +0100 (MET)

Hello all

Problem context
---------------

I have  a makefile called  "Makefile". This makefile  includes another
makefile called "generated.mak" that could be regenerated.

When the  rule commands  generating "generated.mak" are  executed some
messages are printed with echo in the file "build.log".

What do I want to do ?
----------------------

When the main target of the file "Makefile" is invoked I want to print
some  messages   in  the  file   "build.log".

And  these  message  must appear as  the  first  message in  the  file
"build.log"

Solution 1 (the wrong solution)
-------------------------------

The main  target of  the file Makefile.mak  depends on a  phony target
that prints the messages in the file "build.log".

Obviously, this  solution doesn't  work because if  "generated.mak" is
out of  date then  it will  be regenerated before  the main  target is
checked  and   the  messages   generated  during  the   generation  of
"generated.mak"  will appear  before  the messages  printed from  that
phony target.

Solution 2 (is this the correct one ?)
--------------------------------------

To  put the  following statments  in the  file Makefile.mak before the
statment including "generated.mak"


ifneq ($(MAKECMDGOALS),main_target)

include print_start_message

print_start_message:

       echo "Makefile executed at" `date` > build.log

endif

when  "Makefile" will be  executed, it  will try  to include  the file
"print_start_message". This file does not  exist  and make will try to
regenerate it. It  will find a rule to generate it  and this rule will
print some messages  in the file "build.log" but  it will not generate
any makefile "print_start_message".

I would  like to know  if this  can be seen  as a correct  an reliable
(even for the future versions of  GNU make) solution to my problem. Or
are there  any ways  to force  the execution of  a command  before any
other commands are executed ?

Thank you in advance
Cristian Zoicas







reply via email to

[Prev in Thread] Current Thread [Next in Thread]