Building 'xv' on Ubuntu

I have a particular fondness for an ancient image viewer called xv, written by John Bradley and last updated—if you can believe it—in 1996. It’s a little quirky, especially on modern window managers, and doesn’t handle huge image files very well. But it’s extremely fast and offers a wealth of features.

Thanks to a small community of enthusiasts, the 20+ year old code can still be compiled on modern Linux systems. Here’s what I did to get it compiled on Ubuntu.

  1. Install the following development packages:

    • xorg-dev (installed 80 other packages!)
    • libjpeg-dev
    • libtiff-dev
    • libpng-dev
    • libz-dev
  2. Install libjasper-dev from another source (it disappeared from the main Ubuntu 18.04.2 LTS repository, but is still available from 16.04-6 LTS):
      add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"   apt-get update
      apt-get install libjasper-dev

  3. Download the “RPM Fusion” patches from GitHib and unpack them:

    wget -O xv-master.zip https://github.com/rpmfusion/xv/archive/master.zip
    unzip -q xv-master.zip
    
  4. Change to the xv-master directory:

    cd xv-master
    
  5. Download the xv source code from John Bradley’s FTP site and unpack the archive:

    wget ftp://ftp.trilon.com/pub/xv/xv-3.10a.tar.gz
    tar xzf xv-3.10a.tar.gz
    
  6. Download the Jumbo patches from SourceForge and unpack them:

    wget http://downloads.sourceforge.net/png-mng/xv-3.10a-jumbo-patches-20070520.tar.gz 
    tar xzf xv-3.10a-jumbo-patches-20070520.tar.gz
    
  7. Change to the xv-3.10a source directory:

    cd xv-3.10a
    
  8. Run the following script to apply the patches:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    #!/bin/bash
    for PATCH in xv-3.10a-jumbo-fix-enh-patch-20070520.txt \    
        xv-jumbo-20070520-makefile.patch \
        xv-3.10a-enhancements.20070520-20081216.diff \
        xv-3.10a-cleanup.patch     xv-FLmask.v2.1.patch \
        xv-wait.patch              xv-3.10a-libpng15.patch \
        xv-3.10a-namemax.patch     xv-3.10a-xvcut.patch \
        xv-3.10a-format.patch      xv-3.10a-png-itxt.patch \
        xv-3.10a-smooth-fix2.patch xv-3.10a-signal.patch
    do
        echo ">>> Applying patch \"$PATCH\""
        P1="-p1"
        [ "$PATCH" == 'xv-3.10a-libpng15.patch' ] && P1=""
        [ "$PATCH" == 'xv-3.10a-format.patch' ] && P1=""
        [ "$PATCH" == 'xv-3.10a-signal.patch' ] && P1=""
        patch $P1 < ../$PATCH
        echo
    done
    
  9. Apply some additional patches to install to /opt and shorten the version number:

    sed --in-place 's,^PREFIX = .*,PREFIX = /opt/xv-3.10u,; s/^\(LIBS = .*\)/\1 -lXt/' Makefile
    sed --in-place 's/^\(#define VERSTR\).*/\1 "3.10u"/' xv.h
    
  10. Build the program:

    time make 2>&1 | tee build.1.make.text
    
  11. If make was successful, install:

    sudo make install
    sudo mv docs /opt/xv-3.10u/share
    sudo rm -f /opt/xv-3.10u/share/doc/*man   # (They're already in share/man)
    sudo ln -s xv-3.10u /opt/xv
    cd /usr/bin
    for FILE in xv bggen vdcomp xcmap xvpictoppm; do sudo ln -s /opt/xv/bin/$FILE; done