help-make
[Top][All Lists]
Advanced

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

Writing Function in Makefile


From: Ajay Jain
Subject: Writing Function in Makefile
Date: Tue, 27 Dec 2011 13:03:49 +0530

Hello,

I need to do an operation repeatedly in various Makefiles and therefore
want to make a function that I can call:

Contents of the function:
-----------------------------------

ifeq ($(LOG_LEVEL),LOG_LEVEL_PANIC)
  CFLAGS += -DLOG_LEVEL=1
else ifeq ($(LOG_LEVEL),LOG_LEVEL_ERR)
 CFLAGS += -DLOG_LEVEL=2
else ifeq ($(LOG_LEVEL),LOG_LEVEL_WARN)
 CFLAGS += -DLOG_LEVEL=3
else ifeq ($(LOG_LEVEL),LOG_LEVEL_INFO)
 CFLAGS += -DLOG_LEVEL=4
else ifeq ($(LOG_LEVEL),LOG_LEVEL_DBG)
 CFLAGS += -DLOG_LEVEL=5
else ifeq ($(LOG_LEVEL),LOG_LEVEL_NONE)
 CFLAGS += -DLOG_LEVEL=6
else
 $(error INCORRECT LOG_LEVEL = $(LOG_LEVEL))
endif


Invoke the function:
----------------------------
$(call convert_logstring_to_num,$(LOG_LEVEL))

where LOG_LEVEL = LOG_LEVEL_INFO (for example).

Can I do this in my Makefile inside a function so that I can call it at
multiple places? If yes, any suggestion? The usage of eval and call seems
to be too tricky ..

Thanks.


reply via email to

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