--- xjig-2.4.orig/README
+++ xjig-2.4/README
@@ -13,9 +13,9 @@
 
  Description:
       XJig is a puzzle, that tries to replicate a jigsaw puzzle on the
-      screen as close as possible. Gif-images can be loaded and sliced
-      into pieces and as in every jigsaw puzzle, the goal is to
-      set the parts together again.
+      screen as close as possible. GIFs, JPEGs, and PPMs can be loaded
+      and sliced into pieces and as in every jigsaw puzzle, the goal
+      is to set the parts together again.
 
  Special effects:
       - Tiles are freely rotatable with intuitive pointer movement.
--- xjig-2.4.orig/xjig.man
+++ xjig-2.4/xjig.man
@@ -1,4 +1,4 @@
-.TH xjig 1 "July-23-1996" "X Version 11"
+.TH xjig 6 "July-23-1996" "X Version 11"
 .SH NAME
 xjig \- the jigsaw puzzle
 .SH SYNOPSIS
@@ -11,8 +11,9 @@
 pieces together. If you like, you can watch the time that you spent
 for it.
 .PP
-Any image-file in gif-format can be used as the source for the puzzle, which
-is then randomly created regarding the sizes selected by the options. 
+Any image-file in GIF, JPEG, or PPM format can be used as the source for the
+puzzle, which is then randomly created regarding the sizes selected by the
+options. 
 .PP
 The control should be as intuitive as possible in the way that you will usually
 pull the freely rotatable pieces at one edge, drag them to the desired
@@ -80,10 +81,12 @@
 .B -w \fIx\fP
 Select number of tiles in horizontal direction. The Images are automatically
 rotated in portrait orientation before they are sliced. Therefore \fIx\fP
-usually should be smaller than \fIy\fP of the next option.
+usually should be smaller than \fIy\fP of the next option. The default
+is four.
 .TP 12
 .B -h \fIy\fP
-Select number of tiles in vertical direction respectively.
+Select number of tiles in vertical direction respectively. The default
+is six.
 .TP 12
 .B -ts \fIn\fP
 Select average tile width. Instead of explicitly specifying the number of tiles
--- xjig-2.4.orig/global.h
+++ xjig-2.4/global.h
@@ -101,7 +101,7 @@
 extern int		maxsnapretries;		// max. possible retries to snap the snapped
 
 extern class Puzzle			*p;		// Collection of all puzzle pieces
-extern class GifPixmap		*pm;		// Original pixmap for the puzzle tiles
+extern class XjigPixmap		*pm;		// Original pixmap for the puzzle tiles
 extern class Port				*port;	// Port (Display synonym) for color mapping
 extern class ObjectStack	*stk;		// administrator object for all viewable objects
 extern class ImageBuffer	*img_buf;//	memory for rotating image (probably shared)
--- xjig-2.4.orig/Imakefile
+++ xjig-2.4/Imakefile
@@ -27,21 +27,23 @@
 
 XCOMM which default file should be loaded if no option is set
 
-        JIG_DEFAULT = \"tina.gif\"
+        JIG_DEFAULT = \"/usr/share/games/xjig/tina.gif\"
 
 XCOMM #######################################################################
 
                SRCS = xjig.C objects.C stack.C imgbuff.C puzzle.C \
                       real.C vec2.C vec2list.C mat2.C \
-                      color_mapper.C gif_image.C gifx_image.C
+                      color_mapper.C base_image.C gif_image.C ximage.C \
+                      ppm_image.C jpeg_image.C
 
            CXXFLAGS = $(USE_MIT_SHM) $(RANG_CHECK)
 
-    LOCAL_LIBRARIES = $(XLIB) -lm
+    LOCAL_LIBRARIES = $(XLIB) -ljpeg -lnetpbm -lm
 
                OBJS = xjig.o objects.o stack.o imgbuff.o puzzle.o \
                       real.o vec2.o vec2list.o mat2.o \
-                      color_mapper.o gif_image.o gifx_image.o
+                      color_mapper.o base_image.o gif_image.o ximage.o \
+                      ppm_image.o jpeg_image.o
 
 
 
@@ -49,6 +51,7 @@
 	$(RM) $@
 	$(CXX) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
 
+AllTarget(xjig)
 InstallProgram(xjig,$(BINDIR))
 InstallManPage(xjig,$(MANDIR))
 DependTarget()
--- xjig-2.4.orig/xjig.C
+++ xjig-2.4/xjig.C
@@ -1,6 +1,10 @@
 
 #include "global.h"
 
+#include <time.h> // for time()
+#include <sys/types.h> // for getpid()
+#include <unistd.h> // for getpid()
+
 #include <signal.h>
 #ifdef PINUP_DEFAULT
 #	include <sys/stat.h>
@@ -42,7 +46,7 @@
 #	include "objects.H"
 #endif
 
-#include "gifx_image.H"
+#include "ximage.H"
 #include "color_mapper.H"
 #include "imgbuff.H"
 #include "puzzle.H"
@@ -118,27 +122,19 @@
 int		angle=0;					// preset angles for debugging
 
 class Puzzle		*p;			// Collection of all puzzle pieces
-class GifPixmap	*pm;			// Original pixmap for the puzzle tiles
+class XjigPixmap	*pm;			// Original pixmap for the puzzle tiles
 class Port			*port;		// Port (Display synonym) for color mapping
 class ObjectStack	*stk;			// administrator object for all viewable objects
 class ImageBuffer	*img_buf;	//	memory for rotating image (probably shared)
 
 // ===========================================================================
 
-static unsigned char b[2];
-
 static void my_srand( unsigned seed ) {
-	b[0]=seed&0xff;
-	b[1]=seed>>8;
+	srand(seed);
 }
 
 int my_rand(void) {
-	unsigned long	s1=b[0]<<8|b[1];
-	s1+=12345;
-	s1*=s1;
-	b[0]=(unsigned char)((s1>>8)&0xff);
-	b[1]=(unsigned char)((s1>>16)&0xff);
-	return (s1>>8)&0xffff;
+	return rand();
 }
 
 // ===========================================================================
@@ -301,7 +297,7 @@
 void usage() {
 	printf( "usage  : xjig [<options>]\n" );
 	printf( "\n" );
-	printf( "options: -file <file>: use gif-image in <file>\n" );
+	printf( "options: -file <file>: use image in <file>\n" );
 	printf( "         -w  <n>     : number of tiles in x direction\n" );
 	printf( "         -h  <n>     : number of tiles in y direction\n" );
 	printf( "         -ts <n>     : set average tile size\n" );
@@ -362,13 +358,13 @@
 void scan_args( int argc, char **argv ) {
 	for (int i=1;i<argc;i++) {
 		if (!strcmp(argv[i],"-display"))			dispname=argv[++i];
-		else if (!strcmp(argv[i],"-ww"))	width =atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-ww")&&i<argc-1)	width=atoi(argv[++i]);
 		else if (!strcmp(argv[i],"-wh")||!strcmp(argv[i],"-hh"))	height=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-w"))	dx=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-w")&&i<argc-1)	dx=atoi(argv[++i]);
 		else if (!strcmp(argv[i],"-h")&&i<argc-1)	dy=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-ts"))			tile_size=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-ts"))		tile_size=atoi(argv[++i]);
 		else if (!strcmp(argv[i],"-r"))			rotate=1;
-		else if (!strcmp(argv[i],"-a")) {
+		else if (!strcmp(argv[i],"-a")&&i<argc-1) {
 				angle=atoi(argv[++i]);
 				shuffle&=~1;
 		}
@@ -379,16 +375,16 @@
 		else if (!strcmp(argv[i],"-sp"))			shuffle=2;
 		else if (!strcmp(argv[i],"-no_flip"))  no_flip=1;
 		else if (!strcmp(argv[i],"-no_crop"))  autocrop=0;
-		else if (!strcmp(argv[i],"-side"))		side_lock=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-rand"))		random_seed=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-dist"))		distortion=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-maxang"))	maxang=atof(argv[++i]);
-		else if (!strcmp(argv[i],"-shadow"))	shadow_size=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-setup")) {
+		else if (!strcmp(argv[i],"-side")&&i<argc-1)		side_lock=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-rand")&&i<argc-1)		random_seed=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-dist")&&i<argc-1)		distortion=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-maxang")&&i<argc-1)	maxang=atof(argv[++i]);
+		else if (!strcmp(argv[i],"-shadow")&&i<argc-1)	shadow_size=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-setup")&&i<argc-1) {
 				straight_setup=atoi(argv[++i]);
 				shuffle=0;
 		}
-		else if (!strcmp(argv[i],"-file"))			filename=argv[++i];
+		else if (!strcmp(argv[i],"-file")&&i<argc-1)			filename=argv[++i];
 #ifdef PINUP_DEFAULT
 		else if (!strcmp(argv[i],"-pinup"))			filename=PINUP_DEFAULT;
 #endif
@@ -399,15 +395,15 @@
 		else if (!strcmp(argv[i],"-no_shm"))		shared=0;
 		else if (!strcmp(argv[i],"-shapes"))		shapes=1;
 		else if (!strncmp(argv[i],"-verbose",2))	verbose=1;
-		else if (!strcmp(argv[i],"-ftb"))			fliptimebase=atof(argv[++i]);
-		else if (!strcmp(argv[i],"-ftd"))			fliptimedelta=atof(argv[++i]);
-		else if (!strcmp(argv[i],"-mft"))			maxfliptiles=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-fs"))				flipsave=atof(argv[++i]);
-		else if (!strcmp(argv[i],"-ttb"))			turntimebase=atof(argv[++i]);
-		else if (!strcmp(argv[i],"-ttd"))			turntimedelta=atof(argv[++i]);
-		else if (!strcmp(argv[i],"-mtt"))			maxturntiles=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-msr"))			maxsnapretries=atoi(argv[++i]);
-		else if (!strcmp(argv[i],"-mac"))			minadjustcount=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-ftb")&&i<argc-1)			fliptimebase=atof(argv[++i]);
+		else if (!strcmp(argv[i],"-ftd")&&i<argc-1)			fliptimedelta=atof(argv[++i]);
+		else if (!strcmp(argv[i],"-mft")&&i<argc-1)			maxfliptiles=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-fs")&&i<argc-1)				flipsave=atof(argv[++i]);
+		else if (!strcmp(argv[i],"-ttb")&&i<argc-1)			turntimebase=atof(argv[++i]);
+		else if (!strcmp(argv[i],"-ttd")&&i<argc-1)			turntimedelta=atof(argv[++i]);
+		else if (!strcmp(argv[i],"-mtt")&&i<argc-1)			maxturntiles=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-msr")&&i<argc-1)			maxsnapretries=atoi(argv[++i]);
+		else if (!strcmp(argv[i],"-mac")&&i<argc-1)			minadjustcount=atoi(argv[++i]);
 		else if (!strcmp(argv[i],"-no_anim")) {
 									maxturntiles = maxfliptiles = 0;
 		}
@@ -522,7 +518,7 @@
 	// load image an scale it according to the input options
 	// or set original image size, when no size selected.
 	//
