EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Doing simple in math MAKEFILE

Started by fl429 February 22, 2007
I am customizing my makefile for use with the latest GNUARM C package.
Is it possible to evaluate a simple mathamatic expression like this:

....

UND_STACK_SIZE = 4
FIQ_STACK_SIZE = 0x100

# this does not work because it does substitutions.
STACK_SIZE = $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE)

How do I ask make to evaluate mathamatically instead of symbolically ?

Any advice ?

Thanks
Greg

An Engineer's Guide to the LPC2100 Series

I don't know what compiler you are using, but GNU linker can
generate symbols based on simple maths.

So you could generate a global symbol STACK_SIZE from there - at
least that is what I do.....

j.
--- In l..., "fl429" wrote:
>
> I am customizing my makefile for use with the latest GNUARM C
package.
> Is it possible to evaluate a simple mathamatic expression like
this:
>
> ....
>
> UND_STACK_SIZE = 4
> FIQ_STACK_SIZE = 0x100
>
> # this does not work because it does substitutions.
> STACK_SIZE = $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE)
>
> How do I ask make to evaluate mathamatically instead of
symbolically ?
>
> Any advice ?
>
> Thanks
> Greg
>
I am using the GNUARM.
I am trying to make the link script independent of any specific
project, where adjustment of the sizes of stacks is necessary
depending on applications. Therefore I am trying to move the stack
sizing part to the makefile and pass the total size into the link
script for layout.

Thanks

Greg
--- In l..., "Jason Morgan"
wrote:
>
> I don't know what compiler you are using, but GNU linker can
> generate symbols based on simple maths.
>
> So you could generate a global symbol STACK_SIZE from there - at
> least that is what I do.....
>
> j.
> --- In l..., "fl429" wrote:
> >
> > I am customizing my makefile for use with the latest GNUARM C
> package.
> > Is it possible to evaluate a simple mathamatic expression like
> this:
> >
> > ....
> >
> > UND_STACK_SIZE = 4
> > FIQ_STACK_SIZE = 0x100
> >
> > # this does not work because it does substitutions.
> > STACK_SIZE = $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE)
> >
> > How do I ask make to evaluate mathamatically instead of
> symbolically ?
> >
> > Any advice ?
> >
> > Thanks
> > Greg
>
IMO trying to make things that predict their use in the future just
forces you into a corner later, but anyway...

I don't think MAKE itself can do anything more than simple text
processing and calling external programs.

But you could always use this form of assignment

var := $(shell mycmd x y z)

and let your OS handle it, but you will have then started to box
yourself as your makefile will be os dependent.

e.g. in 2000/XP

------------------

UND_STACK_SIZE = 4
FIQ_STACK_SIZE = 0x100

var := $(shell cmd /c SET /A $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE))

all:;echo $(var)

---------------

Regards,
Jason.

--- In l..., "fl429" wrote:
>
> I am using the GNUARM.
> I am trying to make the link script independent of any specific
> project, where adjustment of the sizes of stacks is necessary
> depending on applications. Therefore I am trying to move the stack
> sizing part to the makefile and pass the total size into the link
> script for layout.
>
> Thanks
>
> Greg
> --- In l..., "Jason Morgan"
> wrote:
> >
> > I don't know what compiler you are using, but GNU linker can
> > generate symbols based on simple maths.
> >
> > So you could generate a global symbol STACK_SIZE from there - at
> > least that is what I do.....
> >
> > j.
> >
> >
> > --- In l..., "fl429" wrote:
> > >
> > > I am customizing my makefile for use with the latest GNUARM C
> > package.
> > > Is it possible to evaluate a simple mathamatic expression like
> > this:
> > >
> > > ....
> > >
> > > UND_STACK_SIZE = 4
> > > FIQ_STACK_SIZE = 0x100
> > >
> > > # this does not work because it does substitutions.
> > > STACK_SIZE = $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE)
> > >
> > > How do I ask make to evaluate mathamatically instead of
> > symbolically ?
> > >
> > > Any advice ?
> > >
> > > Thanks
> > > Greg
> > >
>
Thank you very much! It works.

Greg

--- In l..., "Jason Morgan"
wrote:
>
> IMO trying to make things that predict their use in the future just
> forces you into a corner later, but anyway...
>
> I don't think MAKE itself can do anything more than simple text
> processing and calling external programs.
>
> But you could always use this form of assignment
>
> var := $(shell mycmd x y z)
>
> and let your OS handle it, but you will have then started to box
> yourself as your makefile will be os dependent.
>
> e.g. in 2000/XP
>
> ------------------
>
> UND_STACK_SIZE = 4
> FIQ_STACK_SIZE = 0x100
>
> var := $(shell cmd /c SET /A $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE))
>
> all:;echo $(var)
>
> ---------------
>
> Regards,
> Jason.
>
>
> --- In l..., "fl429" wrote:
> >
> > I am using the GNUARM.
> > I am trying to make the link script independent of any specific
> > project, where adjustment of the sizes of stacks is necessary
> > depending on applications. Therefore I am trying to move the
stack
> > sizing part to the makefile and pass the total size into the link
> > script for layout.
> >
> > Thanks
> >
> > Greg
> >
> >
> > --- In l..., "Jason Morgan"
> > wrote:
> > >
> > > I don't know what compiler you are using, but GNU linker can
> > > generate symbols based on simple maths.
> > >
> > > So you could generate a global symbol STACK_SIZE from there -
at
> > > least that is what I do.....
> > >
> > > j.
> > >
> > >
> > > --- In l..., "fl429" wrote:
> > > >
> > > > I am customizing my makefile for use with the latest GNUARM C
> > > package.
> > > > Is it possible to evaluate a simple mathamatic expression
like
> > > this:
> > > >
> > > > ....
> > > >
> > > > UND_STACK_SIZE = 4
> > > > FIQ_STACK_SIZE = 0x100
> > > >
> > > > # this does not work because it does substitutions.
> > > > STACK_SIZE = $(UND_STACK_SIZE) + $(FIQ_STACK_SIZE)
> > > >
> > > > How do I ask make to evaluate mathamatically instead of
> > > symbolically ?
> > > >
> > > > Any advice ?
> > > >
> > > > Thanks
> > > > Greg
> > > >
> > >
>

Memfault Beyond the Launch