Re: makefile question

2002-12-05 Thread guy keren

On Thu, 5 Dec 2002, Tzafrir Cohen wrote:

 On Thu, 5 Dec 2002, guy keren wrote:
 
 
  Makefiles should not be medled with. if you try to do something
  complicated - most likely you'll fail, cause the language that gmake (and
  the commercial 'make' variants) supports - are very very limited.
 
 A chalange, then, ha?

not realy - gnu make's language realy _is_ very limited. every once in a 
while i try to enhance the Makefile of the project i work on (been using 
gnu make for such things since around 97 - so i thought i should be able 
to do what i want with it) - and eventually fall back to using cut and 
paste, external aliases and scripts and the like - because of the limits 
of its language, and the lack of a proper debugger (or proper error 
messages).

 (reading the gnu-make manual)

so did i yet again before i wrote my previous post ;)

 Well, the best I could find was: target-spesific values
 
  There is one more special feature of target-specific variables: when
   you define a target-specific variable, that variable value is also in
   effect for all prerequisites of this target (unless those prerequisites
   override it with their own target-specific variable value).  So, for
   example, a statement like this:
 
  prog : CFLAGS = -g
  prog : prog.o foo.o bar.o
 
   will set `CFLAGS' to `-g' in the command script for `prog', but it will
   also set `CFLAGS' to `-g' in the command scripts that create `prog.o',
   `foo.o', and `bar.o', and any command scripts which create their
   prerequisites.
 
 So how about:
 
   ppc: ARC=PPC
   ppc: release
 
   release:
   ifeq ($(ARCH),PPC)
 (is that the right syntax?)

tzafrir, if you want a challenge - then _try_ what you write. it does not 
work and will not work, because of a simple reason - the given variable is 
being defined ONLY inside the commands of the rule. this 'ifeq' is NOT 
part of the commands for the rule - since it is a gnu make command. the 
'commands of the rule', as i perceive the term now, are only the _shell_ 
commands of the rule.

 The problem is that 'release' has to be a pre-requirement of ppc.

the problem is - this does not work as you think it does ;)

 But then-again, recursive makes are not much nicer.

but at least they can be understood, and they do work.

--
guy

For world domination - press 1,
 or dial 0, and please hold, for the creator. -- nob o. dy


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




makefile question

2002-12-04 Thread Michael Sternberg

I would like to set up a taget in a makefile that will only define
some variable, and it will be used in the next target, something
like this:

ppc :
ARCH = PPC

release:
ifeq ($(ARCH),PPC)
echo start ppc compiler with ppc flags
else
echo do something else
endif

And I would like to start make with make ppc release.
Tried to dig in make's info, only thing I found
appropriate is Target-specific Variable Values.
I tried as suggested:

ppc : ARCH = PPC
:

release :
ifeq ($(ARCH),PPC)
echo start ppc compiler with ppc flags
else
echo do something else
endif

It gives me *** commands commence before first target.  Stop.

make version is 3.79.1 GNU Make, i386 platform.

Thanks for help, Michael.


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: makefile question

2002-12-04 Thread Oleg Goldshmidt
Michael Sternberg [EMAIL PROTECTED] writes:

 I would like to set up a taget in a makefile that will only define
 some variable, and it will be used in the next target, 

Use recursive make:

ppc:
$(MAKE) ARCH=PPC

-- 
Oleg Goldshmidt | [EMAIL PROTECTED]

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: makefile question

2002-12-04 Thread Oleg Goldshmidt
Michael Sternberg [EMAIL PROTECTED] writes:

 I run it with make ppc debug and wait to see
 performing debug build for PPC

I misunderstood your question. It's simpler, actually:

make debug ARCH=PPC

will work - what's wrong with that?

-- 
Oleg Goldshmidt | [EMAIL PROTECTED]

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: makefile question

2002-12-04 Thread Michael Sternberg

Oleg Goldshmidt wrote:
 Use recursive make:
 ppc:
   $(MAKE) ARCH=PPC


