Reviving a Unix Favorite – xv on PowerMac G5

xv Splash Screen

During my early 1990s employment in the engineering field, managers used Macs, engineers used Unix workstations and everyone else muddled along on IBM 3270 mainframe terminals. Engineering managers such as myself got the combined set: a Unix workstation for technical work, a Mac for administrative work and often an IBM mainframe terminal as well. It led to a crowded desk, but it was massively functional for the time.

It was at that time that I first ran across an early Unix graphics program called xv. xv was (and still is) an X-Windows based image viewer and editor. For quite some time, it was the JPEGView of the Unix world – the golden standard for image viewers. If you wanted to view an image, you viewed it with xv. It was that simple.

xvlogo

The xv story did not end in those now distant times however. xv successfully made the transition to Linux and carried on. While no longer being actively developed, this venerable image viewer and editor continues to be very useful. As a long time Linux user, I always made sure to load xv as part of the program set I deployed with any new Linux distribution I was installing at the time.

Of course, ultimately I moved from Linux to Mac OS X back in 2006, and xv slowly faded from my consciousness. A few weeks ago however, I accidentally stumbled across a reference to it running under Mac OS X Tiger, and intrigued by this thought, I tracked the lead down. It turns out that an xv enthusiast had put together a web page with instructions for how to compile xv from its source code and get it running on an Intel Mac. The instructions were for 10.4.11 Tiger and an Intel Mac, but I reasoned that if the steps outlined resulted in a clean compile and build on an Intel Mac, it should do likewise on a PowerPC Mac. Tiger is Tiger after all!

I tried this out this weekend and I am pleased to report that it worked like a charm. xv is now once again resident on my computer (a PowerMac G5) and is once again a valuable addition to my image viewing and editing arsenal.

Building xv from its source code is not nearly as scary as it might sound to anyone who has not done this before. Here is what you will need to get started:

> XCode (Apple’s C compilers, development tools and so on)

> X11 (the X-Windows implementation for Tiger)

Both of these are available on your Mac OS X Tiger install disks, typically on the second disk as I recall.

OK, with these two installed, here is the step-by-step recipe for building xv from source, based on the instructions I found at at http://anoved.net/software/xv, which I followed slavishly (and successfully!).

Step 1 – Get the Source, Place it in /usr/local/src

Download the source code package from http://anoved.net/software/xv. The file you will get is “xv-3.10a.tar.gz”. Double click this file and Finder will expand it into a folder called xv-3.10a (or something very similar).

Start Terminal.app (located in your Utilities folder) and you will be presented with a terminal window. Change to your /usr/local directory with this command:

cd /usr/local

Check the contents of this directory via the “ls” command. If there is not a “src” subdirectory, create it via the next two commands:

sudo mkdir src
sudo chmod +rwx src

Note that both of the above commands will ask for your usual admin password.

Now move the xv source package to the newly created “src” folder:

mv ~/Desktop/xv-3.10a src

Alternately, you can use Finder and drag and drop, achieving the same result.

The above assumes that you downloaded the xv source package to your Desktop. If you downloaded it to some other location, it might be simplest to use Finder to move it to your desktop before executing the above step.

Step 2 – Modify the Source for the Mac Environment

Next, there are four small changes you will need to make to the source code to set xv up for life on a Mac vs. on its original Unix/Linux. You can make these changes in your text editor of choice. I used vi, but you can use whatever you like.

Change to the xv src directory:

cd src/xv-3.10a

Check for the presence of the gunzip utility:

which gunzip

If this comes back with a file path (vs. a message saying that you have no gunzip on your system), you have gunzip, and should make the following change to file “config.h”:

Source File Change 1: Edit the config.h File:

Change ‘undef’ to ‘define’ in line 16, such that it reads:

#define USE_GUNZIP

Then change line 22 so that it reads:

#   define GUNZIP “/usr/bin/gunzip -q”

or to whatever file path matches what was returned by the ‘which gunzip’ above. Note that the path is originally set to /usr/local/bin/gunzip.

Save your changed file and move on to the next step…

Source File Change 2: Edit the xv.h File:

Comment out line 119 so that it reads:

/* extern char *sys_errlist[];   */

Adjust the path included in line 167 so that it reads:

#   include <malloc/malloc.h>

Save these changes and move and move on to the next step…

Source File Change 3: Edit the vdcomp.c File:

Adjust the path included in line 116 so that it reads:

#   include <malloc/malloc.h>

Save these changes and move to the last step…

Source File Change 4: Edit the Makefile File:

Edit the CCOPTS definition at or near line 16 so that it reads:

CCOPTS = -O -L/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib

OK, you’ve made it! That is the hard part done. You have now accomplished all the source level changes that are needed. All that is left now is to do the actual build and install. This part is really quite easy.

Step 3 – Build and Install

Issue the following two commands:

make

(you will see lots and lots of compile commands and a few warnings go by, but everything works out successfully)

sudo make install

(you will see quite a number of copy commands go by, all successfully)

You are done! If you now look in /usr/local/bin, you will find the xv executable there, ready to rock and roll! Here is what it looks like in action, first after being started, and then, displaying an image:

xv on Desktop

xv Displaying an Image

For the most part, Mac users prefer all their applications to be in the Applications folder, rather than in an obscure folder like /usr/local/bin. I quite agree with this line of thinking, but being something of a Unix/Linux purist myself, I decided not to move the actual executable, but rather to put an alias to it in my Applications folder. I did this by opening a Finder window on /usr/local/bin and then doing a CMD+OPT+drag of the xv executable to my desktop. This put an xv alias on my desktop and I moved that from there to my Applications folder. A view of a fragment of my Applications folder after the move appears below.

xv in Applications Folder

As you can see above, one last step that I took was to change the icon of the xv executable. xv has a nice icon (below), and I wanted to use it.

xvlogo

If you go to Google Images and query “xv 3.10a icon” you will see a few show up in the returned results and you can grab one from there (or you can just snag the image above!). All of these are image files however, not the requisite .icns file that you need, and so you will need to put them through some form of program to create an icon out of them. My favorite for this sort of thing is Iconverter, which you can get at:

http://www.macupdate.com/app/mac/9477/iconverter

That’s it! You now have an old Unix favorite running on your Power Mac! The interface is a bit quirky by today’s standards, but remember, it WAS created in the early 1990s. Interface quirkiness quite aside, the program is immensely powerful and if you spend some time with it, my bet is that you will like it.

To really take advantage of xv, I would recommend printing out the full documentation, available in your /usr/local/src/xv-3.10a/docs folder. Look for the file xvdocs.ps and open it in Preview.app. This same document is also available online at:

http://www.trilon.com/xv/manual/xv-3.10a/cover.html

While you are there, check out the home page as well. There is lots of other neat stuff that you might enjoy having a browse through. As an added bonus, the site appears to be maintained by the author of xv himself – John Bradley.

As you read through the documentation, you will be amazed at all the functionality John managed to cram into this innocent looking program. There is even an early file manager, going by the unlikely name of “Visual Schnauzer”!

Comment back – let us know what you think of xv!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s