# Makefile Capitalize Variable



## tuaris (Apr 13, 2014)

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:

```
PORTNAME=	testprogram
```

So I can use that as a variable:

```
${INSTALL} ${FILESDIR}/Testprogram.conf.sample ${STAGEDIR}${PREFIX}/etc/Testprogram.conf.sample
```


----------



## wblock@ (Apr 13, 2014)

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?


----------



## tuaris (Apr 14, 2014)

That was a bad example.  Consider this perhaps:

Taking a template ".desktop" file for use with the port:

```
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.


----------



## wblock@ (Apr 14, 2014)

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.


----------



## ljboiler (Apr 14, 2014)

Perhaps something like this?

```
PORTNAME=       hello
PORTNAME_CAP=`echo ${PORTNAME:C/^(.).*/\1/} | tr [:lower:] [:upper:]`${PORTNAME:C/^.//}
.BEGIN:
        @echo ${PORTNAME_CAP}

all:
```


----------

