Unix Programming - GNU make, how to make make exit the build script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2007 > GNU make, how to make make exit the build script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

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

2007-01-26, 1: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

matevzb

2007-01-26, 1: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
http://www.gnu.org/software/make/ma...Functions.html.
Take a look at the $(error ...) function.
--
WYCIWYG - what you C is what you get

af300wsm@gmail.com

2007-01-26, 7:24 pm



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.

toby

2007-01-27, 7:22 am



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


Hubble

2007-01-28, 1: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

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com