Subject: Re: pthread + pkgsrc proposal
To: Johnny C. Lam <jlam@buildlink.org>
From: Greg A. Woods <woods@weird.com>
List: tech-pkg
Date: 11/25/2004 17:04:45
[ On Wednesday, November 24, 2004 at 17:48:55 (-0500), Johnny C. Lam wrote: ]
> Subject: Re: pthread + pkgsrc proposal
>
> Greg A. Woods wrote:
> > [ On Wednesday, November 24, 2004 at 07:01:37 (+0000), Johnny C. Lam wrote: ]
> > 
> > >Subject: pthread + pkgsrc proposal
> > >
> > >_DLOPEN_REQUIRE_PTHREADS?=	no
> > >.if exists(/usr/include/pthread.h) && \
> > 
> > This kind of thing is _very_ incredibly bad practice.
> > 
> > Surely there's a better way.
> 
> Why don't you find it and get back to me.

Ask a NetBSD pthreads expert for the right answer but in the mean time
it would at least be better to do something like this:

.if ${OPSYS} == "NetBSD"

# Note that __NetBSD_Version__ is only in 1.3.3 and -current >= 1.3C
#
NETBSD_VERSION != grep __NetBSD_Version__ /usr/include/sys/param.h | \
			awk 'BEGIN{v=0} $$1 == "\#define" {v=$$3} END{print v}'

# XXX of course you should use whatever value is correct here....
#
. if ${NETBSD_VERSION} < 106xx0000
_DLOPEN_REQUIRE_PTHREADS =	yes
. endif

.endif


>  Otherwise, this is a 
> reasonable first cut.

No, it is not.

There are too many of these realy bad hacks already hardening themselves
into place in pkgsrc and they're increasingly more difficult to get rid
of.

Never use the plain existance of a filename as the sole means to detect
a system feature, and especially never do so when it's really only the
_location_ of a common filename that's your sole trigger.  I know you
don't like the idea of LOCALBASE=/usr, but please do consider that
anyone and everyone using that allowable feature will be tripped up by
your bad hack (and all the other similar existing ones in pkgsrc)!

The best "first cut" is a "correct cut"

I.e. measure twice, cut once.

Bad hacks just don't "cut it" at all.  :-)

-- 
						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>