Darwin versions for open-source development

I’m trying to support Intel in 10.4 and PPC in 10.2. I found the following table from Wikipedia very helpful:

Date Darwin release Mac OS X release
March 16, 1999 Darwin 0.1 Mac OS X Server 1.0
April 5, 2000 Darwin 1.0
April 13, 2000 Darwin 1.0.2 Mac OS X DP4
Darwin 1.2.1 Mac OS X public beta
April 13, 2001 Darwin 1.3.1 Mac OS X 10.0 to 10.0.4
October 2, 2001 Darwin 1.4.1 Mac OS X 10.1
Darwin 5.1 Mac OS X 10.1.1
Darwin 5.2 Mac OS X 10.1.2
Darwin 5.3 Mac OS X 10.1.3
Darwin 5.4 Mac OS X 10.1.4
Darwin 5.5 Mac OS X 10.1.5
September 23, 2002 Darwin 6.0.1 Mac OS X 10.2
October 28, 2002 Darwin 6.0.2 Mac OS X 10.2
Darwin 6.1 Mac OS X 10.2.1
Darwin 6.2 Mac OS X 10.2.2
Darwin 6.3 Mac OS X 10.2.3
Darwin 6.4 Mac OS X 10.2.4
Darwin 6.5 Mac OS X 10.2.5
Darwin 6.6 Mac OS X 10.2.6
Darwin 6.7 Mac OS X 10.2.7
Darwin 6.8 Mac OS X 10.2.8
October 24, 2003 Darwin 7.0 Mac OS X 10.3
Darwin 7.1 Mac OS X 10.3.1
Darwin 7.2 Mac OS X 10.3.2
Darwin 7.3 Mac OS X 10.3.3
Darwin 7.4 Mac OS X 10.3.4
Darwin 7.5 Mac OS X 10.3.5
Darwin 7.6 Mac OS X 10.3.6
Darwin 7.7 Mac OS X 10.3.7
Darwin 7.8 Mac OS X 10.3.8
April 15, 2005 Darwin 7.9 Mac OS X 10.3.9
April 29, 2005 Darwin 8.0 Mac OS X 10.4
May 16, 2005 Darwin 8.1 Mac OS X 10.4.1
July 12, 2005 Darwin 8.2 Mac OS X 10.4.2
October 31, 2005 Darwin 8.3 Mac OS X 10.4.3
January 10, 2006 Darwin 8.4 Mac OS X 10.4.4
February 14, 2006 Darwin 8.5 Mac OS X 10.4.5
April 3, 2006 Darwin 8.6 Mac OS X 10.4.6
August 7, 2006 Darwin 8.7 Mac OS X 10.4.7
September 29, 2006 Darwin 8.8 Mac OS X 10.4.8

Keep on vim’ing…

My .vimrc:

:syn on
:set number
set encoding=utf-8

I still use TextWranger if I need to edit 6 files at once. I can’t flip between files as easily in gvim. But at least I have Unicode working now.

The latest word on configure-based Univeral Binaries for MacOS X

After some e-mails on Apple’s Xcode mailing list, I have concluded that my previous advice about how to build configure-based Univeral Binaries for MacOS X was incorrect. All the ones I have build so far have worked fine. However, there is a possibility that some poorly designed autoconf project could set an endian macro based on the architecture passed to the configure script. Basically, while autoconf has the ability to do cross-compilation, almost no one uses that ability. It is completely unable to do Universal Binaries.

The only valid solution is something like the following:
rm -Rf /tmp/ppc
env CFLAGS=”-isysroot /Developer/SDKs/MacOSX10.2.8.sdk -arch ppc” ./configure –prefix=/tmp/ppc
make
make install
rm -Rf /tmp/i386
env CFLAGS=”-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386″ ./configure –prefix=/tmp/i386
make
make install
lipofiles /tmp/ppc /tmp/i386

I just remembered! You don’t want to do that either. Your binaries could very likely have hard-coded paths to /tmp/i386 or /tmp/ppc because the –prefix line says that is where they’ll be installed. What a mess!

