Subject: Re: Dealing with Linux-only functions in a package
To: None <pkgsrc-users@NetBSD.org>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: pkgsrc-users
Date: 10/20/2006 16:25:24
On Fri, 20 Oct 2006 21:15:53 +0200, Christian Biere
<christianbiere@gmx.de> wrote:

> Steven M. Bellovin wrote:
> > I'm trying to put together a package for memtest86+.  One routine uses the
> > inb_p, outb_p, and outb functions that it gets from <sys/io.h> on Linux.
> > The question is what to do when compiling on NetBSD.
> 
> Have you asked the original developers? I think the fix is obvious:
> Add a compile-time check for the header file and the functions. If
> they are not available use GCC's inline assembler. Those functions
> should be one-liners and map directly to x86 assembler instructions.

How is that best done in the pkgsrc framework?  Right now, I have a
patch-ab file, which is applied unconditionally.  There's no autoconfig
framework to do that.  I could, I suppose, patch the offending file to use
some local #include file, and write a post-patch target that checked
for /usr/include/sys/io.h and used either that or the inline copy.
> 
> > OTOH, it seems unclean to do a source copy, since if the
> > package is compiled on a Linux box the original version works just fine.
> 
> I'd say there's nothing which guarantees that anything from sys/io.h
> or any other header file works without the OS being loaded. So in my
> opinion, always including the code is the cleaner solution.
> 
Well, yes, but I didn't write the original code that made that
assumption...

Anyway, that's certainly the easiest way to proceed as well; if people
don't think there's a problem with it, I'll leave it alone.  It avoids the
crazy scripts I talked about above.

		--Steven M. Bellovin, http://www.cs.columbia.edu/~smb