Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performing greater-than less-than calculations in a Makefile

Tags:

makefile

I'm trying to do this in a Makefile:

value = 2.0

if ${greaterthan ${value}, 1.50}
-> execute a rule
elseif ${lessthan ${value}, 0.50}
-> execute a rule
endif

It seems like quite a common thing to want to do. What's the best way of doing this?

like image 254
Dan Avatar asked Aug 09 '10 16:08

Dan


People also ask

What does += mean in Makefile?

+= is used for appending more text to variables e.g. objects=main.o foo.o bar.o. objects+=new.o. which will set objects to 'main.o foo.o bar.o new.o' = is for recursively expanded variable.

What is $$ in Makefile?

$$ means be interpreted as a $ by the shell. the $(UNZIP_PATH) gets expanded by make before being interpreted by the shell.

How do I use IFEQ in Makefile?

The ifeq directive begins the conditional, and specifies the condition. It contains two arguments, separated by a comma and surrounded by parentheses. Variable substitution is performed on both arguments and then they are compared.

How do I link my Makefile to .a files?

$(CC) $(CFLAGS) -I$(LIB_PATH) -L$(LIB_PATH) -o $(PROGRAM) main. c -l$(LIB) `pkg-config ...` Basically, you need set the include path to the . h file with -I, then -L for the lib path and -l to set the lib name.


1 Answers

Try this

In this example VER is checked for greater than 4

ifeq ($(shell test $(VER) -gt 4; echo $$?),0)
  IFLAGS += -I$(TOPDIR)/include
  LIBS += -L$(TOPDIR)/libs -lpcap
endif
like image 199
manpatha Avatar answered Sep 23 '22 23:09

manpatha