[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Testing integers in a Makefile?
From: |
Der Herr Hofrat |
Subject: |
Re: Testing integers in a Makefile? |
Date: |
Tue, 8 Mar 2005 18:49:40 +0100 (CET) |
> Hi all,
>
> Sorry to post this but I've spent a long time looking for information to
> solve my problem and still haven't found anything...
>
> What I'd like to do is add some definitions to my DEFS variable depending on
> the value of _HARDWARE_REVISION (which is an integer).
>
> My Makefile looks like this:
> DEFS=-D_HARDWARE_REVISION=005 -D_...
> ...
> COMPILE=$(TOOLDIR)/arm-elf-gcc -c -O2 -mcpu=arm7tdmi $(DEFS) -o
> "$(OUTDIR)/$(*F).o" "$<" -Wall
>
> I'd like to write something like:
> $(if ($(_HARDWARE_REVISION) > 005),DEFS+=-D_ADD_THIS,DEFS+=-D_ADD_THAT)
> but I cannot find the right syntax for doing this...
>
make only knows about character strings - so you must use some external
program to do the comparison you could use shell - something like:
_HARDWARE_REVISION=12
eval = $(shell if [ $(1) -gt $(2) ] ; then echo gt ; else echo lt ; fi)
ifeq ($(call eval,$(VER),5),gt)
DEFS+=-D_ADD_THIS
else
DEFS+=-D_ADD_THAT
endif
show:
@echo $(DEFS)