Here is a another idea:
Avoid open-source code, if possible. Apple has given us quite a bit already. Learn to use it and write cross-platform wrappers if required.
If you must use an open-source library, configure it to a non-native platform. For example, if you have an Intel machine, do the following:
env CFLAGS=”-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc” ./configure
Then hack up the makefile and add “-arch i386” right after the “-arch ppc”.
Build and test hoping that, if it is going to beak, it will break on your primary test machine.

I apologize in advance if this idea is hopelessly dangerous and stupid. At this point, I’m just confused. I’ve already wasted too much time on it. Building the “official Apple way” has worked for me so far.

What is my IP address?

Pound for pound, I think the Apple Mailing List site may be the most useful site for programmers looking for answers. One would think that something as generic as C code to find local IP addresses on Unix should have tons of examples on the Internet. Well, I couldn’t find them. I did, however, find exactly what I was looking for in this post on the Apple Mailing List site. This isn’t the first time this has happened.

I have seen some scary stuff come out of Apple. But I think the people posting on the mailing lists tend to know what they are talking about.

The answer to my query is a nice little function called getifaddrs.

What? Didn’t that link work? You must not have Bwana installed.

Still using CVS (after all these years)

I’ve finally got my various web sites properly controlled under CVS. They have always been under CVS, but it was always an awkward process. Now, I think I have it right. Dreamhost provides access to CVS, so I’m finally making use of it. My repository lives on my server, along with my web sites (and this blog). I can check out/in files locally to work on them. Then, when they are ready to go live, I can just cd into the approprate site’s directory and do “cvs update”. I’ll still always have an offsite backup, but I won’t have to fiddle with (s)FTP anymore.

The only problem I had was that I don’t want people poking around in my CVS directories. I fixed that my creating a checkout trigger in CVS that copies in a very restrictive .htaccess file into the CVS directory. First of all, I need a good .htaccess file. This should keep everybody out:

Order deny,allow
Deny from All

I added such a file to my CVS repository’s config directory using an entry in the checkoutlist file:

hidecvs.htaccess Could not checkout the hidecvs.htaccess file

Next, I need a shell script to actually copy the .htaccess file.

#!/bin/sh

find . -name CVS -type d -exec cp ~/CVSROOT/hidecvs.htaccess {}/.htaccess ;

This script finds all directories named CVS and copies my configured .htaccess file to each CVS directory it finds. I also had to add this script file to CVS and to the checkoutlist file.

Finally, an entry in the modules file that looks like:

etresoft.com -o ~/CVSROOT/hidecvs.sh etresoft.com

completes the work. I repeat this line for each web site I have. Everything looks fine so far.

The first question someone might ask is “Why not use subversion? It is much better than CVS.” Not so fast. I have tried subversion. I instantly took a dislike to it because of the “branches, tags, trunk” directory structure that one must use. It is ugly and I don’t like that. Of course, you can configure subversion any way you want. You don’t have to use this layout. You also don’t have to integrate subversion deep inside Apache 2.0 using WebDAV. Good luck with that.

CVS suits me just fine. OK, so I can’t move files and maintain history. I’ve used Clearcase since 1997 and never moved a file, so that feature isn’t such a big deal for me. CVS is fast, simple, easy to use, stores my repository data in regular files, and doesn’t hook into other software that doesn’t have anything to do with version control. If I want something fancy, I can always use CVS-NT – it isn’t just for Windows anymore.

Is CVS broken? Clearly it isn’t or people wouldn’t have been able to use it until Subversion came along. I’ve used CVS, Clearcase, Apex, Continuus, Subversion, and VSS. With the notable exception of VSS, they are all reasonably functional. CVS is, by far, the cheapest (being free) and simplest. Subversion is also free but not simple. The others are very expensive and very complicated. Yes, you can do things in Clearcase that you just can’t do in CVS. But I’ve seen those things done. And unless you have a very good team of people to run Clearcase, it isn’t going to work at all. You could get by with less complicated repositories and fewer people with Clearcase using a little inelegance. But then, you would be no better off than with CVS.

More Open Source Fun

I haven’t put wget on my system yet. I saw a note on digg about it. Someone commented on how you can use “-c” to resume previous wget session. I never knew that and had explicity looked for such an option. Hmm… I must have missed it somehow. Someone else posted a note about CocoaWget, yet another program I wanted to write and never had the time to. Wow. Two useful comments on digg in the same day – a record.

