Subject: Some work on pkgsrc on Darwin
To: None <>
From: Eric Gillespie <>
List: tech-pkg
Date: 02/11/2002 21:09:55
A few weeks ago i got my shiny new iBook and set out to get all the
programs i normally use working on OS X via pkgsrc.  I am now done,
and what an adventure it has been.  You can get the resulting binary
packages at <>.

At <> i have put up all my
diffs and a new package, dlcompat.  I found dlcompat from the Fink
project (, but apparently it originally
comes from Apple.  It's a dlopen wrapper so dynamically loading
modules works on Darwin.

I have also patched to buildlink to dlcompat automatically;
i'm not sure if i got this exactly right, but i think changing all the
packages which need dlopen to do this special thing on Darwin is
probably a mistake.  Similarly, adding -no-cpp-precomp to a bunch of
separate package Makefiles (which i did) is probably not the best
solution.  Putting it in mk.conf didn't seem to help.  (Apple's gcc
pre-compiles headers by default, which doesn't work for some packages,
hence the -no-cpp-precomp option).

The single biggest problem on Darwin is dynamic libraries.  There is a
version of libtool floating around out there (from the Fink people, i
believe; that's where i got it anyway) that produces shared libraries
on Darwin.  I am not a libtool expert, and all my efforts at getting
pkgsrc's libtool to build shared libs on Darwin were met with failure.
Supposedly libtool HEAD contains the patches; i have not verified
this.  pkgsrc's libtool does seem to contain at least some of the
necessary support.  I had to edit to get pkgsrc to
recognize that Darwin can do shared libraries (this is in my diffs),
but that leads to a bigger problem.

The PLIST files refer to ELF so files.  Mach-O dylib files have
drastically different naming conventions.  At first i thought i could
use awk in to translate (as a matter of fact there was some
primitive support for this already) from ELF so to Mach-O dylib and
did so (this is in the diffs i put up).  This worked on the package i
tested it with, but with no other packages.  Here's why:

0 ~% uname -a
NetBSD 1.5.2 NetBSD 1.5.2 ($Id: TRANTOR,v 1.7 2001/11/24 20:48:33 epg Exp $) #3: Sat Nov 24 15:58:07 EST 2001 i386
0 ~% ls /usr/pkg/lib/librep.*
/usr/pkg/lib/librep.a          /usr/pkg/lib/         /usr/pkg/lib/
/usr/pkg/lib/         /usr/pkg/lib/
0 ~% rep --version
rep version 0.15.1

0 ~% uname -a
Darwin 1.4 Darwin Kernel Version 1.4: Sun Sep  9 15:39:59 PDT 2001; root:xnu/xnu-201.obj~1/RELEASE_PPC  Power Macintosh powerpc
0 ~% ls /usr/pkg/lib/librep.*
/usr/pkg/lib/librep.9.2.1.dylib                /usr/pkg/lib/librep.dylib
/usr/pkg/lib/librep.9.dylib                    /usr/pkg/lib/
0 ~% rep --version
rep version 0.15.1

Same version of rep, both built from pkgsrc, yet completely different
shared library file names.  I have no idea how to go about fixing
this.  Just so i could get my software, i hacked each PLIST
individually.  I didn't clutter the diffs on my web site with all that

Things have been rather hellish at work lately with no sign of getting
better, so i haven't looked at this stuff in about a week; it's
possible i've forgotten some of the things i did or learned.  And i
wasn't able to solve a lot of the problems.  But hopefully what i've
done and learned will be useful enough so that someone else can pick
up and make pkgsrc kick ass on pkgsrc.

If i remember anything else i'll be sure to post it here.  Have fun.

Eric Gillespie, Jr. <*>

"When everyone has to reinvent the wheel, many people invent
 square wheels."