GNU make, how to make make exit the build script
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > GNU make, how to make make exit the build script




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    GNU make, how to make make exit the build script  
af300wsm@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-26-07 06:18 PM

Hi,

I'm having some difficulty finding what I'm looking for on the GNU
documentation site.  Basically, I want to have make exit if a
particular condition is true.  Actually, because there are a few
different compilers installed on the system, I need to make sure the
correct one has been selected and if not, to exit the script and warn
the user.  Something like:

ifeq (${GCC}, "/usr/bin/gcc")
echo "you must configure for compiler XXXXXX"
exit
endif

I can't find an exit command (at least not yet) and I was wondering if
this is possible.  What would the command/directive be?

(NOTE because of how the environment is, it's not trivial to configure
for the right compiler.  Therefore, I want the users to configure
before they call make.)

Thanks,
Andy






[ Post a follow-up to this message ]



    Re: GNU make, how to make make exit the build script  
matevzb


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-26-07 06:18 PM

On Jan 26, 4:37 pm, af300...@gmail.com wrote:
> Hi,
>
> I'm having some difficulty finding what I'm looking for on the GNU
> documentation site.  Basically, I want to have make exit if a
> particular condition is true.  Actually, because there are a few
> different compilers installed on the system, I need to make sure the
> correct one has been selected and if not, to exit the script and warn
> the user.  Something like:
>
> ifeq (${GCC}, "/usr/bin/gcc")
>             echo "you must configure for compiler XXXXXX"
>             exit
> endif
>
> I can't find an exit command (at least not yet) and I was wondering if
> this is possible.  What would the command/directive be?
>
> (NOTE because of how the environment is, it's not trivial to configure
> for the right compiler.  Therefore, I want the users to configure
> before they call make.)
Make control functions are described at
[url]http://www.gnu.org/software/make/manual/html_node/Make-Control-Functions.html.[/ur
l]
Take a look at the $(error ...) function.
--
WYCIWYG - what you C is what you get






[ Post a follow-up to this message ]



    Re: GNU make, how to make make exit the build script  
af300wsm@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-07 12:24 AM



On Jan 26, 10:44 am, "matevzb" <mate...@gmail.com> wrote:
> On Jan 26, 4:37 pm, af300...@gmail.com wrote:
> 
> 
> 
> 
> 
> Take a look at the $(error ...) function.
> --
> WYCIWYG - what you C is what you get

Thanks.






[ Post a follow-up to this message ]



    Re: GNU make, how to make make exit the build script  
toby


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-07 12:22 PM



On Jan 26, 1:37 pm, af300...@gmail.com wrote:
> Hi,
>
> I'm having some difficulty finding what I'm looking for on the GNU
> documentation site.  Basically, I want to have make exit if a
> particular condition is true.  Actually, because there are a few
> different compilers installed on the system, I need to make sure the
> correct one has been selected

Why not just select it directly then?

CC=/name/your/gcc
or
CXX=/name/your/g++

> and if not, to exit the script and warn
> the user.  Something like:
>
> ifeq (${GCC}, "/usr/bin/gcc")
>             echo "you must configure for compiler XXXXXX"
>             exit
> endif
>
> I can't find an exit command (at least not yet) and I was wondering if
> this is possible.  What would the command/directive be?
>
> (NOTE because of how the environment is, it's not trivial to configure
> for the right compiler.  Therefore, I want the users to configure
> before they call make.)
>
> Thanks,
> Andy






[ Post a follow-up to this message ]



    Re: GNU make, how to make make exit the build script  
Hubble


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-28-07 06:27 AM



On 26 Jan., 16:37, af300...@gmail.com wrote:
> Hi,
>
> I'm having some difficulty finding what I'm looking for on the GNU
> documentation site.  Basically, I want to have make exit if a
> particular condition is true.  Actually, because there are a few
> different compilers installed on the system, I need to make sure the
> correct one has been selected and if not, to exit the script and warn
> the user.  Something like:
>
> ifeq (${GCC}, "/usr/bin/gcc")
>             echo "you must configure for compiler XXXXXX"
>             exit
> endif
>
> I can't find an exit command (at least not yet) and I was wondering if
> this is possible.  What would the command/directive be?
>
> (NOTE because of how the environment is, it's not trivial to configure
> for the right compiler.  Therefore, I want the users to configure
> before they call make.)

Make exits on a false conditio. So an action like "false" will stop
make.
You can also use exit 1 (but not exit, which is exit 0, which is
true").

Knowing this you can create test actions:
- file exits:
test -f <filename>
..
(but check if you should put filename in a prerequisite

- file_does_not_exist:
[ !  -f <filename> ]
..

... exit if a particular conditions is true
condition ; [ $$? = 0 ]

If you want to output something on error, you can do

[ ! -f .lock ] || ( echo file .lock must not exist >&2 :
exit 1 ; }

Hubble






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:03 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register