November 7, 2009

Compiling Irssi for Mac OS X 10.6

Filed under:technology — ryan @ 12:04 am

When upgrading from 10.5 to 10.6, I noticed that my laboriously-compiled (okay, okay, I’m being dramatic, but it WAS a pain) irssi broke, due to some funkiness with Perl and 64-bit. Unfortunately, recompiling Irssi for 10.6 proved to be even more of a pain, and I know that I myself will have a hard time with it if I don’t write down exactly what I did here. I’m assuming this’ll be useful for other folks, too.

I’ll try to provide notes and reasoning for each step in the directions below. Keep in mind that you’ll need the developer tools installed (from the ‘Additional Installs’ folder on the Snow Leopard install disc), and that I am NOT using Fink or DarwinPorts (it would be much easier if I did, however I am not a fan of package managers and separate library paths, etc). I also assume that you’re familiar with basic terminal commands (cd, ls, etc) and navigating filesystem paths (mostly to downloaded/untarred folders in your ‘Downloads’ folder).

Ingredients:

(numbers in parenthesis are the latest versions as of the time of this posting)

Irssi (0.8.14)

Glib (2.22.2)

pkg-config (0.23)

Gettext (0.17)

Libiconv (1.13.1)

If you’re using Safari, it should not only place the downloaded tarballs into your Downloads folder (/Users/yourname/Downloads or ~/Downloads), but it should transparently remove the gzip compression, as well. In this case, untar each file so you have a directory of the source code for each. If you’re using Firefox, you may need to unzip, as well, and your files may not be in Downloads.

Directions:

1. Compile and install pkg-config:

(which is a program used to retrieve information about installed libraries)

Open Terminal.app and navigate to the newly-created pkg-config folder. Then, run the following commands in order, after the prior command has completed. If you’ve ever compiled anything from source in the command line before, this may be familiar (and will be, by the time we’re through):

./configure

make

sudo make install (be prepared to provide your password)

2. Compile and install gettext:

(which is a set of tools for multilanguage support in GNU applications)

Navigate to the gettext folder, and follow the same steps as before:

./configure

make

sudo make install

3. Compile and install libiconv:

(which is a text encoding converter, used to convert between various character encodings in international text)

As before, navigate to the libiconv folder in your Downloads folder, and run your favorite three commands, entering your password for the third: ./configure, then make, then sudo make install.

4. Recompile gettext:

Yes. Believe it or not, but libiconv and gettext have circular dependencies and depend upon each other for certain features. While libiconv needed certain features from gettext to compile with crucial functionality enabled, gettext also requires libiconv to be installed in order to enable yet more features. This time, we have to clean out any trace of prior compilation, so we’re going to prefix a command like so:

make distclean

./configure

make

sudo make install

5. Compile and install Glib:

GLib is a core suite of libraries for unix- and or gnome-style applications written in C. This one is a bit bigger than the others, and also requires a bit of source code hacking to get installed. If you haven’t grabbed a snack yet, now’s a good time to, unless you are one of those people with an impeccably-clean keyboard and desk. First, we start the configuration process by navigating to the glib folder and running:

./configure

Once this is complete, we’ll need to replace 3 lines in a certain source file.

From what I understand, apple’s included libiconv doesn’t support 64bit, and I happen to be building a 64bit irssi. So, let’s make the changes below to make sure the libiconv that we’ve built is used. Navigate to the ‘glib’ folder (just plain glib, the one INSIDE of the main glib source folder), and open ‘gconvert.c’ with your favorite editor.

#if defined(USE_LIBICONV_GNU) && !defined (_LIBICONV_H)
#error GNU libiconv in use but included iconv.h not from libiconv
#endif
#if !defined(USE_LIBICONV_GNU) && defined (_LIBICONV_H)
#error GNU libiconv not in use but included iconv.h is from libiconv
#endif

replace the last 3 lines, like so:

#if defined(USE_LIBICONV_GNU) && !defined (_LIBICONV_H)
#error GNU libiconv in use but included iconv.h not from libiconv
#endif
#if !(defined(__APPLE__) && defined(__LP64__)) && !defined(USE_LIBICONV_GNU) && defined (_LIBICONV_H)
#error GNU libiconv not in use but included iconv.h is from libiconv
#endif

Save and close the file in place. Now you’re ready to compile and install glib:

make

sudo make install

6. Compile and install Irssi (finally):

Irssi is a…is he fucking serious? No, I’m not; you know what irssi is or you would not be here. Let’s continue. We’re going to configure irssi with perl support, because perl is the language used for lovely irssi plugins such as dau.pl, which is an irssi script that helps you find and keep friends. I’m kidding, very much so. Anyhow:

./configure –with-perl=yes

Unfortunately, if you tried to compile with this configuration, there would be issues. Linking to Apple’s included perl libraries proves problematic, because compilation tries to create Universal Binaries and for some reason, you’re not allowed to do this, in this case. That’s fine, though – we’re only compiling for our specific machines, here. In my case, I’m creating an x86_64 build, so I’ll need to run the following two commands to strip out any compiler flags to the contrary:

find . -type f -exec sed -i “” -e “s/-arch i386//g” {} \;

find . -type f -exec sed -i “” -e “s/-arch ppc//g” {} \;

If you have a 32 bit Intel (i.e. Core Duo or earlier),or a PPC mac, you’d want to replace the appropriate string in one of those lines with ‘x86_64′. I’ll leave that for you to figure out, but it should be obvious. This is a guide for the preferred 64 bit code path. All we have to do now is proceed with the compilation and install:

make

sudo make install

That’s it! You’re done; open a new terminal and type ‘irssi’ to begin!

zero comments so far »

Please won't you leave a comment, below? It'll put some text here!

Copy link for RSS feed for comments on this post or for TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)