-	pm=new GifPixmap(port,filename);
+	pm=new XjigPixmap(port,filename);
 	options=pm->GetExtensionData( OPTION_EXTENSION );
 	if (options) {
 		char	opt_buffer[256];
@@ -637,7 +633,10 @@
 	img_buf = new ImageBuffer();
 
 	// initialize puzzle game
-	my_srand( random_seed );
+	if(random_seed>0)
+		my_srand( random_seed );
+	else
+		my_srand(time(NULL)+getpid());
 	p = new Puzzle();
 	p->Init(width,height,dx,dy, pm->GetExtensionData( FLATTILE_EXTENSION ) );
 
@@ -668,7 +667,7 @@
 			XSync(dpy,0);
 			while (!XPending(dpy)) {
 				struct timeval timeout;
-				struct fd_set readfds;
+				/*struct*/ fd_set readfds;
 				int		nfds;
 	
 				FD_ZERO( &readfds );
--- xjig-2.4.orig/gif_image.C
+++ xjig-2.4/gif_image.C
@@ -42,7 +42,6 @@
 #define	DEBUG	0
 
 #define	quiet				1
-#define	minpix			10
 #define	fastinfo_flag	0
 
 void Extension::AddData( char *ndata, int nlen ) {
@@ -55,40 +54,20 @@
 }
 
 GifImage::GifImage(const char *filename, int autocrop )
-: lockcount(0) {
+	: Image(filename, autocrop)
+{
 	first=0;
-	LoadGIF( filename );
-	name = strrchr(filename,'/');
-	if (name)	name=strdup(name+1);
-	else			name=strdup(filename);
+	LoadImageFile( filename );
 
 	if (autocrop&&!fastinfo_flag)	CropImage();
 }
 
 GifImage::GifImage() {
 	first=0;
-	name=strdup("dummy");
-	lockcount=0;
-	ColorMapSize=128;
-	for (int i=0;i<128;i++) {
-		Red[i]   = 255 * ((i>>5)&0x03) / 3;
-		Green[i] = 255 * ((i>>2)&0x07) / 7;
-		Blue[i]  = 255 *      (i&0x03) / 3;
-	}
-	width =1;
-	height=1;
-	data  =(byte*)malloc(1);
 }
 
 GifImage::~GifImage() {
-	if (lockcount) {
-		fprintf( stderr, "ERROR: GifImage::~GifImage: image still locked\n" );
-	}
-
 	if (first)	delete first;
-
-	free(name);
-	CloseGif();
 }
 
 const char *GifImage::GetExtensionData( unsigned char code ) {
@@ -100,156 +79,6 @@
 	return 0;
 }
 
-int GifImage::GetColor(int id, unsigned short *red, unsigned short *green, unsigned short *blue) {
-	*red  =Red[id]   | Red[id]<<8;
-	*green=Green[id] | Green[id]<<8;
-	*blue =Blue[id]  | Blue[id]<<8;
-	return 0;
-}
-
-void GifImage::Recolor( class GifImage *gif_p ) {
-int mapper[256];
-int i,j;
-
-	for (i=0;i<ColorMapSize;i++) {
-		int	min_j = 0;
-		int	min_d = 0x7fffffff;
-		for (j=0;j<gif_p->ColorMapSize;j++) {
-			int dr = (gif_p->Red[j]  -Red[i]);
-			int dg = (gif_p->Green[j]-Green[i]);
-			int db = (gif_p->Blue[j] -Blue[i]);
-			int d = dr*dr + dg*dg + db*db;
-			if (d<min_d) {
-				min_d = d;
-				min_j = j;
-			} 
-		}
-		mapper[i]=min_j;
-	}
-	for (i=0;i<width*height;i++) {
-		data[i] = mapper[data[i]];
-	}
-
-	for (j=0;j<gif_p->ColorMapSize;j++) {
-		Red[j]   = gif_p->Red[j];
-		Green[j] = gif_p->Green[j];
-		Blue[j]  = gif_p->Blue[j];
-	}
-	ColorMapSize = gif_p->ColorMapSize;
-}
-
-void GifImage::Rotate90() {
-byte	*ndata;
-int	help;
-
-	if (!(ndata = (byte *)malloc(width*height))) {
-		fprintf(stderr,"not enough memory to flip image");
-		exit(-1);
-	}
-
-	for (int y=0;y<height;y++) {
-		for (int x=0;x<width;x++) {
-			ndata[(height-y-1)+x*height] = data[x+y*width];
-		}
-	}
-
-	help=width; width=height; height=help;
-	free(data);
-	data=ndata;
-}
-
-void GifImage::AddAt( int x21, int y21, class GifImage *gif_p ) {
-int x22=x21+gif_p->Width();
-int y22=y21+gif_p->Height();
-
-int nwidth,nheight;
-byte *ndata=0;
-
-	if (x21>=0) {
-		if (x22>Width())		nwidth=x22;
-		else						nwidth=Width();
-	}
-	else {
-		if (x22>Width())		nwidth=gif_p->Width();
-		else						nwidth=(-x21)+Width();
-	}
-	if (y21>=0) {
-		if (y22>Height())		nheight=y22;
-		else						nheight=Height();
-	}
-	else {
-		if (y22>Height())		nheight=gif_p->Height();
-		else						nheight=(-y21)+Height();
-	}
-
-	if (nwidth>Width()||nheight>Height()) {
-		if (!(ndata = (byte *)malloc(nwidth*nheight))) {
-			fprintf(stderr,"not enough memory for image");
-			exit(-1);
-		}
-
-	/* move first image */
-		memset( ndata, 0, nwidth*nheight );
-		int offx = (x21<0)?-x21:0;
-		int offy = (y21<0)?-y21:0;
-		for (int y=0;y<Height();y++) {
-			memcpy( ndata+offx+(offy+y)*nwidth, data+y*Width(), Width() );
-		}
-	}
-	else	ndata=data;
-
-#if (0)
-	printf( "Colors1: %d\n", ColorMapSize );
-	printf( "Colors2: %d\n", gif_p->ColorMapSize );
-	for (int i=0;i<gif_p->ColorMapSize;i++) {
-		printf( "%3d: %02x %02x %02x   %02x %02x %02x\n", i,
-			Red[i], Green[i], Blue[i],
-			gif_p->Red[i], gif_p->Green[i], gif_p->Blue[i] );
-	}
-#endif
-
-	int offx = (x21>=0)?x21:0;
-	int offy = (y21>=0)?y21:0;
-	for (int y=0;y<gif_p->Height();y++) {
-		memcpy( ndata+offx+(offy+y)*nwidth, gif_p->data+y*gif_p->Width(), gif_p->Width() );
-	}
-
-	if (ndata!=data) {
-		free(data);
-		data   = ndata;
-		height = nheight;
-		width  = nwidth;
-	}
-}
-
-void GifImage::AddLock(class GifXImage *  /*locker*/ ) {
-	lockcount++;
-}
-void GifImage::RemoveLock(class GifXImage * /*locker*/ ) {
-	if (!--lockcount) {
-		delete this;
-	}
-}
-
-void GifImage::GetSize( int *w, int *h ) {
-	*w = Width();
-	*h = Height();
-}
-
-long GifImage::GetAverageColor() {
-long	erg;
-int	i;
-
-	erg=0;
-	for (i=Width()*Height();i>0;i--) {
-		erg+=10*Red[*data];
-		erg+=5*Green[*data];
-		erg+=Blue[*data];
-		data++;
-	}
-	return erg;
-}
-
 #define IMAGESEP 0x2c
 #define EXTENSION 0x21
 #define INTERLACEMASK 0x40
@@ -290,7 +119,7 @@
 
 
 /*****************************/
-int GifImage::LoadGIF(const char *fname)
+int GifImage::LoadImageFile(const char *fname)
 /*****************************/
 {
 	register byte ch;
@@ -313,8 +142,8 @@
 	if ( (fread(gifheader, sizeof(gifheader), 1, fp)!=1)
 	  || ( (strncmp((char*)gifheader, id, 3)!=0)
 	    && (strncmp((char*)gifheader, "FIG", 3)!=0) ) )
-	  		{		fprintf(stderr,"'%s' not a GIF file\n", fname );
-	  				return 1;
+	  		{		fprintf(stderr,"'%s' not a GIF, JPG or PPM file\n", fname );
+	  				exit(1);
 	  		}
 
 	if (strncmp((char*)gifheader+3, "87a", 3) && strncmp((char*)gifheader+3,"89a",3))
@@ -403,106 +232,6 @@
 	return 0;
 }
 
-int GifImage::CropImage(int x1,int y1, int x2, int y2) {
-int	w = x2-x1;
-int	h = y2-y1;
-
-	if (x1<0 || x2>width  || w<0 || y1<0 || y2>height || h<0) {
-		fprintf(stderr,"unable to crop (%d,%d)-(%d,%d)\n", x1,y1,x2,y2);
-		fprintf(stderr,"image size: %dx%d\n", width, height );
-		exit(-1);
-	}
-
-	for (int i=0;i<h;i++) {
-			memmove(data+i*w,data+(i+y1)*Width()+x1,w);
-	}
-	width  = w;
-	height = h;
-	return 0;
-}
-
-int GifImage::CropImage() {
-int		i,j;
-int		b;
-int		x1,x2,y1,y2;
-byte		*ptr;
-long		d;
-
-	b=*data;
-	d=0x7fffffff;
-	for (i=0;i<256;i++) {
-			if (Red[i]+Green[i]+Blue[i]<d) {
-					b=i;
-					d=Red[i]+Green[i]+Blue[i];
-			}
-	}
-	x1=-1; x2=Width();
-	y1=-1; y2=Height();
-	for (i=0; i<Height(); i++) {
-			int		flag[256];
-			int		count=0;
-			ptr = data + (i*Width());
-			for (j=0;j<256;j++)		flag[j]=0;
-		for (j=0; j<Width(); j++,ptr++) {
-				if (!flag[*ptr]) {
-						flag[*ptr]++;
-						if (++count>=minpix)		break;
-				}
-		}
-		if (count>=minpix)		break;
-		y1=i;
-	}
-	for (i=Height()-1;i>=0; i--) {
-			int		flag[256];
-			int		count=0;
-			ptr = data + (i*Width());
-			for (j=0;j<256;j++)		flag[j]=0;
-		for (j=0; j<Width(); j++,ptr++) {
-				if (!flag[*ptr]) {
-						flag[*ptr]++;
-						if (++count>=minpix)		break;
-				}
-		}
-		if (count>=minpix)		break;
-		y2=i;
-	}
-
-	for (i=0; i<Width(); i++) {
-			int		flag[256];
-			int		count=0;
-			ptr = data + i;
-			for (j=0;j<256;j++)		flag[j]=0;
-		for (j=0; j<Height(); j++,ptr+=Width()) {
-				if (!flag[*ptr]) {
-						flag[*ptr]++;
-						if (++count>=minpix)		break;
-				}
-		}
-		if (count>=minpix)		break;
-		x1=i;
-	}
-	for (i=Width()-1;i>=0;i--) {
-			int		flag[256];
-			int		count=0;
-			ptr = data + i;
-			for (j=0;j<256;j++)		flag[j]=0;
-		for (j=0; j<Height(); j++,ptr+=Width()) {
-				if (!flag[*ptr]) {
-						flag[*ptr]++;
-						if (++count>=minpix)		break;
-				}
-		}
-		if (count>=minpix)		break;
-		x2=i;
-	}
-
-	x1++; x2--; y1++; y2--;
-	if (x2<=x1||y2<=y1)				return 1;
-
-	CropImage(x1,y1,x2,y2);
-	return 0;
-}
-
 int  GifImage::DecodeImage()
 {
 /* Start reading the raster data. First we get the intial code size
@@ -709,31 +438,3 @@
 	}
 	NumUsed=0;
 }
-
-
-void GifImage::CloseGif()
-{
-#if (0)
-	if (LocalCmap)
-	{
-		XFreeColormap(theDisp, LocalCmap);
-		LocalCmap=0;
-	}  
-	else
-	{
-		int i,j;
-		unsigned long pixels[256];
-		 
-		for (j=i=0;i<ColorMapSize;i++)
-			if (used[i]==ALLOCATED)
-				pixels[j++]=cols[i];
-		XFreeColors(theDisp, theCmap, pixels, j, 0L);
-	}
-#endif
-	if (data)
-	{
-		free(data);
-		data=NULL;
-	}
-}
-
--- xjig-2.4.orig/gif_image.H
+++ xjig-2.4/gif_image.H
@@ -1,15 +1,7 @@
 #ifndef __gif_image_h
 #define __gif_image_h
 
-typedef unsigned char	byte;
-typedef int					boolean;
-
-#define	OPTION_EXTENSION		(0x10)
-#define	REMOVETILE_EXTENSION	(0x11)
-#define	FLATTILE_EXTENSION	(0x12)
-#define	SUBSIZE_EXTENSION		(0x13)
-#define	SCALEINFO_START		(0x20)
-#define	COMMENT_EXTENSION		(0xFE)
+#include "base_image.H"
 
 class Extension {
 	public:
@@ -30,34 +22,16 @@
 	friend class GifImage;
 };
 
-class GifImage {
+class GifImage : public Image {
 	public:
 		GifImage( const char *filename, int autocrop=1 );
 		GifImage();
 		~GifImage();
 
-		const char *Name()	{ return name; }
-		int Width()				{ return width; }
-		int Height()			{ return height; }
-		const byte* Data()	{ return data; }
-
 		const char *GetExtensionData( unsigned char code );
-		void GetSize( int *h, int *w );
-		long GetAverageColor();
-
-		int CropImage(int x1,int y1, int x2, int y2);
-		int CropImage();
-
-		void AddLock(class GifXImage *locker);
-		void RemoveLock(class GifXImage *locker);
-
-		void Recolor( class GifImage *gif_p );
-		void AddAt( int x, int y, class GifImage *gif2 );
-
-		void Rotate90();
 
 	protected:
-		int LoadGIF(const char *fname);
+		int LoadImageFile(const char *fname);
 		int ReadImageData(FILE *fp);			// read raw raster data into buffer
 		int DecodeImage();						// decode data into image
 		static int ReadCode();
@@ -66,26 +40,9 @@
 		int ColorDicking();
 #endif
 		void ReadColormap(FILE *fp);
-		void CloseGif();
 
 	protected:
-		char	*name;
-		int	width, height;								// image dimensions
-		byte	*data;										// image data
-		byte	Red[256], Green[256], Blue[256];		// Colormap-Data
-		boolean	HasColormap;
-		int		ColorMapSize;						/* number of colors */
-		int		Background;							/* background color */
-
-		int		lockcount;							/* number of lockers */
-
 		Extension	*first;
-
-	public:
-		int	GetNCols()	{ return ColorMapSize; }
-		int	GetColor(int id, unsigned short *red, unsigned short *green, unsigned short *blue);
-
-friend class GifXImage;
 };
 
 #endif
--- xjig-2.4.orig/Makefile.Linux
+++ xjig-2.4/Makefile.Linux
@@ -1,6 +1,6 @@
 
 ### compiler section
-CXX			= gcc -Wall -fstrength-reduce -fpcc-struct-return
+CXX			= g++ -Wall -fstrength-reduce -fpcc-struct-return
 CXXFLAGS	   = -g -DUSE_MIT_SHM
 
 ### default file to be used, when no options are set
@@ -24,7 +24,7 @@
 
 LD	      = $(CXX)
 
-LIBS	      = -lXext -lX11 -lm
+LIBS	      = -lXext -lX11 -ljpeg -lnetpbm -lm
 
 OBJS	= xjig.o \
 		objects.o \
@@ -36,8 +36,11 @@
 		vec2list.o \
 		mat2.o \
 		color_mapper.o \
+		base_image.o \
 		gif_image.o \
-		gifx_image.o
+		ppm_image.o \
+		jpeg_image.o \
+		ximage.o
 
 PROGRAM       = xjig
 
@@ -62,32 +65,34 @@
 vec2list.o: vec2list.C
 mat2.o: mat2.C
 color_mapper.o: color_mapper.C
+base_image.o: base_image.C
 gif_image.o: gif_image.C
-gifx_image.o: gifx_image.C
+ppm_image.o: ppm_image.C
+jpeg_image.o: jpeg_image.C
+ximage.o: ximage.C
 
 # -----------------------------------------------------------------------
 # dependencies generated by makedepend
 
 # DO NOT DELETE
 
-color_mapper.o: color_mapper.H
-gif_image.o: gif_image.H
-gifx_image.o: global.h gifx_image.H gif_image.H color_mapper.H reset_image.H
-imgbuff.o: global.h imgbuff.H
-mat2.o: global.h mat2.h real.h vec2.h
-mat2_x.o: global.h vec2.h vec2list.h mat2.h real.h
-matrix.o: global.h matrix.h vector.h real.h
-matrix_x.o: global.h vec2.h vec3.h real.h matrix.h vector.h
-objects.o: global.h objects.H stack.H vec2.h vec2list.h mat2.h real.h
-objects.o: gifx_image.H gif_image.H imgbuff.H color_mapper.H puzzle.H
-objects.o: rotate.H
-puzzle.o: global.h puzzle.H objects.H stack.H vec2.h vec2list.h mat2.h real.h
-real.o: global.h real.h
-stack.o: global.h stack.H objects.H vec2.h vec2list.h mat2.h real.h
-stack.o: gifx_image.H gif_image.H
-vec2.o: global.h vec2.h
-vec2list.o: global.h vec2list.h mat2.h real.h vec2.h
-vec3.o: global.h vec3.h real.h
-vector.o: global.h vector.h real.h vec2.h vec3.h
-xjig.o: global.h objects.H stack.H vec2.h vec2list.h mat2.h real.h
-xjig.o: gifx_image.H gif_image.H color_mapper.H imgbuff.H puzzle.H cursor.h
+base_image.o: base_image.C base_image.H
+color_mapper.o: color_mapper.C color_mapper.H
+gif_image.o: gif_image.C gif_image.H base_image.H
+imgbuff.o: imgbuff.C global.h imgbuff.H
+jpeg_image.o: jpeg_image.C jpeg_image.H base_image.H
+mat2.o: mat2.C global.h mat2.h real.h vec2.h
+objects.o: objects.C global.h objects.H stack.H vec2.h real.h vec2list.h \
+  mat2.h ximage.H base_image.H imgbuff.H color_mapper.H puzzle.H rotate.H
+ppm_image.o: ppm_image.C ppm_image.H base_image.H
+puzzle.o: puzzle.C global.h puzzle.H vec2.h real.h objects.H stack.H \
+  vec2list.h mat2.h
+real.o: real.C global.h real.h
+stack.o: stack.C global.h stack.H objects.H vec2.h real.h vec2list.h \
+  mat2.h ximage.H base_image.H
+vec2.o: vec2.C global.h vec2.h real.h
+vec2list.o: vec2list.C global.h vec2list.h vec2.h real.h mat2.h
+ximage.o: ximage.C global.h ximage.H base_image.H color_mapper.H \
+  gif_image.H ppm_image.H jpeg_image.H reset_image.H
+xjig.o: xjig.C global.h objects.H stack.H vec2.h real.h vec2list.h mat2.h \
+  ximage.H base_image.H color_mapper.H imgbuff.H puzzle.H cursor.h
--- xjig-2.4.orig/Makefile.HP-UX
+++ xjig-2.4/Makefile.HP-UX
@@ -24,11 +24,12 @@
 
 LD	      = $(CXX)
 
-LIBS	      = -lXext -lX11 -lm
+LIBS	      = -lXext -lX11 -ljpeg -lnetpbm -lm
 
 OBJS	= xjig.o objects.o stack.o imgbuff.o puzzle.o \
 		real.o vec2.o vec2list.o mat2.o \
-		color_mapper.o gif_image.o gifx_image.o
+		color_mapper.o base_image.o gif_image.o \
+		ppm_image.o jpeg_image.o ximage.o
 
 PROGRAM       = xjig
 
@@ -53,32 +54,34 @@
 vec2list.o: vec2list.C
 mat2.o: mat2.C
 color_mapper.o: color_mapper.C
+base_image.o: base_image.C
 gif_image.o: gif_image.C
-gifx_image.o: gifx_image.C
+ppm_image.o: ppm_image.C
+jpeg_image.o: jpeg_image.C
+ximage.o: ximage.C
 
 # -----------------------------------------------------------------------
 # dependencies generated by makedepend
 
 # DO NOT DELETE
 
-color_mapper.o: color_mapper.H
-gif_image.o: gif_image.H
-gifx_image.o: global.h gifx_image.H gif_image.H color_mapper.H reset_image.H
-imgbuff.o: global.h imgbuff.H
-mat2.o: global.h mat2.h real.h vec2.h
-mat2_x.o: global.h vec2.h vec2list.h mat2.h real.h
-matrix.o: global.h matrix.h vector.h real.h
-matrix_x.o: global.h vec2.h vec3.h real.h matrix.h vector.h
-objects.o: global.h objects.H stack.H vec2.h vec2list.h mat2.h real.h
-objects.o: gifx_image.H gif_image.H imgbuff.H color_mapper.H puzzle.H
-objects.o: rotate.H
-puzzle.o: global.h puzzle.H objects.H stack.H vec2.h vec2list.h mat2.h real.h
-real.o: global.h real.h
-stack.o: global.h stack.H objects.H vec2.h vec2list.h mat2.h real.h
-stack.o: gifx_image.H gif_image.H
-vec2.o: global.h vec2.h
-vec2list.o: global.h vec2list.h mat2.h real.h vec2.h
-vec3.o: global.h vec3.h real.h
-vector.o: global.h vector.h real.h vec2.h vec3.h
-xjig.o: global.h objects.H stack.H vec2.h vec2list.h mat2.h real.h
-xjig.o: gifx_image.H gif_image.H color_mapper.H imgbuff.H puzzle.H cursor.h
+base_image.o: base_image.C base_image.H
+color_mapper.o: color_mapper.C color_mapper.H
+gif_image.o: gif_image.C gif_image.H base_image.H
+imgbuff.o: imgbuff.C global.h imgbuff.H
+jpeg_image.o: jpeg_image.C jpeg_image.H base_image.H
+mat2.o: mat2.C global.h mat2.h real.h vec2.h
+objects.o: objects.C global.h objects.H stack.H vec2.h real.h vec2list.h \
+  mat2.h ximage.H base_image.H imgbuff.H color_mapper.H puzzle.H rotate.H
+ppm_image.o: ppm_image.C ppm_image.H base_image.H
+puzzle.o: puzzle.C global.h puzzle.H vec2.h real.h objects.H stack.H \
+  vec2list.h mat2.h
+real.o: real.C global.h real.h
+stack.o: stack.C global.h stack.H objects.H vec2.h real.h vec2list.h \
+  mat2.h ximage.H base_image.H
+vec2.o: vec2.C global.h vec2.h real.h
+vec2list.o: vec2list.C global.h vec2list.h vec2.h real.h mat2.h
+ximage.o: ximage.C global.h ximage.H base_image.H color_mapper.H \
+  gif_image.H ppm_image.H jpeg_image.H reset_image.H
+xjig.o: xjig.C global.h objects.H stack.H vec2.h real.h vec2list.h mat2.h \
+  ximage.H base_image.H color_mapper.H imgbuff.H puzzle.H cursor.h
--- xjig-2.4.orig/stack.C
+++ xjig-2.4/stack.C
@@ -13,8 +13,8 @@
 #ifndef _objects_h
 #	include "objects.H"
 #endif
-#ifndef _gifx_image_h
-#	include "gifx_image.H"
+#ifndef _ximage_h
+#	include "ximage.H"
 #endif
 
 
--- xjig-2.4.orig/objects.C
+++ xjig-2.4/objects.C
@@ -9,8 +9,8 @@
 #ifndef _objects_h
 #	include "objects.H"
 #endif
-#ifndef _gifx_image_h
-#	include "gifx_image.H"
+#ifndef _ximage_h
+#	include "ximage.H"
 #endif
 #ifndef _imgbuff_h
 #	include "imgbuff.H"
@@ -73,6 +73,8 @@
 
 double PieceFrameSetup::spx[] = {  1, 2.5, 5, 7, 7, 5, 5, 6, 8,13 };
 double PieceFrameSetup::spy[] = { 13,12.5,11, 8, 5, 2, 0,-2,-3,-3 };
+//double PieceFrameSetup::spx[] = {  1, 2,  4, 5, 7, 8, 9, 10,11,13 };
+//double PieceFrameSetup::spy[] = { 13, 12,10, 9, 7, 6, 5,  4, 3, 1 };
 
 
 PieceFrameSetup::PieceFrameSetup() {
@@ -1070,7 +1072,7 @@
 			}
 			turnflag=0;
 	}
-	else if (xbutton->time-start_time<150&&xbutton->button==Button2&&!(xbutton->state&~Button2Mask)) {
+	else if (xbutton->time-start_time<300&&xbutton->button==Button2&&!(xbutton->state&~Button2Mask)) {
 				FlipOver(Vec2(xbutton->x,xbutton->y));
 	}
 	else if (xbutton->state&Button1Mask)
--- xjig-2.4.orig/debian/README.debian
+++ xjig-2.4/debian/README.debian
@@ -0,0 +1,19 @@
+xjig for Debian
+---------------
+
+This is the Debian Linux prepackaged version of "xjig", an X11 jigsaw
+game. xjig was written by Helmut Hoenig <Helmut.Hoenig@hub.de>.
+
+This package was put together by Dave Holland <dave@debian.org>
+from sources obtained from ftp.x.org:/contrib/games/xjig-2.4.tgz
+
+For changes made to the source for the Debian version of xjig, see
+the file /usr/share/doc/xjig/changelog.Debian.gz
+
+For copyright information, see the file /usr/share/doc/xjig/copyright
+
+This package includes "xjig-random", a perl script which runs xjig with
+a random image from /usr/lib/games/xjig/* . This script is called by
+xjig's Debian menu entry.
+
+Dave Holland <dave@debian.org>
--- xjig-2.4.orig/debian/changelog
+++ xjig-2.4/debian/changelog
@@ -0,0 +1,121 @@
+xjig (2.4-11.1) unstable; urgency=low
+
+  * NMU
+  * debian/rules: Adapt to new imake behaviour of installing stuff to /usr/bin
+    (Closes: #373693)
+  * Do menu file transition, install it in /usr/share/menu
+
+ -- Marc 'HE' Brockschmidt <he@debian.org>  Thu, 15 Jun 2006 10:44:42 +0200
+i
+xjig (2.4-11) unstable; urgency=low
+
+  * update xlibs-dev build dependency (thanks, John Wright)
+    (closes: #346404)
+
+ -- Dave Holland <dave@debian.org>  Tue, 10 Jan 2006 12:03:26 +0000
+
+xjig (2.4-10) unstable; urgency=low
+
+  * the /usr/doc symlink is no more (closes: #345282)
+
+ -- Dave Holland <dave@debian.org>  Fri,  6 Jan 2006 13:27:32 +0000
+
+xjig (2.4-9) unstable; urgency=low
+
+  * increased the delay threshold on middle-click (thanks to Richard
+    Fojta for the suggestion)
+  * now supports JPEG and PPM images (many thanks to Alan Curry for
+    the patch) (closes: #239134)
+  * rebuilt with g++ 4.0.2-4
+
+ -- Dave Holland <dave@debian.org>  Fri,  2 Dec 2005 13:00:45 +0000
+
+xjig (2.4-8) unstable; urgency=low
+
+  * rebuilt in "sid" using g++ 3.3 (closes: #210502).
+
+ -- Dave Holland <dave@debian.org>  Thu, 18 Sep 2003 13:18:34 +0000
+
+xjig (2.4-7) unstable; urgency=low
+
+  * change build-depends to xlibs-dev (closes: #170143).
+  * support DEB_BUILD_OPTIONS
+  * now conforms to Standards 3.5.8.0
+
+ -- Dave Holland <dave@debian.org>  Mon, 25 Nov 2002 14:03:23 +0000
+
+xjig (2.4-6) unstable; urgency=low
+
+  * Added detail to man page (closes #139281).
+  * Fixed segfault with various command line arguments.
+  * Fixed mode of xjig-random (closes #96000).
+  * Used Carl Johnson's idea for better randomness (closes #137436).
+  * Fixed some small errors in README.debian.
+
+ -- Dave Holland <dave@debian.org>  Thu,  3 Oct 2002 17:08:30 +0100
+
+xjig (2.4-5.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Added Build-Depends, fixes Bug#84647.
+
+ -- Lenart Janos <ocsi@debian.org>  Sat, 24 Feb 2001 02:28:59 +0100
+
+xjig (2.4-5) frozen unstable; urgency=low
+
+  * Added Yann Dirson's patch for xjig-random (fixes #43599).
+  * Conforms to Standards 3.1.1.1.
+  * Changed maintainer email address.
+
+ -- Dave Holland <dave@debian.org>  Thu, 13 Jan 2000 13:37:29 +0000
+
+xjig (2.4-4.1) unstable; urgency=low
+
+  * Non-maintainer upload during bug-squashing party.
+  * Recompilation with new libstdc++2.10 (closes #53218).
+
+ -- Christian Kurz <shorty@debian.org>  Sat,  8 Jan 2000 15:34:54 +0100
+
+xjig (2.4-4) unstable; urgency=low
+
+  * debian/rules: changed "cp" to "install" for postinst, postrm
+    (fixes #40161) -- thanks to Roman Hodek.
+
+ -- Dave Holland <dave@zenda.demon.co.uk>  Fri, 25 Jun 1999 09:21:50 +0100
+
+xjig (2.4-3) unstable; urgency=low
+
+  * Exits gracefully if supplied image is not a GIF (fixes #10666).
+  * Added menu file, call update-menus (fixes #15063).
+  * Added xjig-random (fixes #24476).
+  * Compiled with g++ 2.91.60-5 (egcs) (fixes #29075).
+
+ -- Dave Holland <dave@zenda.demon.co.uk>  Tue, 22 Jun 1999 17:34:12 +0100
+
+xjig (2.4-2.2) frozen unstable; urgency=low
+
+  * Non maintainer upload.
+  * Recompiled with g++/libstdc++2.9.
+  * debian/rules: Set CXX.
+  * Install debian/changelog.
+  * Install xjig into /usr/games.
+
+ -- Matthias Klose <doko@cs.tu-berlin.de>  Mon, 14 Dec 1998 14:38:47 +0200
+ 
+xjig (2.4-2.1) unstable; urgency=low
+
+  * Non-maintainer release.
+  * Libc6 compile.
+
+ -- Martin Mitchell <martin@debian.org>  Wed, 12 Nov 1997 04:38:05 +1100
+
+xjig (2.4-2) unstable; urgency=low
+
+  * Source package now conforms to Debian Standards 2.1.0.0 (fixes #9520)
+  * Changed maintainer email address
+
+ -- Dave Holland <dave@zenda.demon.co.uk>  Mon, 12 May 1997 13:18:47 +0100
+
+Local variables:
+mode: debian-changelog
+End:
--- xjig-2.4.orig/debian/copyright
+++ xjig-2.4/debian/copyright
@@ -0,0 +1,73 @@
+This package was debianized by Dave Holland dave@zenda.demon.co.uk on
+Mon, 12 May 1997 13:18:47 +0100.
+
+It was downloaded from ftp.x.org:/contrib/games/xjig-2.4.tgz
+
+Copyright:
+
+       Copyright 1996, Helmut Hoenig, Heiligenhaus/Bad Camberg
+
+       email (for any comments):
+               Helmut.Hoenig@hub.de
+
+       smail (for gifts :-)
+               Helmut Hoenig
+               Hopfenstrasse 8a
+               65520 Bad Camberg
+               GERMANY
+
+        ********************************************************
+
+           By the way, I am collecting banknotes! If you want
+            to join into my collection, get any bill of your
+           country, sign it on the backside and send it to me
+                   so I will pin it on my world map.
+            (Don't forget the exact location for the pin :-)
+          But you can also just send me a picture postcard ...
+
+        ********************************************************
+
+       Permission to use, copy, modify, and distribute this soft-
+       ware  for  any  purpose and without fee is hereby granted,
+       provided that the above copyright  notice  appear  in  all
+       copies
+
+ -----------------------------------------------------------------------------
+
+               The demo picture supplied with the package
+          (which I can set together by heart in the meantime)
+      was taken from Panorama-Disk 124 with license free photo's by
+
+                         Dr. Lothar Rossipaul
+                       Verlagsgesellschaft mbH
+                          Menzinger Str. 37
+                            80638 München
+
+ -----------------------------------------------------------------------------
+
+  The loading routine for gif images was extracted from the gif-loader
+  of the xv-package. It was rearranged, enclosed into a C++-class and
+  enhanced to use extension data for some game specific features.
+
+  Here is the copyright note, that was contained in the original loader:
+
+| xvgif.c  -  GIF loading code for 'xv'.  Based strongly on...
+|
+| gif2ras.c - Converts from a Compuserve GIF (tm) image to a Sun Raster image.
+|
+| Copyright (c) 1988, 1989 by Patrick J. Naughton
+|
+| Author: Patrick J. Naughton
+| naughton@wind.sun.com
+|
+| Permission to use, copy, modify, and distribute this software and its
+| documentation for any purpose and without fee is hereby granted,
+| provided that the above copyright notice appear in all copies and that
+| both that copyright notice and this permission notice appear in
+| supporting documentation.
+|
+| This file is provided AS IS with no warranties of any kind.  The author
+| shall have no liability with respect to the infringement of copyrights,
+| trade secrets or any patents by this file or any part thereof.  In no
+| event will the author be liable for any lost revenue or profits or
+| other special, indirect and consequential damages.
--- xjig-2.4.orig/debian/menu
+++ xjig-2.4/debian/menu
@@ -0,0 +1 @@
+?package(xjig):needs="x11" section="Games/Puzzles"  title="Xjig" command="/usr/games/xjig-random"
--- xjig-2.4.orig/debian/dirs
+++ xjig-2.4/debian/dirs
@@ -0,0 +1,3 @@
+/usr/games
+/usr/lib/games/xjig
+/usr/man/man6
--- xjig-2.4.orig/debian/postrm
+++ xjig-2.4/debian/postrm
@@ -0,0 +1,4 @@
+#!/bin/sh
+set -e
+
+if test -x /usr/bin/update-menus; then update-menus; fi
--- xjig-2.4.orig/debian/prerm
+++ xjig-2.4/debian/prerm
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+
+if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/xjig ]; then
+   rm -f /usr/doc/xjig
+fi
--- xjig-2.4.orig/debian/postinst
+++ xjig-2.4/debian/postinst
@@ -0,0 +1,4 @@
+#!/bin/sh
+set -e
+
+if test -x /usr/bin/update-menus; then update-menus; fi
--- xjig-2.4.orig/debian/rules
+++ xjig-2.4/debian/rules
@@ -0,0 +1,95 @@
+#!/usr/bin/make -f
+# Sample debian.rules file - for GNU Hello (1.3).
+# Copyright 1994,1995 by Ian Jackson.
+# I hereby give you perpetual unlimited permission to copy,
+# modify and relicense this file, provided that you do not remove
+# my name from the file itself.  (I assert my moral right of
+# paternity under the Copyright, Designs and Patents Act 1988.)
+# This file may have to be extensively modified
+
+package=xjig
+CXX=c++ -g -Wall
+INSTALL = install
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+	INSTALL += -s
+endif
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CXX += -O0
+else
+	CXX += -O2
+endif
+
+
+
+build:
+	$(checkdir)
+	xmkmf # djh
+	make depend # djh
+	cp xjig.man xjig.6
+	if [ -x configure ]; then ./configure --prefix=/usr; fi
+	make CXX="$(CXX)"
+
+	touch build
+
+clean:
+	$(checkdir)
+	-rm -f build
+	-rm -f xjig xjig.6
+	-make clean
+	-rm `find . -name "*~"`
+	-rm -rf debian/tmp debian/files* core debian/substvars
+
+binary-indep:	checkroot build
+	$(checkdir)
+# There are no architecture-independent files to be uploaded
+# generated by this package.  If there were any they would be
+# made here.
+
+binary-arch:	checkroot build
+	$(checkdir)
+	-rm -rf debian/tmp
+	install -d debian/tmp/DEBIAN debian/tmp/usr/share/doc/xjig debian/tmp/usr/share/man/man6
+	if [ -x configure ]; then \
+	  make install CXX="$(CXX)" prefix=`pwd`/debian/tmp/usr ;\
+	else \
+	  make install CXX="$(CXX)" DESTDIR=`pwd`/debian/tmp; \
+	fi
+	mkdir -p debian/tmp/usr/lib/games/xjig
+	cp tina.gif debian/tmp/usr/lib/games/xjig
+	cp README* debian/README.debian debian/tmp/usr/share/doc/xjig
+	cp debian/changelog debian/tmp/usr/share/doc/xjig/changelog.Debian
+	mkdir -p debian/tmp/usr/share/menu
+	cp debian/menu debian/tmp/usr/share/menu/xjig
+	gzip -9v debian/tmp/usr/share/doc/xjig/*
+	cp debian/copyright debian/tmp/usr/share/doc/xjig
+	cp xjig.6 debian/tmp/usr/share/man/man6
+	cp xjig-random.man debian/tmp/usr/share/man/man6/xjig-random.6
+	gzip -9v debian/tmp/usr/share/man/man6/*
+	mkdir -p debian/tmp/usr/games
+	chmod a+rx xjig-random
+	cp xjig-random debian/tmp/usr/games
+	$(INSTALL) debian/tmp/usr/bin/xjig debian/tmp/usr/games/.
+	rm -rf debian/tmp/usr/bin
+	install -m 755 debian/prerm debian/postinst debian/postrm debian/tmp/DEBIAN
+	dpkg-shlibdeps debian/tmp/usr/games/xjig
+	dpkg-gencontrol -isp
+	chown -R root.root debian/tmp
+	chmod -R go=rX debian/tmp
+	dpkg --build debian/tmp ..
+
+define checkdir
+	test -f debian/rules
+endef
+
+# Below here is fairly generic really
+
+binary:		binary-indep binary-arch
+
+source diff:
+	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+checkroot:
+	$(checkdir)
+	test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep clean checkroot
--- xjig-2.4.orig/debian/control
+++ xjig-2.4/debian/control
@@ -0,0 +1,21 @@
+Source: xjig
+Section: games
+Priority: optional
+Maintainer: Dave Holland <dave@debian.org>
+Standards-Version: 3.5.8.0
+Build-Depends: xutils, libx11-dev, libxext-dev, x-dev, libnetpbm10-dev, libjpeg-dev
+
+Package: xjig
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: An X11 jigsaw puzzle
+ xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
+ as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
+ into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
+ original picture.
+ .
+ Tiles may be freely rotated by use of the mouse, flipped (for
+ double-sided puzzles) and even shown as shaped windows on the desktop
+ (fast machine/video card recommended for the latter!). An example image
+ is provided in /usr/lib/games/xjig .
+
--- xjig-2.4.orig/xjig-random
+++ xjig-2.4/xjig-random
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+#
+# start xjig with a random image from /usr/lib/games/xjig/*
+# or other directories
+#
+# Dave Holland <dave@debian.org> 22 June 1999
+
+srand;
+
+@list = split(' ',`/bin/ls /usr/lib/games/xjig/* /usr/local/lib/games/xjig/* ~/.xjig/*`);
+
+$index = rand @list;
+chomp($file = $list[$index]);
+
+exec "/usr/games/xjig",@ARGV,"-file","$file" || die "Couldn't start xjig: $!\n";
--- xjig-2.4.orig/xjig-random.man
+++ xjig-2.4/xjig-random.man
@@ -0,0 +1,25 @@
+.TH xjig-random 6 "23 June 1999" ""
+.SH NAME
+xjig-random \- a random jigsaw puzzle
+.SH SYNOPSIS
+.B xjig-random
+<options>
+.SH DESCRIPTION
+.I xjig-random
+selects a random image from the /usr/lib/games/xjig directory and loads
+it into xjig.
+.PP
+Command-line options may be specified and will be passed through to
+xjig.
+
+.SH "SEE ALSO"
+X(1), xjig(6)
+
+.SH COPYRIGHT
+Copyright 1999 Dave Holland <dave@debian.org>
+.PP
+Permission to use, copy, modify, and distribute this software for any
+purpose and without fee is hereby granted, provided that the above
+copyright notice appear in all copies.
+
+.fi
--- xjig-2.4.orig/README.beyondgif
+++ xjig-2.4/README.beyondgif
@@ -0,0 +1,52 @@
+Notes in random order:
+
+The internal data format for xjig's images shows its GIF heritage: it uses an
+8-bit palette. To support non-paletted images, there are 3 ways to go:
+  1. Convert the image to an 8-bit palette while loading it. This implies a
+  loss of quality if the image contains more than 256 distinct colors.
+  2. Make xjig use a non-paletted internal representation. This requires
+  touching a lot of code that has nothing to do with the image file loader,
+  so it would be more work. And then palettized images would have to be
+  converted to truecolor while loading.
+  3. Make xjig capable of using either pseudocolor or truecolor as its
+  internal representation, and let the image file loader choose which one is
+  appropriate. This would be a LOT more work.
+So I'm doing it the easy way.
+
+Actually converting an image with lots of colors to a 256-color palette is
+not "easy" if you want it to look good afterward, but that's not important
+right now. A good quantize() routine should be integrated into xjig. It would
+even be useful for GIFs, if the display doesn't have a lot of empty slots in
+its default colormap.
+
+If there is a *serious* shortage of empty slots in the default colormap,
+using a private colormap would be good, regardless of image format.
+
+The following things are no longer GIF-specific and should be renamed:
+  gif_cols
+
+In GIFs, xjig looks for command line options and other xjig-specific
+extensions embedded in the image file. This seems crazy. I'll leave open the
+possibility of implementing it in other formats, but don't hold your breath.
+
+I hate C++, so any code that I've touched will probably end up looking more
+C-like than before. This is not an accident.
+
+ppm was the first new image format I supported, because libppm (libnetpbm)
+was very easy to use. jpeg came next because libjpeg has its own quantizer,
+which is a big help. I wish I could call that quantizer independently from
+the rest of libjpeg... it would be useful for improving the ppm loader. Oh
+well, I guess #include "ppmquant.c" shouldn't be too hard to pull off. PNG
+should be the next format to be supported, but libpng's documentation is
+frightening.
+
+Autodetection of image format would be a good thing to have, but choosing a
+loader based on filename suffix is a little bit easier so I'll do it that way
+first. In any case there should be a command line option to force the use of
+a specific loader.
+
+Although I'm working with Debian's patched source, everything I'm doing
+should be applicable upstream. Slight problem: I don't know if there is a
+surviving upstream. I might be it. For better usability outside Debian, there
+should be configuration options to omit image types whose libraries are not
+present.
--- xjig-2.4.orig/base_image.H
+++ xjig-2.4/base_image.H
@@ -0,0 +1,60 @@
+#ifndef __base_image_h
+#define __base_image_h
+
+typedef unsigned char	byte;
+typedef int					boolean;
+
+#define	OPTION_EXTENSION		(0x10)
+#define	REMOVETILE_EXTENSION	(0x11)
+#define	FLATTILE_EXTENSION	(0x12)
+#define	SUBSIZE_EXTENSION		(0x13)
+#define	SCALEINFO_START		(0x20)
+#define	COMMENT_EXTENSION		(0xFE)
+
+class Image {
+	public:
+		Image( const char *filename, int autocrop=1 );
+		Image();
+		virtual ~Image();
+
+		virtual const char *GetExtensionData( unsigned char code ) { return 0; }
+
+		const char *Name()	{ return name; }
+		int Width()				{ return width; }
+		int Height()			{ return height; }
+		const byte* Data()	{ return data; }
+
+		int CropImage(int x1,int y1, int x2, int y2);
+		int CropImage();
+
+		void Rotate90();
+
+	protected:
+		virtual int LoadImageFile(const char *fname);
+		virtual int LoadImageFile(FILE *fp) {
+			/* This can only be reached if a child class fails to provide either
+			 * one of the LoadImageFile() methods. I can't figure a way of
+			 * making that a compile-time error. Think of these 2 methods as
+			 * "jointly pure virtual". */
+			fprintf(stderr,
+					  "internal error: LoadImageFile() methods missing\n");
+			exit(1);
+		}
+		void CloseImage();
+		void DefaultBackground();
+
+	protected:
+		char	*name;
+		int	width, height;								// image dimensions
+		byte	*data;										// image data
+		byte	Red[256], Green[256], Blue[256];		// Colormap-Data
+		boolean	HasColormap;
+		int		ColorMapSize;						/* number of colors */
+		int		Background;							/* background color */
+
+	public:
+		int	GetNCols()	{ return ColorMapSize; }
+		int	GetColor(int id, unsigned short *red, unsigned short *green, unsigned short *blue);
+};
+
+#endif
--- xjig-2.4.orig/fmt_image.H.stub
+++ xjig-2.4/fmt_image.H.stub
@@ -0,0 +1,26 @@
+#ifndef __fmt_image_h
+#define __fmt_image_h
+
+#include "base_image.H"
+
+class fmtImage : public Image {
+	public:
+		fmtImage( const char *filename, int autocrop=1 );
+		fmtImage();
+		~fmtImage();
+
+		/* This function may be omitted if the file format doesn't support it.
+		 * Just delete the following line and the function definition in the
+		 * corresponding .C file */
+		const char *GetExtensionData( unsigned char code );
+
+	protected:
+		/* OPTION 1: The fmt class loader takes a FILE* */
+		int LoadImageFile(FILE *fp);
+		int LoadImageFile(const char *fname) {return Image::LoadImageFile(fname);}
+
+		/* OPTION 2: The fmt class loader takes a filename */
+		/*int LoadImageFile(const char *fname);*/
+};
+
+#endif
--- xjig-2.4.orig/jpeg_image.C
+++ xjig-2.4/jpeg_image.C
@@ -0,0 +1,98 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <jpeglib.h>
+
+#include "jpeg_image.H"
+
+#undef XJIG_JPEG_DEBUG
+
+jpegImage::jpegImage(const char *filename, int autocrop )
+	: Image(filename, autocrop)
+{
+	LoadImageFile( filename );
+	if (autocrop)	CropImage();
+}
+
+/*****************************/
+int jpegImage::LoadImageFile(FILE *fp)
+/*****************************/
+{
+	struct jpeg_decompress_struct cinfo;
+	struct jpeg_error_mgr jerr;
+	int i, j, copied_lines;
+
+	cinfo.err = jpeg_std_error(&jerr);
+	jpeg_create_decompress(&cinfo);
+	jpeg_stdio_src(&cinfo, fp);
+	jpeg_read_header(&cinfo, TRUE);
+
+	/* Ask for palettized RGB output */
+	cinfo.out_color_space = JCS_RGB;
+	cinfo.quantize_colors = TRUE;
+
+	jpeg_start_decompress(&cinfo);
+
+	width=cinfo.output_width;
+	height=cinfo.output_height;
+
+#ifdef XJIG_JPEG_DEBUG
+	fprintf(stderr, "jpeg width=%d height=%d\n", width, height);
+	if(cinfo.output_components!=1) {
+		fprintf(stderr, "Not getting palettized output from libjpeg!\n");
+		exit(1);
+	}
+#endif
+
+	data=(byte *)malloc(width*height*sizeof *data);
+	if(!data) {
+		fprintf(stderr, "Not enough memory to store jpeg data");
+		exit(1);
+	}
+
+	JSAMPARRAY lines=(JSAMPARRAY)malloc(cinfo.rec_outbuf_height*sizeof *lines);
+	if(!lines) {
+		fprintf(stderr, "Not enough memory to for temporary jpeg buffer");
+		exit(1);
+	}
+	for(i=0 ; i<cinfo.rec_outbuf_height ; ++i) {
+		lines[i]=(JSAMPROW)malloc(width*sizeof *lines[i]);
+		if(!lines[i]) {
+			fprintf(stderr, "Not enough memory to for temporary jpeg buffer");
+			exit(1);
+		}
+	}
+
+	copied_lines=0;
+	while(cinfo.output_scanline < cinfo.output_height) {
+		int gotlines=jpeg_read_scanlines(&cinfo, lines, cinfo.rec_outbuf_height);
+#ifdef XJIG_JPEG_DEBUG
+		fprintf(stderr, "got %d lines from jpeg\n", gotlines);
+#endif
+		for(i=0;i<gotlines;++i)
+			for(j=0;j<width;++j)
+				data[(copied_lines+i)*width+j]=lines[i][j];
+		copied_lines+=i;
+#ifdef XJIG_JPEG_DEBUG
+		fprintf(stderr, "have now filled in %d lines of data\n", copied_lines);
+#endif
+	}
+
+	for(i=0 ; i<cinfo.rec_outbuf_height ; ++i)
+		free(lines[i]);
+	free(lines);
+
+	HasColormap=1;
+	ColorMapSize=cinfo.actual_number_of_colors;
+	for(i=0;i<ColorMapSize;++i) {
+		Red[i]   = cinfo.colormap[0][i];
+		Green[i] = cinfo.colormap[1][i];
+		Blue[i]  = cinfo.colormap[2][i];
+	}
+	Background=-1;
+
+	jpeg_finish_decompress(&cinfo);
+	jpeg_destroy_decompress(&cinfo);
+
+	return 0;
+}
--- xjig-2.4.orig/ppm_image.C
+++ xjig-2.4/ppm_image.C
@@ -0,0 +1,120 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+extern "C" {
+#include <ppm.h>
+#include <ppmcmap.h>
+}
+
+#include "ppm_image.H"
+
+#undef XJIG_PPM_DEBUG
+
+ppmImage::ppmImage(const char *filename, int autocrop )
+	: Image(filename, autocrop)
+{
+	LoadImageFile( filename );
+	if (autocrop)	CropImage();
+}
+
+/*****************************/
+int ppmImage::LoadImageFile(FILE *fp)
+/*****************************/
+{
+	pixval maxval;
+	pixel **ppmdata;
+	int ncolors, i, j;
+	colorhist_vector colors;
+	colorhash_table hash;
+	int fake_argc=1;
+	char *fake_argv[]={"xjig-ppm-loader", 0};
+
+	ppm_init(&fake_argc, fake_argv);
+	ppmdata=ppm_readppm(fp, &width, &height, &maxval);
+#ifdef XJIG_PPM_DEBUG
+	fprintf(stderr, "ppm width=%d height=%d maxval=%d\n",
+			  width, height, (int)maxval);
+#endif
+
+	/* Scale the color values up or down to 24 bits (RGB=888), which is what
+	 * the xjig core expects. */
+	if(maxval!=255)
+		for(i=0;i<height;++i)
+			for(j=0;j<width;++j)
+				PPM_DEPTH(ppmdata[i][j], ppmdata[i][j], maxval, 255);
+
+	/* Find out how many distinct colors are in the image */
+	colors=ppm_computecolorhist(ppmdata, width, height, 0, &ncolors);
+#ifdef XJIG_PPM_DEBUG
+	fprintf(stderr, "ppm ncolors=%d\n", ncolors);
+#endif
+
+	HasColormap=1;
+
+	if(ncolors>256) {
+		fprintf(stderr,
+				  "ppm image contains %d colors\n"
+				  "Stupid Color Reduction activated.\n"
+				  "For better quality, use ppmquant to reduce colors.\n",
+				  ncolors);
+
+		/* Stupid Color Reduction is an RGB=332 colormap. */
+		int r, g, b;
+		i=0;
+		for(r=0;r<8;++r)
+			for(g=0;g<8;++g)
+				for(b=0;b<4;++b) {
+					Red[i] = r*32;
+					Green[i] = g*32;
+					Blue[i] = b*64;
+					++i;
+				}
+
+		ColorMapSize=256;
+
+		data=(byte *)malloc(width*height*sizeof *data);
+		if(!data) {
+			fprintf(stderr, "Not enough memory to store ppm data");
+			exit(1);
+		}
+		for(i=0;i<height;++i)
+			for(j=0;j<width;++j) {
+				r = PPM_GETR(ppmdata[i][j]);
+				g = PPM_GETG(ppmdata[i][j]);
+				b = PPM_GETB(ppmdata[i][j]);
+				data[i*width+j]=(r & 0xe0) | ((g & 0xe0)>>3) | (b>>6);
+			}
+	} else {
+		ColorMapSize=ncolors;
+
+		hash=ppm_colorhisttocolorhash(colors, ncolors);
+		for(i=0;i<ncolors;++i) {
+			Red[i]   = PPM_GETR(colors[i].color);
+			Green[i] = PPM_GETG(colors[i].color);
+			Blue[i]  = PPM_GETB(colors[i].color);
+#ifdef XJIG_PPM_DEBUG
+			fprintf(stderr, "ppm color:%d value:%d hvalue:%d",
+					  i, colors[i].value,
+					  ppm_lookupcolor(hash, &colors[i].color));
+			fprintf(stderr, " R:%d G:%d B:%d\n",
+					  (int)Red[i], (int)Green[i], (int)Blue[i]);
+#endif
+		}
+
+		data=(byte *)malloc(width*height*sizeof *data);
+		if(!data) {
+			fprintf(stderr, "Not enough memory to store ppm data");
+			exit(1);
+		}
+		for(i=0;i<height;++i)
+			for(j=0;j<width;++j)
+				data[i*width+j]=ppm_lookupcolor(hash, &ppmdata[i][j]);
+
+		ppm_freecolorhash(hash);
+	}
+	ppm_freecolorhist(colors);
+	ppm_freearray(ppmdata, height);
+
+	DefaultBackground();
+	return 0;
+}
--- xjig-2.4.orig/ximage.C
+++ xjig-2.4/ximage.C
@@ -0,0 +1,169 @@
+
+#include "global.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmd.h>
+
+#include "ximage.H"
+#include "color_mapper.H"
+#include "gif_image.H"
+#include "ppm_image.H"
+#include "jpeg_image.H"
+
+XjigXImage::XjigXImage(class Port *port,const char *filename,int autocrop)
+: p(port) {
+	const char *suffix = strrchr(filename, '.');
+	if(suffix && (!strcasecmp(suffix, ".jpg") ||
+					  !strcasecmp(suffix, ".jpeg") ||
+					  !strcasecmp(suffix, ".jpe")))
+		img=new jpegImage(filename, autocrop);
+	else if(suffix && (!strcasecmp(suffix, ".ppm") ||
+							 !strcasecmp(suffix, ".pgm") ||
+							 !strcasecmp(suffix, ".pbm")))
+		img=new ppmImage(filename, autocrop);
+	else
+		img=new GifImage(filename, autocrop);
+	xwidth  = Width();
+	xheight = Height();
+	dpy=p->GetDisplay();
+	scr=DefaultScreen(dpy);
+	ximage = 0;
+	gif_cols=0;
+	SetupMapper();
+#ifndef RANGE_CHECK
+	offset_rows=(int)(sqrt((double)xwidth*(double)xwidth+(double)xheight*(double)xheight)/2.0)+1;
+#else
+	offset_rows=0;
+#endif
+}
+
+XjigXImage::~XjigXImage() {
+	DropData();
+	if (gif_cols)		delete [] gif_cols;
+}
+
+void XjigXImage::SetupMapper() {
+	if (gif_cols)		delete [] gif_cols;
+	SetupTrueMapper();
+}
+
+void XjigXImage::SetupTrueMapper() {
+	gif_cols=new unsigned long[GetNCols()];
+	for (int i=0;i<GetNCols();i++) {
+		XColor	def;
+		GetColor(i,&def.red,&def.green,&def.blue);
+		gif_cols[i]=p->GetMapper()->alloc_color(&def);
+	}
+}
+
+void XjigXImage::TraceMapper() {
+	for (int i=0;i<GetNCols();i++) {
+		XColor   def;
+		GetColor(i,&def.red,&def.green,&def.blue);
+		printf( "%3d: %02x %02x %02x - %ld\n", i, def.red>>8, def.green>>8, def.blue>>8, gif_cols[i] );
+	}
+}
+
+void XjigXImage::CreateData( int w, int h ) {
+	xwidth  = w;
+	xheight = h;
+#ifndef RANGE_CHECK
+	offset_rows=(int)(sqrt((double)w*(double)w+(double)h*(double)h)/2.0)+1;
+#else
+	offset_rows=0;
+#endif
+	DropData();
+	switch(texture_mode) {
+	case 1:		Reset8();		break;
+	case 2:		Reset16();		break;
+	case 3:		Reset32();		break;
+	default:		fprintf( stderr, "depth not supported\n" );
+					exit(0);
+	}
+}
+
+void XjigXImage::DropData() {
+	if (ximage) {
+		delete [] (ximage->data-offset_bytes);
+		ximage->data = 0L;
+		XDestroyImage(ximage);
+		ximage=0;
+	}
+}
+
+unsigned long XjigXImage::GetPixel(int x, int y) {
+	if (x<0||x>=xwidth||y<0||y>=xheight) {
+		return 0;
+	}
+	else {
+		return XGetPixel(ximage,x,y);
+	}
+}
+
+/*----------------------------------------------------------------------------*/
+#define	DATA_TYPE	CARD32
+#define	DATA_PAD		4
+void XjigXImage::Reset32() {
+#	include "reset_image.H"
+}
+#undef DATA_TYPE
+#undef DATA_PAD
+/*----------------------------------------------------------------------------*/
+#define	DATA_TYPE	CARD16
+#define	DATA_PAD		2
+void XjigXImage::Reset16() {
+#	include "reset_image.H"
+}
+#undef DATA_TYPE
+#undef DATA_PAD
+/*----------------------------------------------------------------------------*/
+#define	DATA_TYPE	CARD8
+#define	DATA_PAD		1
+void XjigXImage::Reset8() {
+#	include "reset_image.H"
+}
+#undef DATA_TYPE
+#undef DATA_PAD
+
+// ========================================================================
+
+XjigPixmap::XjigPixmap( Port *port, const char *filename, int autocrop )
+: XjigXImage(port,filename,autocrop) {
+int w, h;
+
+	pixmap=0;
+
+	const char	*ext=GetExtensionData( SUBSIZE_EXTENSION );
+
+	if (ext&&sscanf( ext, "%dx%d", &w, &h)==2) {
+		xmult=XjigXImage::Width()/w;
+		ymult=XjigXImage::Height()/h;
+	}
+	else {
+		xmult=1;
+		ymult=1;
+	}
+}
+
+XjigPixmap::~XjigPixmap() {
+	if (pixmap)		XFreePixmap(dpy,pixmap);
+}
+
+Pixmap XjigPixmap::GetPixmap() {
+	if (!pixmap) {
+		pixmap=XCreatePixmap(dpy,RootWindow(dpy,scr),xwidth,xheight,DefaultDepth(dpy,scr));
+		XPutImage(dpy,pixmap,DefaultGC(dpy,scr),GetImage(),0,0,0,0,xwidth,xheight);
+	}
+	return pixmap;
+}
+
+void XjigPixmap::CreateData(int w,int h) {
+	w*=xmult;
+	h*=ymult;
+	if (pixmap)		{ XFreePixmap(dpy,pixmap); pixmap=0; }
+	XjigXImage::CreateData(w,h);
+}
--- xjig-2.4.orig/base_image.C
+++ xjig-2.4/base_image.C
@@ -0,0 +1,239 @@
+/* This file was split off from gif_image.C; look there for the impressive
+   pedigree. */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "base_image.H"
+
+#define	False	0
+#define	True	1
+#define	DEBUG	0
+
+#define	minpix			10
+
+Image::Image(const char *filename, int autocrop )
+{
+	name = strrchr(filename,'/');
+	if (name)	name=strdup(name+1);
+	else			name=strdup(filename);
+
+   /*can't call virtual from constructor, so child class will have to do this:*/
+	/*LoadImageFile( filename );*/
+
+	/*this depends on the image being loaded, so child class has to do it too:*/
+	/*if (autocrop&&!fastinfo_flag)	CropImage();*/
+}
+
+Image::Image() {
+	name=strdup("dummy");
+	ColorMapSize=128;
+	for (int i=0;i<128;i++) {
+		Red[i]   = 255 * ((i>>5)&0x03) / 3;
+		Green[i] = 255 * ((i>>2)&0x07) / 7;
+		Blue[i]  = 255 *      (i&0x03) / 3;
+	}
+	width =1;
+	height=1;
+	data  =(byte*)malloc(1);
+}
+
+Image::~Image() {
+	free(name);
+	CloseImage();
+}
+
+int Image::GetColor(int id, unsigned short *red, unsigned short *green, unsigned short *blue) {
+	*red  =Red[id]   | Red[id]<<8;
+	*green=Green[id] | Green[id]<<8;
+	*blue =Blue[id]  | Blue[id]<<8;
+	return 0;
+}
+
+void Image::Rotate90() {
+byte	*ndata;
+int	help;
+
+	if (!(ndata = (byte *)malloc(width*height))) {
+		fprintf(stderr,"not enough memory to flip image");
+		exit(-1);
+	}
+
+	for (int y=0;y<height;y++) {
+		for (int x=0;x<width;x++) {
+			ndata[(height-y-1)+x*height] = data[x+y*width];
+		}
+	}
+
+	help=width; width=height; height=help;
+	free(data);
+	data=ndata;
+}
+
+int Image::LoadImageFile(const char *fname)
+{
+	int ret;
+	FILE *fp;
+
+	fp = fopen(fname,"rb");
+
+	if (!fp) {
+			fprintf(stderr,"'%s': File not found\n", fname);
+			exit(0);
+	}
+
+	ret = LoadImageFile(fp);
+
+	fclose(fp);
+	return ret;
+}
+
+int Image::CropImage(int x1,int y1, int x2, int y2) {
+int	w = x2-x1;
+int	h = y2-y1;
+
+	if (x1<0 || x2>width  || w<0 || y1<0 || y2>height || h<0) {
+		fprintf(stderr,"unable to crop (%d,%d)-(%d,%d)\n", x1,y1,x2,y2);
+		fprintf(stderr,"image size: %dx%d\n", width, height );
+		exit(-1);
+	}
+
+	for (int i=0;i<h;i++) {
+			memmove(data+i*w,data+(i+y1)*Width()+x1,w);
+	}
+	width  = w;
+	height = h;
+	return 0;
+}
+
+int Image::CropImage() {
+int		i,j;
+int		b;
+int		x1,x2,y1,y2;
+byte		*ptr;
+long		d;
+
+	b=*data;
+	d=0x7fffffff;
+	for (i=0;i<256;i++) {
+			if (Red[i]+Green[i]+Blue[i]<d) {
+					b=i;
+					d=Red[i]+Green[i]+Blue[i];
+			}
+	}
+	x1=-1; x2=Width();
+	y1=-1; y2=Height();
+	for (i=0; i<Height(); i++) {
+			int		flag[256];
+			int		count=0;
+			ptr = data + (i*Width());
+			for (j=0;j<256;j++)		flag[j]=0;
+		for (j=0; j<Width(); j++,ptr++) {
+				if (!flag[*ptr]) {
+						flag[*ptr]++;
+						if (++count>=minpix)		break;
+				}
+		}
+		if (count>=minpix)		break;
+		y1=i;
+	}
+	for (i=Height()-1;i>=0; i--) {
+			int		flag[256];
+			int		count=0;
+			ptr = data + (i*Width());
+			for (j=0;j<256;j++)		flag[j]=0;
+		for (j=0; j<Width(); j++,ptr++) {
+				if (!flag[*ptr]) {
+						flag[*ptr]++;
+						if (++count>=minpix)		break;
+				}
+		}
+		if (count>=minpix)		break;
+		y2=i;
+	}
+
+	for (i=0; i<Width(); i++) {
+			int		flag[256];
+			int		count=0;
+			ptr = data + i;
+			for (j=0;j<256;j++)		flag[j]=0;
+		for (j=0; j<Height(); j++,ptr+=Width()) {
+				if (!flag[*ptr]) {
+						flag[*ptr]++;
+						if (++count>=minpix)		break;
+				}
+		}
+		if (count>=minpix)		break;
+		x1=i;
+	}
+	for (i=Width()-1;i>=0;i--) {
+			int		flag[256];
+			int		count=0;
+			ptr = data + i;
+			for (j=0;j<256;j++)		flag[j]=0;
+		for (j=0; j<Height(); j++,ptr+=Width()) {
+				if (!flag[*ptr]) {
+						flag[*ptr]++;
+						if (++count>=minpix)		break;
+				}
+		}
+		if (count>=minpix)		break;
+		x2=i;
+	}
+
+	x1++; x2--; y1++; y2--;
+	if (x2<=x1||y2<=y1)				return 1;
+
+	CropImage(x1,y1,x2,y2);
+	return 0;
+}
+
+
+void Image::CloseImage()
+{
+#if (0)
+	if (LocalCmap)
+	{
+		XFreeColormap(theDisp, LocalCmap);
+		LocalCmap=0;
+	}  
+	else
+	{
+		int i,j;
+		unsigned long pixels[256];
+		 
+		for (j=i=0;i<ColorMapSize;i++)
+			if (used[i]==ALLOCATED)
+				pixels[j++]=cols[i];
+		XFreeColors(theDisp, theCmap, pixels, j, 0L);
+	}
+#endif
+	if (data)
+	{
+		free(data);
+		data=NULL;
+	}
+}
+
+void Image::DefaultBackground()
+{
+	int darkest=255*255*3+1;
+	int i;
+	for(i=0;i<ColorMapSize;++i) {
+		int s;
+		s=Red[i]*Red[i]+Green[i]*Green[i]+Blue[i]*Blue[i];
+		if(s<darkest) {
+			darkest=s;
+			Background=i;
+		}
+	}
+
+	/* Add a black pixel for background, if there was no black in the image
+	 * and there's a free slot in the palette. */
+	if(darkest>0 && i<256) {
+		Red[i]=Green[i]=Blue[i]=0;
+		Background=i;
+		++ColorMapSize;
+	}
+}
--- xjig-2.4.orig/fmt_image.C.stub
+++ xjig-2.4/fmt_image.C.stub
@@ -0,0 +1,70 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "fmt_image.H"
+
+fmtImage::fmtImage(const char *filename, int autocrop )
+	: Image(filename, autocrop)
+{
+	LoadImageFile( filename );
+	if (autocrop)	CropImage();
+}
+
+fmtImage::fmtImage() {
+	/*nothing*/
+}
+
+fmtImage::~fmtImage() {
+	/*nothing*/
+}
+
+/* This function may be omitted if the file format doesn't support it. Just
+ * delete the following line and the prototype in the corresponding .H file. */
+const char *fmtImage::GetExtensionData( unsigned char code ) { return 0; }
+
+
+/*
+   LoadImageFile must fill in the following fields:
+		int	width, height;								// image dimensions
+		byte	*data;										// image data
+		byte	Red[256], Green[256], Blue[256];		// Colormap-Data
+		boolean	HasColormap;
+		int		ColorMapSize;						// number of colors
+		int		Background;							// background color
+	The data is one byte per pixel, the bytes index the Red[], Green[], and
+	Blue[] arrays, so you have 24-bit color with an 8-bit palette. If the
+	image format contains more than 256 distinct colors, LoadImageFile must
+	quantize it down to 256. You must malloc the data, but don't worry about
+	freeing it. The superclass will take care of that.
+
+	If there are any errors opening the file or decoding the image, the best
+	that can be done is to print an error message to stderr and exit().
+
+	I'm not sure what the HasColormap field is for. In the GIF loader, it
+	might end up as 0 depending on the file headers. What kind of GIF doesn't
+	have a palette? Fortunately nothing outside the GIF loader uses it. I
+	decree that it shall be set to 1 by all loaders until I figure out what
+	it's good for.
+
+	The Background field isn't used either, but it's probably a good idea to
+	set it. If your image file doesn't have a "background" color, call
+	DefaultBackground() after you've filled in all the other fields and one
+	will be chosen for you.
+
+	The return value is also not used anywhere, but to be consistent with the
+	GIF loader you should return 0 to indicate success.
+
+	If you prefer to open and close the image file yourself, you can take a
+	const char *filename arg instead of FILE *fp. If you take the FILE *fp
+	arg, all you have to do is read from it.
+
+	Obviously, there is room for improvement in the interface.
+ */
+/*****************************/
+int fmtImage::LoadImageFile(FILE *fp)
+/*****************************/
+{
+	fprintf(stderr, "This file format is just a stub!\n");
+	exit(1);
+}
--- xjig-2.4.orig/jpeg_image.H
+++ xjig-2.4/jpeg_image.H
@@ -0,0 +1,15 @@
+#ifndef __jpeg_image_h
+#define __jpeg_image_h
+
+#include "base_image.H"
+
+class jpegImage : public Image {
+	public:
+		jpegImage( const char *filename, int autocrop=1 );
+
+	protected:
+		int LoadImageFile(FILE *fp);
+		int LoadImageFile(const char *fname) {return Image::LoadImageFile(fname);}
+};
+
+#endif
--- xjig-2.4.orig/ppm_image.H
+++ xjig-2.4/ppm_image.H
@@ -0,0 +1,15 @@
+#ifndef __ppm_image_h
+#define __ppm_image_h
+
+#include "base_image.H"
+
+class ppmImage : public Image {
+	public:
+		ppmImage( const char *filename, int autocrop=1 );
+
+	protected:
+		int LoadImageFile(FILE *fp);
+		int LoadImageFile(const char *fname) {return Image::LoadImageFile(fname);}
+};
+
+#endif
--- xjig-2.4.orig/ximage.H
+++ xjig-2.4/ximage.H
@@ -0,0 +1,84 @@
+#ifndef __ximage_h
+#define __ximage_h
+
+#include "base_image.H"
+
+class XjigXImage {
+	public:
+		XjigXImage( class Port *port, const char *filename, int autocrop=0);
+		~XjigXImage();
+
+	// Size Information
+		int   XWidth()							{  return xwidth; }
+		int   XHeight()						{  return xheight; }
+		void GetXSize( int *w, int *h )	{ *w=xwidth; *h=xheight; }
+
+		void CreateData( int w, int h );
+		void SetupMapper();
+		void SetupTrueMapper();
+		void TraceMapper();
+
+		XImage *GetImage() {
+			if (!ximage)		CreateData(xwidth,xheight);
+			return ximage;
+		}
+		unsigned long GetPixel( int x, int y );
+
+	public:
+		void DropData();
+		void Reset8();
+		void Reset16();
+		void Reset32();
+
+		Display	*dpy;
+		int		scr;
+
+		XImage	*ximage;
+		int		xwidth, xheight;
+		int		offset_rows;		// rows befor and ahead of the image
+		int		offset_bytes;		// to prevent overwrite when optimized
+
+		unsigned long		*gif_cols;
+		class Port			*p;
+
+		/* Can't inherit Image because it has a pure virtual function and
+		 * XjigXImage needs to be instantiated. So instead, let it contain a
+		 * pointer to one and forward all the necessary methods. */
+		Image *img;
+		int Width()				{ return img->Width(); }
+		int Height()			{ return img->Height(); }
+		const char *GetExtensionData( unsigned char code )
+			{ return img->GetExtensionData(code); }
+		int CropImage(int x1,int y1, int x2, int y2)
+			{ return img->CropImage(x1,y1,x2,y2); }
+		int CropImage() { return img->CropImage(); }
+		void Rotate90() { img->Rotate90(); }
+		int	GetNCols()	{ return img->GetNCols(); }
+		int	GetColor(int id, unsigned short *red,
+							unsigned short *green, unsigned short *blue)
+			{ return img->GetColor(id, red, green, blue); }
+		const byte* Data()	{ return img->Data(); }
+};
+
+class XjigPixmap : public XjigXImage {
+	public:
+		XjigPixmap( class Port *port, const char *filename, int autocrop=0);
+		~XjigPixmap();
+
+		Pixmap	GetPixmap();
+		void CreateData( int w, int h );
+
+		int		Width()	{ return XjigXImage::Width()/xmult; }
+		int		Height()	{ return XjigXImage::Height()/ymult; }
+		int		XWidth()	{ return XjigXImage::XWidth()/xmult; }
+		int		XHeight()	{ return XjigXImage::XHeight()/ymult; }
+
+		int		IsTwinPixmap()		{ return ymult==2; }
+
+	private:
+		Pixmap	pixmap;
+
+		int		xmult,ymult;
+};
+
+#endif
--- xjig-2.4.orig/Makefile
+++ xjig-2.4/Makefile
@@ -0,0 +1,1554 @@
+# Makefile generated by imake - do not edit!
+# $Xorg: imake.c,v 1.6 2001/02/09 02:03:15 xorgcvs Exp $
+
+# ----------------------------------------------------------------------
+# Makefile generated from "Imake.tmpl" and <Imakefile>
+# $Xorg: Imake.tmpl,v 1.4 2000/08/17 19:41:46 cpqbld Exp $
+# $XdotOrg: xc/config/cf/Imake.tmpl,v 1.6 2004/07/28 03:24:29 gisburn Exp $
+#
+#
+#
+#
+# $XFree86: xc/config/cf/Imake.tmpl,v 3.155 2003/12/24 18:58:41 dickey Exp $
+# ----------------------------------------------------------------------
+
+all::
+
+.SUFFIXES: .i
+
+# $XdotOrg: xc/config/cf/Imake.cf,v 1.4 2004/08/11 21:14:01 kem Exp $
+# $Xorg: Imake.cf,v 1.4 2000/08/17 19:41:45 cpqbld Exp $
+
+# $XFree86: xc/config/cf/Imake.cf,v 3.88 2003/12/16 21:30:21 herrb Exp $
+
+# Keep cpp from replacing path elements containing i486/i586/i686
+
+# -----------------------------------------------------------------------
+# site-specific configuration parameters that need to come before
+# the platform-specific parameters - edit site.def to change
+
+# site:  $TOG: site.sample /main/r64_final/1 1998/02/05 16:28:49 kaleb $
+
+# site:  $XFree86: xc/config/cf/site.def,v 3.24 2000/06/25 20:17:29 dawes Exp $
+
+# $XFree86: xc/config/cf/xf86site.def,v 3.186 2003/06/25 18:06:22 eich Exp $
+
+# ----------------------------------------------------------------------
+# platform-specific configuration parameters - edit linux.cf to change
+
+# $XdotOrg: xc/config/cf/linux.cf,v 1.13 2004/08/11 21:14:01 kem Exp $
+# platform:  $Xorg: linux.cf,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
+
+# platform:  $XFree86: xc/config/cf/linux.cf,v 3.220 2003/12/30 22:38:33 tsi Exp $
+
+# operating system:  Linux 2.6.15-1-686 i686 [ELF] (2.6.15)
+# libc:	(6.3.5)
+# binutils:	(216)
+
+# $Xorg: lnxLib.rules,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
+# $XFree86: xc/config/cf/lnxLib.rules,v 3.52 2003/10/31 20:49:03 herrb Exp $
+
+# $XdotOrg: xc/config/cf/xorg.cf,v 1.27.2.6 2005/01/24 03:11:42 gisburn Exp $
+
+# $Xorg: xfree86.cf,v 1.4 2000/08/17 19:41:49 cpqbld Exp $
+
+XORG_VERSION_CURRENT = (((6) * 10000000) + ((8) * 100000) + ((2) * 1000) + 0)
+RELEASE_VERSION = RELEASE-1
+
+AFB_DEFS = -DUSE_AFB
+
+DRIVERSDKDIR = $(USRLIBDIR)/Server
+DRIVERSDKMODULEDIR = $(USRLIBDIR)/Server/modules
+DRIVERSDKINCLUDEDIR = $(USRLIBDIR)/Server/include
+
+       XF86SRC = $(SERVERSRC)/hw/xfree86
+    XF86COMSRC = $(XF86SRC)/common
+ XF86PARSERSRC = $(XF86SRC)/parser
+     XF86OSSRC = $(XF86SRC)/os-support
+ XF86DRIVERSRC = $(XF86SRC)/drivers
+     DRIVERSRC = $(XF86DRIVERSRC)
+
+        XFREE86DOCDIR = $(DOCDIR)
+      XFREE86PSDOCDIR = $(DOCPSDIR)
+     XFREE86PDFDOCDIR = $(DOCPDFDIR)
+    XFREE86HTMLDOCDIR = $(DOCHTMLDIR)
+XFREE86JAPANESEDOCDIR = $(DOCDIR)/Japanese
+
+# $Xorg: xf86.rules,v 1.3 2000/08/17 19:41:48 cpqbld Exp $
+
+# $XFree86: xc/config/cf/xf86.rules,v 3.34tsi Exp $
+
+   SELINUX_LDFLAGS =
+
+   SELINUX_INCLUDES = -I/usr/include/selinux
+
+   SELINUX_CFLAGS =  -DHAVE_SELINUX
+
+   SELINUX_LIBS = -lselinux
+
+# ----------------------------------------------------------------------
+# site-specific configuration parameters that go after
+# the platform-specific parameters - edit site.def to change
+
+# site:  $TOG: site.sample /main/r64_final/1 1998/02/05 16:28:49 kaleb $
+
+# site:  $XFree86: xc/config/cf/site.def,v 3.24 2000/06/25 20:17:29 dawes Exp $
+
+# ---------------------------------------------------------------------
+# Imake rules for building libraries, programs, scripts, and data files
+# rules:  $Xorg: Imake.rules,v 1.3 2000/08/17 19:41:46 cpqbld Exp $
+# rules:  $XdotOrg: xc/config/cf/Imake.rules,v 1.6 2004/08/13 17:21:43 krh Exp $
+#
+#
+#
+#
+# rules:  $XFree86: xc/config/cf/Imake.rules,v 3.128 2003/11/15 03:25:17 dawes Exp $
+
+.PHONY: all interfaces install install.man install.lib install.sdk 	depend includes cleandir
+
+ _NULLCMD_ = @ echo -n
+
+X_BYTE_ORDER = X_LITTLE_ENDIAN
+
+GLIDE2INCDIR = /usr/include/glide
+
+GLIDE3INCDIR = /usr/include/glide3
+
+GLIDE3LIBNAME = glide3
+
+TKLIBNAME = tk8.4
+
+TKLIBDIR = /usr/lib
+
+TCLLIBNAME = tcl8.4
+
+TCLIBDIR = /usr/lib
+
+          PATHSEP = /
+            SHELL = /bin/sh -e
+
+              TOP = .
+      CURRENT_DIR = .
+
+            IMAKE = imake
+           DEPEND = gccmakedep
+        MKDIRHIER = mkdir -p
+          REVPATH = revpath
+    EXPORTLISTGEN =
+             RMAN = /usr/bin/rman
+     RMANBASENAME = rman
+      RMANOPTIONS =
+        CONFIGSRC = $(TOP)/config
+         IMAKESRC = $(CONFIGSRC)/imake
+        DEPENDSRC = $(CONFIGSRC)/util
+
+          INCROOT = /usr/X11R6/include
+        USRLIBDIR = /usr/X11R6/lib
+           VARDIR = /var
+        VARLIBDIR = $(VARDIR)/lib
+  SYSTEMUSRLIBDIR = /usr/lib
+  SYSTEMUSRINCDIR = /usr/include
+         SHLIBDIR = /usr/X11R6/lib
+       LINTLIBDIR = $(USRLIBDIR)/lint
+          MANPATH = /usr/X11R6/man
+    MANSOURCEPATH = $(MANPATH)/man
+           MANDIR = $(MANSOURCEPATH)$(MANSECT)
+    SYSCALLMANDIR = $(MANSOURCEPATH)$(SYSCALLMANSECT)
+        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSECT)
+     DRIVERMANDIR = $(MANSOURCEPATH)4
+       FILEMANDIR = $(MANSOURCEPATH)$(FILEMANSECT)
+       GAMEMANDIR = $(MANSOURCEPATH)$(GAMEMANSECT)
+       MISCMANDIR = $(MANSOURCEPATH)7
+        ADMMANDIR = $(MANSOURCEPATH)$(ADMMANSECT)
+	  ICONDIR = /usr/X11R6/lib/X11/icons
+      XCURSORPATH = ~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons
+     DRIVERMANDIR = $(MANSOURCEPATH)4
+     LOGDIRECTORY = $(VARDIR)/log
+
+        VARRUNDIR = $(VARDIR)/run
+
+         VARDBDIR = $(VARDIR)/lib
+
+               AR = ar clq
+
+# Nice try but useless: make will inherit BOOTSTRAPCFLAGS
+# from  top Makefile
+  BOOTSTRAPCFLAGS =
+
+               CC = gcc -m32
+               AS = gcc -m32 -c -x assembler
+
+.SUFFIXES: .cc
+
+              CXX = c++ -m32
+
+          CXXFILT = c++filt
+
+           CXXLIB = -lstdc++
+
+    CXXDEBUGFLAGS = -g -O2 -fno-strict-aliasing
+CXXDEPENDINCLUDES =
+ CXXEXTRA_DEFINES =
+CXXEXTRA_INCLUDES =
+   CXXSTD_DEFINES = -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 				-D_POSIX_SOURCE -D_XOPEN_SOURCE 				-D_BSD_SOURCE -D_SVID_SOURCE 				  				 $(CXXPROJECT_DEFINES)
+       CXXOPTIONS =
+      CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES)
+       CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(DEFINES) $(CXXEXTRA_DEFINES)
+         CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES)
+
+         COMPRESS = compress
+          GZIPCMD = gzip
+
+              CPP = cpp $(STD_CPP_DEFINES)
+           RAWCPP = cpp -undef $(STD_CPP_OPTIONS)
+    PREPROCESSCMD = gcc -m32 -E $(STD_CPP_DEFINES)
+
+          INSTALL = install
+     INSTALLFLAGS = -c
+
+               LD = gcc -m32 -nostdlib
+
+              LEX = flex -l
+               M4 = m4
+          M4FLAGS =
+           LEXLIB = -lfl
+             YACC = bison -y
+           CCYACC = bison -y
+
+             LINT = lint
+
+      LINTLIBFLAG = -C
+         LINTOPTS = -axz
+               LN = ln -s
+             MAKE = make
+               MV = mv -f
+               CP = cp
+
+           RANLIB = ranlib
+
+  RANLIBINSTFLAGS =
+
+               RM = rm -f
+             PERL = perl
+         PERLOPTS =
+     PERLENVSETUP = env LC_ALL=C
+
+          MANSECT = 1
+   SYSCALLMANSECT = 2
+       LIBMANSECT = 3
+    DRIVERMANSECT = 4
+      FILEMANSECT = 5
+      GAMEMANSECT = 6
+      MISCMANSECT = 7
+       ADMMANSECT = 8
+       MANSRCSECT = s
+       MANNEWSECT = n
+ PROJECTMANSUFFIX = x
+        MANSUFFIX = $(MANSECT)$(PROJECTMANSUFFIX)
+ SYSCALLMANSUFFIX = $(SYSCALLMANSECT)$(PROJECTMANSUFFIX)
+     LIBMANSUFFIX = $(LIBMANSECT)$(PROJECTMANSUFFIX)
+  DRIVERMANSUFFIX = 4x
+    FILEMANSUFFIX = $(FILEMANSECT)$(PROJECTMANSUFFIX)
+    GAMEMANSUFFIX = $(GAMEMANSECT)$(PROJECTMANSUFFIX)
+    MISCMANSUFFIX = 7x
+     ADMMANSUFFIX = $(ADMMANSECT)$(PROJECTMANSUFFIX)
+   ADMINMANSUFFIX = 8
+     MANSRCSUFFIX = man
+     MANNEWSUFFIX = _man
+          MANDEFS = -D__apploaddir__=$(XAPPLOADDIR) -D__filemansuffix__=$(FILEMANSECT)$(PROJECTMANSUFFIX) -D__osfilemansuffix__=$(FILEMANSECT) -D__libmansuffix__=$(LIBMANSECT)$(PROJECTMANSUFFIX) -D__oslibmansuffix__=$(LIBMANSECT) -D__mansuffix__=$(MANSECT)$(PROJECTMANSUFFIX) -D__osmansuffix__=$(MANSECT) -D__syscallmansuffix__=$(SYSCALLMANSECT)$(PROJECTMANSUFFIX) -D__ossysmansuffix__=$(SYSCALLMANSECT) -D__gamemansuffix__=$(GAMEMANSECT)$(PROJECTMANSUFFIX) -D__osgamemansuffix__=$(GAMEMANSECT) -D__miscmansuffix__=$(MISCMANSECT)$(PROJECTMANSUFFIX) -D__osmiscmansuffix__=$(MISCMANSECT) -D__admmansuffix__=$(ADMMANSECT)$(PROJECTMANSUFFIX) -D__osadmmansuffix__=$(ADMMANSECT) -D__miscmansuffix__=$(MISCMANSECT)$(PROJECTMANSUFFIX) -D__osmiscmansuffix__=$(MISCMANSECT) -D__drivermansuffix__=$(DRIVERMANSECT)$(PROJECTMANSUFFIX) -D__osdrivermansuffix__=$(DRIVERMANSECT) -D__adminmansuffix__=$(ADMINMANSUFFIX) -D__projectroot__=$(PROJECTROOT) -D__xconfigfile__=$(XCONFIGFILE) -D__xconfigdir__=$(XCONFIGDIR) -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) -D__appmansuffix__=$(MANSECT)$(PROJECTMANSUFFIX) $(XORGMANDEFS) $(VENDORMANDEFS)
+
+   COMPRESSMANCMD = gzip -n
+
+            TROFF = groff -Tps
+            NROFF = nroff
+
+         HTMLROFF = groff -Thtml
+
+         MSMACROS = -ms
+        MANMACROS = -man
+              TBL = tbl
+              EQN = eqn
+             NEQN = neqn
+              COL = col
+         COLFLAGS = -b
+
+            MODCC = gcc -m32
+
+           MODCPP = cpp
+        MODCFLAGS = $(CFLAGS)
+            MODAS = gcc -m32 -c -x assembler
+       MODASFLAGS =
+
+            MODLD = gcc -m32 -nostdlib
+
+       MODLDFLAGS =
+MODLDCOMBINEFLAGS = -r
+            MODAR = ar clq
+
+        MODRANLIB = ranlib
+
+            DVIPS = dvips
+            LATEX = latex
+
+     STD_INCLUDES =
+  STD_CPP_OPTIONS = -traditional
+  STD_CPP_DEFINES = -traditional -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 				-D_POSIX_SOURCE -D_XOPEN_SOURCE 				-D_BSD_SOURCE -D_SVID_SOURCE 				  				 $(PROJECT_DEFINES)
+      STD_DEFINES = -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 				-D_POSIX_SOURCE -D_XOPEN_SOURCE 				-D_BSD_SOURCE -D_SVID_SOURCE 				  				 $(PROJECT_DEFINES)
+ EXTRA_LOAD_FLAGS =
+  EXTRA_LDOPTIONS =
+  EXTRA_LIBRARIES =
+             TAGS = ctags
+
+   PARALLELMFLAGS =
+
+    SHAREDCODEDEF =
+         SHLIBDEF =
+
+     SHLIBLDFLAGS = -shared $(SHLIBGLOBALSFLAGS)
+
+         PICFLAGS = -fPIC
+
+      CXXPICFLAGS = -fPIC
+
+    PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO
+
+     INSTPGMFLAGS =
+
+     INSTBINFLAGS = -m 0755
+     INSTUIDFLAGS = -m 4711
+     INSTLIBFLAGS = -m 0644
+     INSTINCFLAGS = -m 0444
+     INSTMANFLAGS = -m 0444
+     INSTDATFLAGS = -m 0444
+    INSTKMEMFLAGS = -m 4711
+
+      PROJECTROOT = /usr/X11R6
+
+      CDEBUGFLAGS = -g -O2 -fno-strict-aliasing
+        CCOPTIONS =
+
+      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(INSTALLED_INCLUDES) $(STD_INCLUDES)
+       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(MODULE_DEFINES) $(DEFINES) $(EXTRA_DEFINES)
+           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(MODULE_CFLAGS) $(ALLDEFINES)
+        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
+         LDPRELIB = -L$(USRLIBDIR) $(INSTALLED_LIBS)
+        LDPOSTLIB =
+        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)  $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
+     CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
+
+           LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
+
+           CCLINK = $(CC)
+
+          CXXLINK = $(CXX)
+
+     LDSTRIPFLAGS = -x
+   LDCOMBINEFLAGS = -r
+      DEPENDFLAGS =
+   DEPEND_DEFINES =
+
+# Not sure this belongs here
+         TKLIBDIR = /usr/lib
+         TKINCDIR = /usr/include
+        TKLIBNAME = tk8.4
+        TKLIBRARY = -L$(TKLIBDIR) -l$(TKLIBNAME)
+        TCLLIBDIR = /usr/lib
+        TCLINCDIR = /usr/include
+       TCLLIBNAME = tcl8.4
+       TCLLIBRARY = -L$(TCLLIBDIR) -l$(TCLLIBNAME)
+
+        MACROFILE = linux.cf
+           RM_CMD = $(RM)
+
+    IMAKE_DEFINES =
+   IMAKE_WARNINGS = -Wundef
+
+         IRULESRC = $(CONFIGDIR)
+        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) 		    $(IMAKE_WARNINGS)
+
+     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/X11.tmpl 			$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) 			$(IRULESRC)/xfree86.cf $(IRULESRC)/xf86.rules $(IRULESRC)/xorgsite.def $(IRULESRC)/host.def $(EXTRA_ICONFIGFILES)
+
+# $Xorg: X11.rules,v 1.4 2000/08/17 19:41:46 cpqbld Exp $
+
+# $XFree86: xc/config/cf/X11.rules,v 1.6 2001/01/17 16:22:31 dawes Exp $
+
+# ----------------------------------------------------------------------
+# X Window System Build Parameters and Rules
+# $XdotOrg: xc/config/cf/X11.tmpl,v 1.35.2.3 2005/02/01 04:07:39 gisburn Exp $
+# $Xorg: X11.tmpl,v 1.6 2000/08/17 19:41:46 cpqbld Exp $
+#
+#
+#
+#
+# $XFree86: xc/config/cf/X11.tmpl,v 1.248 2004/02/16 04:07:37 dawes Exp $
+
+XORGRELSTRING = `echo 6 8 2 | sed 's/ /./g'`
+  XORGMANNAME = X Version 11
+
+STICKY_DEFINES = -DHAS_STICKY_DIR_BIT
+
+FCHOWN_DEFINES = -DHAS_FCHOWN
+
+# -----------------------------------------------------------------------
+# X Window System make variables; these need to be coordinated with rules
+
+             XTOP = $(TOP)
+           BINDIR = /usr/X11R6/bin
+     BUILDINCROOT = $(TOP)/exports
+      BUILDINCDIR = $(BUILDINCROOT)/include
+      BUILDINCTOP = ../..
+      BUILDLIBDIR = $(TOP)/exports/lib
+      BUILDLIBTOP = ../..
+      BUILDBINDIR = $(TOP)/exports/bin
+      BUILDBINTOP = ../..
+   BUILDMODULEDIR = $(BUILDLIBDIR)/modules
+     BUILDI18NDIR = $(BUILDLIBDIR)/locale
+   BUILDMODULETOP = $(BUILDLIBTOP)/..
+    XBUILDINCROOT = $(XTOP)/exports
+     XBUILDINCDIR = $(XBUILDINCROOT)/include/X11
+     XBUILDINCTOP = ../../..
+     XBUILDBINDIR = $(XBUILDINCROOT)/bin
+           INCDIR = $(INCROOT)
+           ADMDIR = /usr/adm
+           LIBDIR = /usr/X11R6/lib/X11
+       LIBEXECDIR = /usr/X11R6/libexec
+        MODULEDIR = $(USRLIBDIR)/modules
+   TOP_X_INCLUDES =
+          XBINDIR = $(PROJECTROOT)/bin
+
+       INSTSRCDIR = /usr/X11R6/src
+
+        ETCX11DIR = /etc/X11
+
+          CONFDIR = $(ETCX11DIR)
+
+           DOCDIR = $(LIBDIR)/doc
+       DOCHTMLDIR = $(DOCDIR)/html
+         DOCPSDIR = $(DOCDIR)/PostScript
+        DOCPDFDIR = $(DOCDIR)/PDF
+          FONTDIR = $(LIBDIR)/fonts
+     ENCODINGSDIR = $(FONTDIR)/encodings
+         XINITDIR = $(LIBDIR)/xinit
+           XDMDIR = $(LIBDIR)/xdm
+        XDMVARDIR = $(VARLIBDIR)/xdm
+           TWMDIR = $(LIBDIR)/twm
+           XSMDIR = $(LIBDIR)/xsm
+           NLSDIR = $(LIBDIR)/nls
+       XLOCALEDIR = $(LIBDIR)/locale
+      LBXPROXYDIR = $(LIBDIR)/lbxproxy
+  PROXYMANAGERDIR = $(LIBDIR)/proxymngr
+        XPRINTDIR = $(LIBDIR)/xserver
+      XAPPLOADDIR = /etc/X11/app-defaults
+       FONTCFLAGS = -t
+
+     INSTAPPFLAGS = $(INSTDATFLAGS)
+
+              RGB = $(XBINDIR)/rgb
+            FONTC = $(XBINDIR)/bdftopcf
+      MKFONTSCALE = $(XBINDIR)/mkfontscale
+        MKFONTDIR = $(XBINDIR)/mkfontdir
+      MKHTMLINDEX = $(XBINDIR)/mkhtmlindex
+          UCS2ANY = $(XBINDIR)/ucs2any
+      BDFTRUNCATE = $(XBINDIR)/bdftruncate
+     UCSMAPPREFIX = $(FONTDIR)/util/map-
+       XCURSORGEN = $(XBINDIR)/xcursorgen
+
+     HTMLINDEXCMD = HtmlIndexCmd
+
+       DOCUTILSRC = $(XTOP)/doc/util
+        CLIENTSRC = $(TOP)/clients
+          DEMOSRC = $(TOP)/demos
+       XDOCMACROS = $(DOCUTILSRC)/macros.t
+       XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
+       PROGRAMSRC = $(TOP)/programs
+           LIBSRC = $(XTOP)/lib
+          FONTSRC = $(XTOP)/fonts
+     ENCODINGSSRC = $(FONTSRC)/encodings
+       INCLUDESRC = $(BUILDINCROOT)/include
+      XINCLUDESRC = $(INCLUDESRC)/X11
+        SERVERSRC = $(XTOP)/programs/Xserver
+       CONTRIBSRC = $(XTOP)/../contrib
+   UNSUPPORTEDSRC = $(XTOP)/unsupported
+           DOCSRC = $(XTOP)/doc
+           RGBSRC = $(XTOP)/programs/rgb
+      BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
+     MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
+    FONTSERVERSRC = $(PROGRAMSRC)/xfs
+       FONTINCSRC = $(XTOP)/include/fonts
+        EXTINCSRC = $(XTOP)/include/extensions
+      FTSOURCEDIR = FreeTypeSrcDir
+        DRMSRCDIR = $(TOP)/extras/drm
+       MESASRCDIR = $(TOP)/extras/Mesa
+  OGLSAMPLESRCDIR = $(TOP)/extras/ogl-sample
+        PSWRAPSRC = $(XTOP)/config/pswrap
+     TRANSCOMMSRC = $(LIBSRC)/xtrans
+   TRANS_INCLUDES = -I$(TRANSCOMMSRC)
+ CONNECTION_FLAGS = -DUNIXCONN -DTCPCONN $(STICKY_DEFINES) $(FCHOWN_DEFINES) -DIPv6
+XTRANS_FAILDEFINES = -DFAIL_HARD
+
+    VENDORMANNAME = X.Org
+ VENDORMANVERSION = `echo 6 8 2 | sed -e 's/ /./g' -e 's/^/Version\\\ /'`
+      XORGMANDEFS = -D__xorgversion__="$(XORGRELSTRING) Release"' "$(XORGMANNAME)"'
+    VENDORMANDEFS = -D__vendorversion__="$(VENDORMANVERSION) $(VENDORMANNAME)"
+       VENDORNAME = The X.Org Foundation
+  VENDORNAMESHORT = X.Org
+
+ VENDORWEBSUPPORT = http://wiki.X.Org
+
+VENDORSUPPORTDEFS = -D__VENDORDWEBSUPPORT__='"$(VENDORWEBSUPPORT)"'
+
+      XKBDEFRULES = xorg
+  XKBDEFRULESDEFS = -D__XKBDEFRULES__='"$(XKBDEFRULES)"'
+
+     XCONFIGFILE = xorg.conf
+      XCONFIGDIR = $(LIBDIR)
+        XLOGFILE = Xorg
+     XSERVERNAME = Xorg
+
+       XENVLIBDIR = $(USRLIBDIR)
+   CLIENTENVSETUP = LD_LIBRARY_PATH=$(XENVLIBDIR) XLOCALEDIR=$(BUILDLIBDIR)/locale
+
+# $Xorg: lnxLib.tmpl,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
+# $XFree86: xc/config/cf/lnxLib.tmpl,v 3.19 2003/10/15 22:47:48 herrb Exp $
+
+          XLIBSRC = $(LIBSRC)/X11
+
+SOXLIBREV = 6.2
+DEPXONLYLIB =
+XONLYLIB =  -lX11
+
+LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln
+
+      DEPXLIBONLY = $(DEPXONLYLIB)
+         XLIBONLY = $(XONLYLIB)
+     LINTXONLYLIB = $(LINTXONLY)
+
+      XEXTLIBSRC = $(LIBSRC)/Xext
+
+SOXEXTREV = 6.4
+DEPEXTENSIONLIB =
+EXTENSIONLIB =  -lXext
+
+LINTEXTENSION = $(LINTLIBDIR)/llib-lXext.ln
+
+LINTEXTENSIONLIB = $(LINTEXTENSION)
+          DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
+             XLIB = $(EXTENSIONLIB) $(XONLYLIB)
+         LINTXLIB = $(LINTXONLYLIB)
+
+    XSSLIBSRC = $(LIBSRC)/Xss
+
+SOXSSREV = 1.0
+DEPXSSLIB =
+XSSLIB =  -lXss
+
+LINTXSS = $(LINTLIBDIR)/llib-lXss.ln
+
+    XXF86MISCLIBSRC = $(LIBSRC)/Xxf86misc
+
+SOXXF86MISCREV = 1.1
+DEPXXF86MISCLIB =
+XXF86MISCLIB =  -lXxf86misc
+
+LINTXXF86MISC = $(LINTLIBDIR)/llib-lXxf86misc.ln
+
+    XXF86VMLIBSRC = $(LIBSRC)/Xxf86vm
+
+SOXXF86VMREV = 1.0
+DEPXXF86VMLIB =
+XXF86VMLIB =  -lXxf86vm
+
+LINTXXF86VM = $(LINTLIBDIR)/llib-lXxf86vm.ln
+
+    XXF86DGALIBSRC = $(LIBSRC)/Xxf86dga
+
+SOXXF86DGAREV = 1.0
+DEPXXF86DGALIB =
+XXF86DGALIB =  -lXxf86dga
+
+LINTXXF86DGA = $(LINTLIBDIR)/llib-lXxf86dga.ln
+
+    XXF86RUSHLIBSRC = $(LIBSRC)/Xxf86rush
+
+SOXXF86RUSHREV = 1.0
+DEPXXF86RUSHLIB =
+XXF86RUSHLIB =  -lXxf86rush
+
+LINTXXF86RUSH = $(LINTLIBDIR)/llib-lXxf86rush.ln
+
+    XVLIBSRC = $(LIBSRC)/Xv
+
+SOXVREV = 1.0
+DEPXVLIB =
+XVLIB =  -lXv
+
+LINTXV = $(LINTLIBDIR)/llib-lXv.ln
+
+    XVMCLIBSRC = $(LIBSRC)/XvMC
+
+SOXVMCREV = 1.0
+DEPXVMCLIB =
+XVMCLIB =  -lXvMC
+
+LINTXVMC = $(LINTLIBDIR)/llib-lXvMC.ln
+
+    XINERAMALIBSRC = $(LIBSRC)/Xinerama
+
+SOXINERAMAREV = 1.0
+DEPXINERAMALIB =
+XINERAMALIB =  -lXinerama
+
+LINTXINERAMA = $(LINTLIBDIR)/llib-lXinerama.ln
+
+    XRESLIBSRC = $(LIBSRC)/XRes
+
+SOXRESREV = 1.0
+DEPXRESLIB =
+XRESLIB =  -lXRes
+
+LINTXRES = $(LINTLIBDIR)/llib-lXRes.ln
+
+    DMXLIBSRC = $(LIBSRC)/dmx
+
+SODMXREV = 1.0
+DEPDMXLIB =
+DMXLIB =  -ldmx
+
+LINTDMX = $(LINTLIBDIR)/llib-ldmx.ln
+
+    DPSLIBSRC = $(LIBSRC)/dps
+
+SODPSREV = 1.0
+DEPDPSLIB =
+DPSLIB =  -ldps
+
+LINTDPS = $(LINTLIBDIR)/llib-ldps.ln
+
+    DPSTKLIBSRC = $(LIBSRC)/dpstk
+
+SODPSTKREV = 1.0
+DEPDPSTKLIB =
+DPSTKLIB =  -ldpstk
+
+LINTDPSTK = $(LINTLIBDIR)/llib-ldpstk.ln
+
+    PSRESLIBSRC = $(LIBSRC)/psres
+
+SOPSRESREV = 1.0
+DEPPSRESLIB =
+PSRESLIB =  -lpsres
+
+LINTPSRES = $(LINTLIBDIR)/llib-lpsres.ln
+
+    GLULIBSRC = $(LIBSRC)/GLU
+
+SOGLUREV = 1.3
+DEPGLULIB =
+GLULIB =  -lGLU
+
+LINTGLU = $(LINTLIBDIR)/llib-lGLU.ln
+
+    GLXLIBSRC = $(LIBSRC)/GL
+
+SOGLREV = 1.2
+DEPGLXLIB =
+GLXLIB =  -lGL
+
+LINTGLX = $(LINTLIBDIR)/llib-lGL.ln
+
+    GLWIDGETSRC = $(LIBSRC)/GLw
+
+DEPGLWLIB = $(USRLIBDIR)/libGLw.a
+GLWLIB =  -lGLw
+
+LINTGLW = $(LINTLIBDIR)/llib-lGLw.ln
+
+XRENDERDIR = /usr
+XRENDERLIBDIR = /usr/lib
+XRENDERINCDIR = /usr/include
+XRENDERLIB = -L$(XRENDERLIBDIR) -lXrender
+DEPXRENDERLIB =
+
+XRENDERINCLUDES = -I$(XRENDERINCDIR)
+
+    XRANDRLIBSRC = $(LIBSRC)/Xrandr
+
+SOXRANDRREV = 2.0
+DEPXRANDRLIB =
+XRANDRLIB =  -lXrandr
+
+LINTXRANDR = $(LINTLIBDIR)/llib-lXrandr.ln
+
+    XFIXESLIBSRC = $(LIBSRC)/Xfixes
+
+SOXFIXESREV = 3.0
+DEPXFIXESLIB =
+XFIXESLIB =  -lXfixes
+
+LINTXFIXES = $(LINTLIBDIR)/llib-lXfixes.ln
+
+   XDAMAGELIBSRC = $(LIBSRC)/Xdamage
+
+SOXDAMAGEREV = 1.0
+DEPXDAMAGELIB =
+XDAMAGELIB =  -lXdamage
+
+LINTXDAMAGE = $(LINTLIBDIR)/llib-lXdamage.ln
+
+XCOMPOSITELIBSRC = $(LIBSRC)/Xcomposite
+
+SOXCOMPOSITEREV = 1.0
+DEPXCOMPOSITELIB =
+XCOMPOSITELIB =  -lXcomposite
+
+LINTXCOMPOSITE = $(LINTLIBDIR)/llib-lXcomposite.ln
+
+XEVIELIBSRC = $(LIBSRC)/Xevie
+
+SOXEVIEREV = 1.0
+DEPXEVIELIB =
+XEVIELIB =  -lXevie
+
+LINTXEVIE = $(LINTLIBDIR)/llib-lXevie.ln
+
+XCURSORDIR = /usr
+XCURSORLIBDIR = /usr/lib
+XCURSORINCDIR = /usr/include
+XCURSORLIB = -L$(XCURSORLIBDIR) -lXcursor
+
+XCURSORINCLUDES=-I$(XCURSORINCDIR) $(XRENDERINCLUDES)
+
+   APPLEWMLIBSRC = $(LIBSRC)/apple
+
+DEPAPPLEWMLIB = $(USRLIBDIR)/libAppleWM.a
+APPLEWMLIB =  -lAppleWM
+
+LINTAPPLEWM = $(LINTLIBDIR)/llib-lAppleWM.ln
+
+   WINDOWSWMLIBSRC = $(LIBSRC)/windows
+
+DEPWINDOWSWMLIB = $(USRLIBDIR)/libWindowsWM.a
+WINDOWSWMLIB =  -lWindowsWM
+
+LINTWINDOWSWM = $(LINTLIBDIR)/llib-lWindowsWM.ln
+
+    XFONTCACHELIBSRC = $(LIBSRC)/Xfontcache
+
+DEPXFONTCACHELIB = $(USRLIBDIR)/libXfontcache.a
+XFONTCACHELIB =  -lXfontcache
+
+LINTXFONTCACHE = $(LINTLIBDIR)/llib-lXfontcache.ln
+
+         XAUTHSRC = $(LIBSRC)/Xau
+
+SOXAUTHREV = 6.0
+DEPXAUTHLIB =
+XAUTHLIB =  -lXau
+
+LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln
+
+      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
+
+SOXDMCPREV = 6.0
+DEPXDMCPLIB =
+XDMCPLIB =  -lXdmcp
+
+LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln
+
+           XMUSRC = $(LIBSRC)/Xmu
+
+SOXMUREV = 6.2
+DEPXMULIB =
+XMULIB =  -lXmu
+
+LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
+
+           XMUUSRC = $(LIBSRC)/Xmuu
+
+SOXMUUREV = 1.0
+DEPXMUULIB =
+XMUULIB =  -lXmuu
+
+LINTXMUU = $(LINTLIBDIR)/llib-lXmuu.ln
+
+       OLDXLIBSRC = $(LIBSRC)/oldX
+
+DEPOLDXLIB = $(USRLIBDIR)/liboldX.a
+OLDXLIB =  -loldX
+
+LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln
+
+         XPLIBSRC = $(LIBSRC)/Xp
+
+SOXPREV = 6.2
+DEPXPLIB =
+XPLIB =  -lXp
+
+LINTXP = $(LINTLIBDIR)/llib-lXp.ln
+
+       TOOLKITSRC = $(LIBSRC)/Xt
+
+SOXTREV = 6.0
+DEPXTOOLONLYLIB =
+XTOOLONLYLIB =  -lXt
+
+LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln
+
+      DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
+         XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
+     LINTXTOOLLIB = $(LINTXTOOLONLYLIB)
+
+       XALIBSRC = $(LIBSRC)/Xa
+
+SOXAREV = 1.0
+DEPXALIB =
+XALIB =  -lXa
+
+LINTXA = $(LINTLIBDIR)/llib-lXa.ln
+
+       AWIDGETSRC = $(LIBSRC)/Xaw
+
+SOXAWREV = 8.0
+DEPXAWLIB =
+XAWLIB =  -lXaw
+
+LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
+
+       AWIDGET7SRC = $(LIBSRC)/Xaw7
+
+SOXAW7REV = 7.0
+DEPXAW7LIB =
+XAW7LIB =  -lXaw
+
+LINTXAW7 = $(LINTLIBDIR)/llib-lXaw.ln
+
+       AWIDGET6SRC = $(LIBSRC)/Xaw6
+
+SOXAW6REV = 6.1
+DEPXAW6LIB =
+XAW6LIB =  -lXaw
+
+LINTXAW6 = $(LINTLIBDIR)/llib-lXaw.ln
+
+         XILIBSRC = $(LIBSRC)/Xi
+
+SOXINPUTREV = 6.0
+DEPXILIB =
+XILIB =  -lXi
+
+LINTXI = $(LINTLIBDIR)/llib-lXi.ln
+
+      XTESTLIBSRC = $(LIBSRC)/Xtst
+
+SOXTESTREV = 6.1
+DEPXTESTLIB =
+XTESTLIB =  -lXtst
+
+LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln
+
+DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
+XBSDLIB =  -lXbsd
+
+LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln
+
+           ICESRC = $(LIBSRC)/ICE
+
+SOICEREV = 6.3
+DEPICELIB =
+ICELIB =  -lICE
+
+LINTICE = $(LINTLIBDIR)/llib-lICE.ln
+
+            SMSRC = $(LIBSRC)/SM
+
+SOSMREV = 6.0
+DEPSMLIB =
+SMLIB =  -lSM
+
+LINTSM = $(LINTLIBDIR)/llib-lSM.ln
+
+           XKEYSRC = $(LIBSRC)/Xkey
+
+SOXKEYREV = 6.0
+DEPXKEYLIB =
+XKEYLIB =  -lXkey
+
+LINTXKEY = $(LINTLIBDIR)/llib-lXkey.ln
+
+         FSLIBSRC = $(LIBSRC)/FS
+
+SOFSREV = 6.0
+DEPFSLIB =
+FSLIB =  -lFS
+
+LINTFS = $(LINTLIBDIR)/llib-lFS.ln
+
+         FONTLIBSRC = $(LIBSRC)/font
+
+DEPFONTLIB = $(USRLIBDIR)/libXfont.a
+FONTLIB = -L$(FREETYPELIBDIR) -L$(FONTLIBSRC)  -lXfont
+
+LINTXFONT = $(LINTLIBDIR)/llib-lXfont.ln
+#
+DEPXFONTLIB = $(USRLIBDIR)/libXfont.a
+XFONTLIB =  -lXfont
+
+LINTXFONT = $(LINTLIBDIR)/llib-lXfont.ln
+
+     FONTSTUBLIBSRC = $(FONTLIBSRC)/stubs
+
+DEPFONTSTUBLIB = $(USRLIBDIR)/libfntstubs.a
+FONTSTUBLIB =  -lfntstubs
+
+LINTFONTSTUB = $(LINTLIBDIR)/llib-lfntstubs.ln
+         DEPFONTLIB = $(DEPXFONTLIB) $(DEPFONTSTUBLIB)
+            FONTLIB = $(XFONTLIB) $(FONTSTUBLIB) $(FREETYPE2LIB)
+
+         FONTENCLIBSRC = $(LIBSRC)/fontenc
+
+DEPXFONTENCLIB = $(USRLIBDIR)/libfontenc.a
+XFONTENCLIB =  -lfontenc
+
+LINTXFONTENC = $(LINTLIBDIR)/llib-lfontenc.ln
+
+          XPMLIBSRC = $(LIBSRC)/Xpm
+
+SOXPMREV = 4.11
+DEPXPMLIB =
+XPMLIB =  -lXpm
+
+LINTXPM = $(LINTLIBDIR)/llib-lXpm.ln
+
+FREETYPE2DIR = /usr
+FREETYPE2LIBDIR = /usr/lib
+FREETYPE2INCDIR = /usr/include
+
+FREETYPE2LIB = -lfreetype
+
+FREETYPE2INCLUDES = -I$(FREETYPE2INCDIR)/freetype2 -I$(FREETYPE2INCDIR)/freetype2/config
+
+FREETYPE2DEFINES = -DFREETYPE2
+
+          EXPATLIBSRC = $(LIBSRC)/expat
+
+SOEXPATREV = 0.4
+DEPEXPATLIB =
+EXPATLIB =  -lexpat
+
+LINTEXPAT = $(LINTLIBDIR)/llib-lexpat.ln
+
+EXPATDIR = /usr
+EXPATLIBDIR = /usr/lib
+EXPATINCDIR = /usr/include
+
+EXPATINCLUDES =
+
+EXPATLIB = -lexpat
+
+EXPATDEFINES = -DEXPAT
+
+XFTDIR = /usr
+XFTLIBDIR = /usr/lib
+XFTINCDIR = /usr/include
+XFTLIB = -L$(XFTLIBDIR) -lXft
+
+XFTINCLUDES= -I$(XFTINCDIR) $(FONTCONFIGINCLUDES) $(FREETYPE2INCLUDES) $(XRENDERINCLUDES)
+
+FONTCONFIGDIR = /usr
+FONTCONFIGLIBDIR = /usr/lib
+FONTCONFIGINCDIR = /usr/include
+FONTCONFIGBINDIR = /usr/bin
+
+FONTCONFIGLIB = -lfontconfig
+
+FONTCONFIGINCLUDES =
+
+FCCACHE = $(FONTCONFIGBINDIR)/fc-cache
+
+FONTCONFIGDEFINES = -DFONTCONFIG
+
+LIBPNGINCDIR = /usr/include
+
+LIBPNGINC=
+
+LIBPNGDIR = /usr
+LIBPNGLIBDIR = /usr/lib
+LIBPNGINCDIR = /usr/include
+
+LIBPNGLIB = -lpng
+
+    XKBFILELIBSRC = $(LIBSRC)/xkbfile
+
+SOXKBFILEREV =  1.0
+DEPXKBFILELIB =
+XKBFILELIB =  -lxkbfile
+
+LINTXKBFILE = $(LINTLIBDIR)/llib-lxkbfile.ln
+
+     XKBCOMPCMD = $(XBINDIR)/xkbcomp
+
+    XKBUILIBSRC = $(LIBSRC)/xkbui
+
+SOXKBUIREV =  1.0
+DEPXKBUILIB =
+XKBUILIB =  -lxkbui
+
+LINTXKBUI = $(LINTLIBDIR)/llib-lxkbui.ln
+
+EXTRAXAWREQS = $(XPLIB)
+
+EXTRAXAWCLIENTDEPLIBS = $(DEPXPLIB)
+
+EXTRAXAWCLIENTLIBS = $(XPLIB)
+
+        XTRAPLIBSRC = $(LIBSRC)/XTrap
+
+SOXTRAPREV = 6.4
+DEPXTRAPLIB =
+XTRAPLIB =  -lXTrap
+
+LINTXTRAP = $(LINTLIBDIR)/llib-lXTrap.ln
+
+          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
+
+         DEPLIBS1 = $(DEPLIBS)
+         DEPLIBS2 = $(DEPLIBS)
+         DEPLIBS3 = $(DEPLIBS)
+         DEPLIBS4 = $(DEPLIBS)
+         DEPLIBS5 = $(DEPLIBS)
+         DEPLIBS6 = $(DEPLIBS)
+         DEPLIBS7 = $(DEPLIBS)
+         DEPLIBS8 = $(DEPLIBS)
+         DEPLIBS9 = $(DEPLIBS)
+         DEPLIBS10 = $(DEPLIBS)
+
+      XFTPRELOADPATTERN = libXft.so.?
+  XRENDERPRELOADPATTERN = libXrender.so.?
+    XFONTPRELOADPATTERN = libXfont*.so.?
+
+XMULIBONLY = -lXmu
+XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
+
+        CONFIGDIR = $(LIBDIR)/config
+
+    USRLIBDIRPATH = $(USRLIBDIR)
+        LDPRELIBS = -L$(USRLIBDIR)  $(INSTALLED_LIBS)
+       LDPOSTLIBS =
+     TOP_INCLUDES = -I$(INCROOT) $(TOP_X_INCLUDES)
+  PROJECT_DEFINES =
+   VENDOR_DEFINES = -DXVENDORNAME='"$(VENDORNAME)"' -DXVENDORNAMESHORT='"$(VENDORNAMESHORT)"'
+
+CXXPROJECT_DEFINES =
+
+# ----------------------------------------------------------------------
+# start of Imakefile
+
+# =====================================================================
+#   Imakefile - xjig v2.4 - Helmut.Hoenig@hub.de - July 24, 1996
+# =====================================================================
+
+# set the compiler that you like,
+# gcc should suit, since the libraries are not needed. But I had problem
+# with the optimize-options on gcc-2.7.0. You should try to use
+# optimization on your version, but if it doesn't work, a compiler bug
+# might be the reason...
+
+#           CXX = gcc -g
+
+# On some machines (like on linux) you can gain speed by using the
+# MIT-SHM extension for transfering images to the server via shared
+# memory. If your system doesn't support that or if you don't see any
+# enhancement, you could remove the -DUSE_MIT_SHM flag from the CXXFLAGS.
+
+        USE_MIT_SHM = -DUSE_MIT_SHM
+
+# There is a speed optimization in not doing any checks about crossing
+# the image boundaries during the texture mapping routines. Some extra
+# memory therefore surround the image for not crashing due to nonallocated
+# memory access. You can switch range-checking on by uncommenting the
+# following flag.
+
+#    RANG_CHECK = -DRANGE_CHECK
+
+# which default file should be loaded if no option is set
+
+        JIG_DEFAULT = \"/usr/lib/games/xjig/tina.gif\"
+
+# #######################################################################
+
+               SRCS = xjig.C objects.C stack.C imgbuff.C puzzle.C                       real.C vec2.C vec2list.C mat2.C                       color_mapper.C base_image.C gif_image.C ximage.C                       ppm_image.C jpeg_image.C
+
+           CXXFLAGS = $(USE_MIT_SHM) $(RANG_CHECK)
+
+    LOCAL_LIBRARIES = $(XLIB) -ljpeg -lnetpbm -lm
+
+               OBJS = xjig.o objects.o stack.o imgbuff.o puzzle.o                       real.o vec2.o vec2list.o mat2.o                       color_mapper.o base_image.o gif_image.o ximage.o                       ppm_image.o jpeg_image.o
+
+xjig: $(OBJS) $(DEPLIBS)
+	$(RM) $@
+	$(CXX) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
+
+all:: xjig
+
+install:: xjig
+	@if [ -d $(DESTDIR)$(BINDIR) ]; then \
+		set +x; \
+	else \
+		if [ -h $(DESTDIR)$(BINDIR) ]; then \
+			(set -x; rm -f $(DESTDIR)$(BINDIR)); \
+		fi; \
+		(set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); \
+	fi
+	$(INSTALL) $(INSTALLFLAGS) $(INSTPGMFLAGS)  xjig $(DESTDIR)$(BINDIR)/xjig
+
+all:: xjig.$(MANNEWSUFFIX)
+
+xjig.$(MANNEWSUFFIX): xjig.$(MANSRCSUFFIX)
+	$(RM) $@
+	if test -z "$(PREPROCESSMANPAGES)" ; then \
+	   cd `dirname xjig` && \
+	   $(LN) `basename xjig.$(MANSRCSUFFIX)` `basename $@`; \
+	else \
+	      	     $(RAWCPP)  $(MANDEFS) $(EXTRAMANDEFS) \
+	     < xjig.$(MANSRCSUFFIX) | sed -e '/^#  *[0-9][0-9]*  *.*$$/d' 			-e '/^#line  *[0-9][0-9]*  *.*$$/d' 			-e '/^[ 	]*XCOMM$$/s/XCOMM/#/' 			-e '/^[ 	]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' 			-e '/^[ 	]*XHASH/s/XHASH/#/' 			-e '/\@\@$$/s/\@\@$$/\\/' >$@; \
+	fi
+
+cleandir::
+	$(RM) xjig.$(MANNEWSUFFIX)
+
+install.man:: xjig.$(MANNEWSUFFIX)
+	@if [ -d $(DESTDIR)$(MANDIR) ]; then \
+		set +x; \
+	else \
+		if [ -h $(DESTDIR)$(MANDIR) ]; then \
+			(set -x; rm -f $(DESTDIR)$(MANDIR)); \
+		fi; \
+		(set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); \
+	fi
+	$(INSTALL) $(INSTALLFLAGS) $(INSTMANFLAGS) xjig.$(MANNEWSUFFIX) $(DESTDIR)$(MANDIR)/xjig.$(MANSUFFIX)
+
+depend::
+	$(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS)
+
+cleandir::
+	$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  grohtml*.png *-auto-*.png "#"*
+
+xjig.o:
+	$(CXX) $(CXXFLAGS) -DJIG_DEFAULT=$(JIG_DEFAULT) -c xjig.C -o $@
+
+# .C.o:
+# 	$(CXX) $(CFLAGS) -c $< -o $@
+
+# ----------------------------------------------------------------------
+# common rules for all Makefiles - do not edit
+
+.c.i:
+	$(RM) $@
+	 	$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@
+
+.SUFFIXES: .ii
+
+.cc.ii:
+	$(RM) $@
+	 	$(CC) -E $(CFLAGS) $(_NOOP_) $*.cc > $@
+
+.SUFFIXES: .s
+
+.c.s:
+	$(RM) $@
+	 	$(CC) -S $(CFLAGS) $(_NOOP_) $*.c
+
+.cc.s:
+	$(RM) $@
+	 	$(CC) -S $(CFLAGS) $(_NOOP_) $*.cc
+
+emptyrule::
+
+cleandir::
+	$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  grohtml*.png *-auto-*.png "#"*
+
+Makefile::
+	-@if [ -f Makefile ]; then set -x; \
+	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
+	else exit 0; fi
+	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
+
+tags::
+	$(TAGS) -w *.[ch]
+	$(TAGS) -xw *.[ch] > TAGS
+
+man_keywords::
+
+html_index::
+
+clean:: cleandir
+
+distclean:: cleandir
+
+    PREPROCESSMANPAGES = true
+
+# ----------------------------------------------------------------------
+# empty rules for directories that do not have SUBDIRS - do not edit
+
+install::
+	@echo "install in $(CURRENT_DIR) done"
+
+install.man::
+	@echo "install.man in $(CURRENT_DIR) done"
+
+install.sdk::
+	@echo "install.sdk in $(CURRENT_DIR) done"
+
+Makefiles::
+
+includes::
+
+depend::
+
+distclean::
+	$(RM) Makefile Makefile.dep
+
+# ----------------------------------------------------------------------
+# dependencies generated by makedepend
+
+# DO NOT DELETE
+xjig.o: xjig.C global.h /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h /usr/include/unistd.h \
+  /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
+  /usr/include/bits/confname.h /usr/include/getopt.h \
+  /usr/include/signal.h /usr/include/bits/signum.h \
+  /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \
+  /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \
+  /usr/include/asm-i486/sigcontext.h /usr/include/linux/compiler.h \
+  /usr/include/bits/sigstack.h /usr/include/sys/ucontext.h \
+  /usr/include/bits/sigthread.h /usr/X11R6/include/X11/keysym.h \
+  /usr/X11R6/include/X11/keysymdef.h /usr/X11R6/include/X11/cursorfont.h \
+  /usr/X11R6/include/X11/extensions/shape.h /usr/X11R6/include/X11/Xos.h \
+  /usr/include/string.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \
+  /usr/include/sys/stat.h /usr/include/bits/stat.h \
+  /usr/include/sys/time.h /usr/X11R6/include/X11/Xarch.h objects.H \
+  stack.H vec2.h real.h vec2list.h mat2.h ximage.H base_image.H \
+  color_mapper.H imgbuff.H puzzle.H cursor.h
+objects.o: objects.C global.h /usr/include/stdlib.h \
+  /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h /usr/X11R6/include/X11/Xmd.h \
+  /usr/X11R6/include/X11/extensions/shape.h objects.H stack.H vec2.h \
+  real.h vec2list.h mat2.h ximage.H base_image.H imgbuff.H color_mapper.H \
+  puzzle.H rotate.H
+stack.o: stack.C /usr/include/stdio.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/types.h /usr/include/bits/wordsize.h \
+  /usr/include/bits/typesizes.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/stdlib.h /usr/include/bits/waitflags.h \
+  /usr/include/bits/waitstatus.h /usr/include/endian.h \
+  /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/strings.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  global.h /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xutil.h stack.H objects.H vec2.h real.h \
+  vec2list.h mat2.h ximage.H base_image.H
+imgbuff.o: imgbuff.C global.h /usr/include/stdlib.h \
+  /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h imgbuff.H
+puzzle.o: puzzle.C global.h /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h puzzle.H vec2.h real.h objects.H stack.H \
+  vec2list.h mat2.h
+real.o: real.C global.h /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h real.h
+vec2.o: vec2.C global.h /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h vec2.h real.h
+vec2list.o: vec2list.C global.h /usr/include/stdlib.h \
+  /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h vec2list.h vec2.h real.h mat2.h
+mat2.o: mat2.C global.h /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h mat2.h real.h vec2.h
+color_mapper.o: color_mapper.C /usr/X11R6/include/X11/Xlib.h \
+  /usr/include/sys/types.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/include/bits/types.h /usr/include/bits/wordsize.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/typesizes.h /usr/include/time.h /usr/include/endian.h \
+  /usr/include/bits/endian.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/X11R6/include/X11/X.h /usr/X11R6/include/X11/Xfuncproto.h \
+  /usr/X11R6/include/X11/Xosdefs.h /usr/include/stdio.h \
+  /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
+  /usr/include/bits/wchar.h /usr/include/gconv.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/stdlib.h /usr/include/bits/waitflags.h \
+  /usr/include/bits/waitstatus.h /usr/include/xlocale.h \
+  /usr/include/alloca.h color_mapper.H
+base_image.o: base_image.C /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/string.h base_image.H
+gif_image.o: gif_image.C /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/string.h gif_image.H base_image.H
+ximage.o: ximage.C global.h /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/math.h /usr/include/bits/huge_val.h \
+  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
+  /usr/include/bits/inf.h /usr/include/bits/nan.h \
+  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
+  /usr/X11R6/include/X11/Xlib.h /usr/X11R6/include/X11/X.h \
+  /usr/X11R6/include/X11/Xfuncproto.h /usr/X11R6/include/X11/Xosdefs.h \
+  /usr/X11R6/include/X11/Xutil.h /usr/include/string.h \
+  /usr/X11R6/include/X11/Xmd.h ximage.H base_image.H color_mapper.H \
+  gif_image.H ppm_image.H jpeg_image.H reset_image.H
+ppm_image.o: ppm_image.C /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/string.h /usr/include/ppm.h /usr/include/pgm.h \
+  /usr/include/pbm.h /usr/include/pm.h /usr/include/pm_config.h \
+  /usr/include/fcntl.h /usr/include/bits/fcntl.h /usr/include/sys/stat.h \
+  /usr/include/bits/stat.h /usr/include/unistd.h \
+  /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
+  /usr/include/bits/confname.h /usr/include/getopt.h /usr/include/ctype.h \
+  /usr/include/errno.h /usr/include/bits/errno.h \
+  /usr/include/linux/errno.h /usr/include/asm/errno.h \
+  /usr/include/asm-i486/errno.h /usr/include/asm-generic/errno.h \
+  /usr/include/asm-generic/errno-base.h /usr/include/netpbm-shhopt.h \
+  /usr/include/ppmcmap.h ppm_image.H base_image.H
+jpeg_image.o: jpeg_image.C /usr/include/stdlib.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+  /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h \
+  /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+  /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+  /usr/include/sys/types.h /usr/include/bits/types.h \
+  /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+  /usr/include/time.h /usr/include/sys/select.h \
+  /usr/include/bits/select.h /usr/include/bits/sigset.h \
+  /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+  /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+  /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \
+  /usr/include/gconv.h /usr/lib/gcc/i486-linux-gnu/4.0.3/include/stdarg.h \
+  /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+  /usr/include/string.h /usr/include/jpeglib.h /usr/include/jconfig.h \
+  /usr/include/jmorecfg.h jpeg_image.H base_image.H
