Makefile Capitalize Variable

What is the preferred way to capitalize the first letter of a variables value in the port's Makefile. For example:

I want the port name's first letter capitalized:
Code:
PORTNAME=	testprogram

So I can use that as a variable:
Code:
${INSTALL} ${FILESDIR}/Testprogram.conf.sample ${STAGEDIR}${PREFIX}/etc/Testprogram.conf.sample
 
It should match the name of the program, but I'm not aware of any strict rules on it.

As far as preferred, why not make the filename all lower case and easier for the user to type?
 
That was a bad example. Consider this perhaps:

Taking a template ".desktop" file for use with the port:
Code:
PORTNAME=   testprogram

${REINPLACE_CMD} -e 's,=/usr,=${PREFIX},' \
     -e 's,sample,${PORTNAME},g' \
     -e 's,Sample,Testprogram,g' \
     -e 's,128,256,g' ${WRKSRC}/templates/desktop/${PORTNAME}-qt.desktop

Sure, I could just leave it hard coded, but I'd like to know if I can avoid doing so.
 
You to use on ${PORTNAME} in the third replacement? Not that I know of, but the people on the freebsd-ports mailing list might. It may work better to just create static .desktop files with the correct names and contents, or to loop through a list of properly-capitalized names.
 
Perhaps something like this?
Code:
PORTNAME=       hello
PORTNAME_CAP=`echo ${PORTNAME:C/^(.).*/\1/} | tr [:lower:] [:upper:]`${PORTNAME:C/^.//}
.BEGIN:
        @echo ${PORTNAME_CAP}

all:
 
Code:
PORTNAME=         hello
PORTNAME_CAP=     ${PORTNAME:C/^(.).*/\1/:tu}${PORTNAME:C/^.//}

$ make -V PORTNAME_CAP -V PORTNAME
Hello
hello
 
Back
Top