Thu, 07 Aug 2008

Stupid make.conf Tricks.

No, I'm not dead. I was on vacation last week for my honeymoon and a friends wedding in Hawaii. I'm back now and trying to get my life back on track, but I'm not sure how well that will work since I'm moving to North Carolina in a month or so. I figured I would get back into the swing of things by posting a question I was recently asked and then give you my solution to it. It's a simple one to start things off again.

I was asked how you would go about removing a specific CFLAGS setting for a specific port. This is slightly different from the more common case: setting specific CFLAGS. The more common case is solved with:

.if ${.CURDIR:M*/foo/bar}
CFLAGS=baz
.endif

That is only one way to do it. There are others including things like portconf. The answer to the question I was asked is:

wxs@ack /usr/ports/devel/git % cat /etc/make.conf
x="foo bar baz"
.if ${.CURDIR:M*/devel/git}
x:=${x:C/bar //}
.endif
wxs@ack /usr/ports/devel/git % make -V x
"foo baz"
wxs@ack /usr/ports/devel/git %

I also have another answer, which I think is a cleaner solution (it's not the same as the one above but it illustrates the point):

wxs@ack ~ % cat Makefile
a=foo bar baz

all:
	@echo ${a:Nbar}
wxs@ack ~ % make
foo baz
wxs@ack ~ %

posted at: 21:02 | tags: , | path: /entries/geek | permanent link to this entry