[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Math and GMake
From: |
Ken Smith |
Subject: |
Math and GMake |
Date: |
Fri, 24 Sep 2004 17:08:21 -0400 |
User-agent: |
Mutt/1.5.6i |
Is there a simple way to do math in GMake? I am currently doing
something like this.
# GNUmakefile
os_math = $(shell echo "$(1)" | bc)
os_add = $(call os_math,$(1)+$(2))
ge = $(shell [[ "$(1)" -ge "$(2)" ]] && echo t)
range = $(if $(call ge,$(strip $(2)),$(strip $(1))),$(call range,$(call
os_add,$(1),1),$(2),$(3) $(1)),$(strip $(3)))
VAR=$(call range,1,10)
all:
@echo VAR=$(VAR)
# end GNUmakefile
An strace of gmake running on the above example shows how painfully slow
this code will make a build which uses it at all. (How many times will
os_add fork? Yikes.) I would like to know if the above can be done
using only GMake primitives? Maybe? Please?
I'll also appreciate hearing any other suggestions or optimizations.
Can any clever mailgroup participant think of a nonrecursive way to
write the range function?
Thanks,
Ken
ps. I'd love to beta test Guile support.
- Math and GMake,
Ken Smith <=
- Re: Math and GMake, Tzafrir Cohen, 2004/09/25
- Re: Math and GMake, Noel Yap, 2004/09/26
- Re: Math and GMake, Ken Smith, 2004/09/27
- Re: Math and GMake, Tzafrir Cohen, 2004/09/27
- Re: Math and GMake, Ken Smith, 2004/09/27
- Re: Math and GMake, Noel Yap, 2004/09/27
- Re: Math and GMake, Ken Smith, 2004/09/27
- Re: Math and GMake, Noel Yap, 2004/09/27
- Re: Math and GMake, Ken Smith, 2004/09/27
- Re: Math and GMake, Tzafrir Cohen, 2004/09/27