It does not work.
Here is a simple makefile:

ppc:
@ $(MAKE) ARCH=PPC

debug:
@ echo performing $@ build for $ARCH

release:
@ echo performing $@ build for $ARCH


I run it with make ppc debug and wait to see
performing debug build for PPC

Instead it enters non-stopping loop...


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: makefile question

2002-12-04 Thread guy keren

On Wed, 4 Dec 2002, Michael Sternberg wrote:

 Oleg Goldshmidt wrote:
  Use recursive make:
  ppc:
  $(MAKE) ARCH=PPC
 
 
 It does not work.
 Here is a simple makefile:
 
 ppc:
   @ $(MAKE) ARCH=PPC

obviously, you did not read what oleg wrote - and modified his suggestion. 
the above rule should instead be changed to:

ppc:
@ $(MAKE) ARCH=PPC debug

and the makefile should be invoked using:

make ppc

the other alternative (i forgot who wrote it) would also work (i.e. 
setting the variable on the command line when running make, rather then in 
the makefile).

Makefiles should not be medled with. if you try to do something 
complicated - most likely you'll fail, cause the language that gmake (and 
the commercial 'make' variants) supports - are very very limited.

-- 
guy

For world domination - press 1,
 or dial 0, and please hold, for the creator. -- nob o. dy


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: makefile question

2002-12-04 Thread Tzafrir Cohen
On Thu, 5 Dec 2002, guy keren wrote:


 Makefiles should not be medled with. if you try to do something
 complicated - most likely you'll fail, cause the language that gmake (and
 the commercial 'make' variants) supports - are very very limited.

A chalange, then, ha?

(reading the gnu-make manual)

Well, the best I could find was: target-spesific values

 There is one more special feature of target-specific variables: when
  you define a target-specific variable, that variable value is also in
  effect for all prerequisites of this target (unless those prerequisites
  override it with their own target-specific variable value).  So, for
  example, a statement like this:

 prog : CFLAGS = -g
 prog : prog.o foo.o bar.o

  will set `CFLAGS' to `-g' in the command script for `prog', but it will
  also set `CFLAGS' to `-g' in the command scripts that create `prog.o',
  `foo.o', and `bar.o', and any command scripts which create their
  prerequisites.

So how about:

  ppc: ARC=PPC
  ppc: release

  release:
ifeq ($(ARCH),PPC)
(is that the right syntax?)

The problem is that 'release' has to be a pre-requirement of ppc.

But then-again, recursive makes are not much nicer.

Another minor problem is that this is surely gnu-make specific.

(OTOH, makefiles are indeed confusing and difficult to debug)

-- 
Tzafrir Cohen
mailto:[EMAIL PROTECTED]
http://www.technion.ac.il/~tzafrir


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




Re: makefile question

2002-12-04 Thread Oleg Goldshmidt
guy keren [EMAIL PROTECTED] writes:

 On Wed, 4 Dec 2002, Michael Sternberg wrote:
 
  Oleg Goldshmidt wrote:
   Use recursive make:
   ppc:
 $(MAKE) ARCH=PPC
  
  
  It does not work.
  Here is a simple makefile:
  
  ppc:
  @ $(MAKE) ARCH=PPC
 
 obviously, you did not read what oleg wrote - and modified his suggestion. 
 the above rule should instead be changed to:
 
 ppc:
   @ $(MAKE) ARCH=PPC debug
 
 and the makefile should be invoked using:
 
 make ppc

That will work, but I think the OP actually wanted to choose the
real target to build, so hardwiring debug into the makefile is not
what works for him.

There is nothing wrong with setting the architecture on the command
line for any real target, as I suggested in my other posting.

 the other alternative (i forgot who wrote it) 

Me too ;-)

 would also work (i.e. setting the variable on the command line when
 running make, rather then in the makefile).

-- 
Oleg Goldshmidt | [EMAIL PROTECTED]

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]