In any event, the developer of CocoaWget didn’t say a word about Universal Binary. But it is just a wrapper around wget, so I though it would be a good idea to test out my uconfigure and umake scripts.

First of all, I had to change my old uconfigure to uconfigurelib. If, for some reason, I want to make a Universal Binary application like wget, I don’t want it installed in /Programming/Libraries. So I moved that option into uconfigurelib and took it out of uconfigure. Also, trying to run autoreconf returned errors. I guess libevent is the one that needs upgrading. My uconfigure and umake scripts worked perfectly with wget.

Upon further inspection of CocoaWget, it is a Universal Binary, as is its included wget command line too. All that for naught. Oh well, I got uconfigurelib created and updated uconfigure and learned a bit more about autoconf. And I didn’t waste too much time.

Open Source Universal Binaries

I would like to get Tor running on my Macbook. Unfortunately, the developers haven’t figured out how to build Universal Binaries for MacOS X yet. I’m not waiting for them. I had earlier hacked together an Intel Privoxy, so Tor shouldn’t be too hard.

The Tor configure fails because I don’t have libevent. Libevent looks very interesting. It could be a candidate for my “good” category of OSS. I might want to incorporate libevent into some shareware. I had been just linking all my libraries statically. Now that I have Universal Binaries to worry about, perhaps I should bite the bullet and figure out how to distribute dynamic libraries inside my .app packages. I also don’t want to just install it on my system because I need to test my yet-to-be-developed scheme for distributing dynamic libraries. I think it is a good idea to develop my software in the same environment in which it will be run. Yeah. I’m a wacko. Maybe when all this is done, I’ll fix my hacked-up Privoxy and submit patches to the offical Tor and Privoxy people. They seem to need to help.

Luckily, Apple has a nice technote on how to build Universal Binary configure-based open source software. It would be even nicer if it worked. Apple’s instructions will not create Universal Binary dynamic libraries.

This guy seems to know what he’s talking about. He thinks I need to download new versions of autoconf, automake, and libtool. I’m not a Linux guy so I would prefer not to muck around with my system. I keep looking and find this post. He claims to have gotten it working. He also says you can install autoconf, automake, and libtool in /usr/local. OK, I’ll do that.

I download, configure, and install autoconf, automake, and libtool. No problems.

Next, I go into my libevent directory and run:

autoreconf -fvi

This may not be necessary. See the next post.

Now, in theory, make should forward those “-arch” arguments on to the linker. I’m ready to re-configure. I setup some handy aliases in my bash profile for configuring and building Universal Binaries. You have to modify CFLAGS to specify that you want both the ppc and 386 architectures built. You have to add the new isysroot thingy. Finally, you have to disable the default dependency tracking to handle the new split personality nature of the object files. Here are my aliases:

alias uconfigure="env CFLAGS=\"-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc\" ./configure --prefix=/Programming/Libraries --disable-dependency-tracking"
alias umake="env CFLAGS=\"-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc\" make"

Note that I am going to install any Universal Binaries into /Programming/Libraries. That way, the system won’t see them. The only way they’ll work is if I figure out how to put them inside a .app bundle. (I hope that works or I’ll have to re-do all this.)

This is all similar to Apple’s instructions. Apple also had us munging up the LDFLAGS, turning off optimization, and turning on debug. I had read somewhere (I forget where, hence the need for this blog) that you don’t have to mess with LDFLAGS. Also, I’ll let the makefile handle optiization and debugging.

It all works. I can now build a Universal Binary libevent and Tor. Next, I’ll fix the official Tor and Privoxy packages. That will take more work. Plus I like to run Privoxy all the time. Tor messes with Privoxy’s config file. I need to figure out a way to switch between them. That’s for later.

I can now build Universal Binary dynamic libraries from OSS. I can easily install them into a hidden, but usable location. I’ve learned about libevent. Overall, a productive tangent.

PS: Today is 10-05-2006 and the blog has come in handy. I forgot how to check the executable type of a file. The above link the Apple technote helped, but, for the record, it is:

file