In GNU Make, how to convert a variable to lower case

makefile

This is a silly question, but…. with GNU Make:

VAR = MixedCaseText
LOWER_VAR = $(VAR,lc)

default:
        @echo $(VAR)
        @echo $(LOWER_VAR)

In the above example, what's the correct syntax for converting VAR's contents to lower case? The syntax shown (and everything else I've run across) result in LOWER_VAR being an empty string.

Best Answer

you can always spawn off tr

LOWER_VAR = `echo $(VAR) | tr A-Z a-z`

or

LOWER_VAR  = $(shell echo $(VAR) | tr A-Z a-z)

The 'lc' functions you trying to call is from GNU Make Standard Library

Assuming that is installed , the proper syntax would be

LOWER_VAR  = $(call lc,$(VAR))