help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with wordlist error: non-numeric first argument to `wordlist' func


From: weebalaji
Subject: Help with wordlist error: non-numeric first argument to `wordlist' function. Stop.
Date: Tue, 24 Jun 2008 14:51:42 -0700 (PDT)
User-agent: G2/1.0

I am trying to divide up a list of years into chunks in GNU make.

If years = 1981 ... 1990 and chunk=5,

'make 1985' should print the list 1981..1985
'make 1990' should print 1986..1990
make any other year returns nothing.

The logic in the file below works fine, except that I seem to unable
to pass the result of a function to the first argument of 'ylist'. If
I edit the 'call ylist' line and type in the correct value for the
first argument (e.g '10' when target is 1990), it works fine.

Any make gurus out there who can help? Thanks,

###### test.mk
years = 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
chunk = 5
start = 1981

modulo = $(shell expr $(1) % $(2))
ysince = $(shell expr $(1) - $(2) + 1)
#1=endyear pos, 2=chunk, 3=years
ylist = $(wordlist $(call ysince,$(1),$(2)),$(1),$(years))

define do_chunk
debug_$(1):
        @echo b=$(call ysince,$(call ysince,$(1),$(start)),$(chunk))
        @echo e=$(call ysince,$(1),$(start)) modulo=$(call modulo,$(call
ysince,$(1),$(start)),$(chunk))
ifeq ($(call modulo, $(call ysince,$(1),$(start)),$(chunk)), 0)
$(1): debug_$(1)
        @echo $(1) ok
        @echo $(call ylist,$(call ysince,$(1),$(start)),$(chunk))
endif
endef

$(foreach year, $(years), $(eval $(call do_chunk,$(year))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]