#ifndef XCOMM
#define XCOMM #
#endif

XCOMM Copyright (c) 1985 by Supoj Sutanthavibul
XCOMM Copyright (c) 1994 by Brian V. Smith
XCOMM Parts Copyright (c) 1991 by Paul King

XCOMM The X Consortium, and any party obtaining a copy of these files from
XCOMM the X Consortium, directly or indirectly, is granted, free of charge, a
XCOMM full and unrestricted irrevocable, world-wide, paid up, royalty-free,
XCOMM nonexclusive right and license to deal in this software and
XCOMM documentation files (the "Software"), including without limitation the
XCOMM rights to use, copy, modify, merge, publish, distribute, sublicense,
XCOMM and/or sell copies of the Software, and to permit persons who receive
XCOMM copies from any such party to do so, with the only requirement being
XCOMM that this copyright notice remain intact.  This license includes without
XCOMM limitation a license to do the foregoing actions under any patents of
XCOMM the party supplying this software to the X Consortium.

XCOMM  NOTE: AS of X11R6 the official comment for Imakefile is the word XCOMM

#ifdef InstallManPage
#undef InstallManPage
#endif
#define InstallManPage(file,dest)                                       @@\
InstallManPageLong(Doc/file,dest,file)

XCOMM Uncomment the following definition for XAWLIB if you want to use
XCOMM the 3d Athena Widget Set (highly recommended!)

XCOMM XAWLIB = -lXaw3d

XCOMM Uncomment the following if needed for DECstations running older X11R4 
XCOMM INCROOT=/usr/include/mit

XCOMM Uncomment the following XPM variable if you have the XPM (color pixmap)
XCOMM package and you would like to use the following:
XCOMM USE_XPM will allow import/export of XPM files
XCOMM USE_XPM_ICON uses a color xpm icon for xfig itself (USE_XPM must be
XCOMM	defined if you use USE_XPM_ICON)
XCOMM You need XPM version 3.4c or newer.  This is available from ftp.x.org
XCOMM   in /contrib/libraries.

XCOMM XPMDEFINES = -DUSE_XPM -DUSE_XPM_ICON
XCOMM XPMLIBDIR = /usr/lib
XCOMM XPMINCDIR = /usr/include/X11
XCOMM XPMLIB = -L$(XPMLIBDIR) -lXpm

XCOMM If you have installed the jpeg library on your system, uncomment the
XCOMM USEINSTALLEDJPEG variable, change the JPEGLIBDIR variable to the directory
XCOMM where your jpeg library resides and change the JPEGINCDIR to the 
XCOMM directory where your jpeg header files (include) reside.
XCOMM You must have version 5b or newer of the jpeg library.
XCOMM If you haven't installed the jpeg library leave the XCOMM comment in and
XCOMM set JPEGLIBDIR after the #else to the directory where you have the source
XCOMM for jpeg.

XCOMM #define USEINSTALLEDJPEG

#ifdef USEINSTALLEDJPEG
JPEGLIBDIR = /usr/local/lib
JPEGINCDIR = /usr/include/X11
#else
JPEGLIBDIR = ../jpeg
JPEGINCDIR = $(JPEGLIBDIR)
DEPLIBJPEG = $(JPEGLIBDIR)/libjpeg.a
#endif

XCOMM For Solaris: add "-lc" to the LOCAL_LIBRARIES variable in the Imakefile 
XCOMM to link with /usr/lib/libc for the directory operations.

XCOMM The Display PostScript code is not supported anymore until some kind
XCOMM user can debug it for me, as I have no access to a server with DPS
XCOMM extensions.  Use Ghostscript for rendering your EPS files.  It gives
XCOMM a color image on the xfig canvas now anyway.

XCOMM If using an input tablet uncomment the following

XCOMM TABLIB = $(XILIB)
XCOMM USETAB = -DUSE_TAB

XCOMM use (and change) the following if you want the multi-key data base file
XCOMM somewhere other than the standard X11 library directory
XCOMM XFIGLIBDIR =		/usr/local/lib/X11/xfig

XCOMM use this if you want the multi-key data base file in the standard X11 tree
XFIGLIBDIR =		$(LIBDIR)/xfig

DIR_DEFS=		-DXFIGLIBDIR=\"$(XFIGLIBDIR)\"
#if (defined(VaxArchitecture) && !defined(UltrixArchitecture)) || \
    (defined(RtArchitecture) && !defined(AIXArchitecture)) || \
    defined(titan) || \
    (defined(SunOSPlatform) && (OSMinorVersion==0))
HAVE_NO_NOSTRSTR = -DNOSTRSTR
#endif

XCOMM If your system doesn't have strcasecmp and/or strncasecmp
XCOMM undefine the following two definitions

XCOMM HAVE_NO_STRCASECMP = -DHAVE_NO_STRCASECMP
XCOMM HAVE_NO_STRNCASECMP = -DHAVE_NO_STRNCASECMP

STRDEFINES = $(HAVE_NO_NOSTRSTR) \
		$(HAVE_NO_STRNCASECMP) \
		$(HAVE_NO_STRCASECMP)

XCOMM For the rotated text code:
XCOMM   Add one of `-DCACHE_XIMAGES' or `-DCACHE_BITMAPS' to decide what is
XCOMM   cached.  If you are converned about memory usage in your X server (e.g.
XCOMM   if you are using an X terminal) then you might want to cache Ximages,
XCOMM   which reside on the client-side.  On the other hand it is much slower,
XCOMM   so you might want to cache bitmaps (which reside in the X server)
XCOMM   instead.
XCOMM   Add `-DCACHE_SIZE_LIMIT=xxxx' where xxxx is the cache size in kilobytes.
XCOMM   A cache size of zero turns caching off.

CACHE = -DCACHE_BITMAPS -DCACHE_SIZE_LIMIT=300

XCOMM For SYSV systems with BSD-style printer command which use lpr instead of 
XCOMM lp (SGI is one such machine), add -DBSDLPR to the DEFINES variable
XCOMM
XCOMM If you have VERY large objects (e.g. polylines etc) you may want to
XCOMM increase MAXNUMPTS, the maximum number of points that are displayed. The
XCOMM default can be found in w_drawprim.h.  This option may be specified by
XCOMM adding -DMAXNUMPTS=xxxx to the DEFINES line, where xxxx is the maximum
XCOMM number of vertices.

XCOMM remove -DGSBIT from the DEFINES if you DON'T want to have gs (Ghostscript)
XCOMM generate a preview bitmap for Encapsulated PostScript objects if they
XCOMM don't have one.  If you do use Ghostscript you will need version 2.4 or
XCOMM later, and it must have the 'pcx256' and 'pbmraw' devices compiled in
XCOMM besides any other device drivers you already use with it.
XCOMM See the Ghostscript Makefile for details.

XCOMM Additionally, there is a bug in the pcx driver in Aladdin Ghostscript
XCOMM versions prior to 3.32, which writes an incorrect pcx file for images
XCOMM with odd width (not even).  The following compile-time flag PCXBUG is
XCOMM set to make xfig add one pixel to the width of an odd-width image
XCOMM it reads in the pcx output from Ghostscript.
XCOMM If you have Aladdin Ghostscript 3.32 or newer (which wasn't released
XCOMM as of this writing) you may comment out PCXBUG and your images will
XCOMM have the proper width.  However, one pixel extra in width shouldn't
XCOMM matter for most imported eps files.

PCXBUG = -DPCXBUG

XCOMM *** You shouldn't have to change anything below this point. ***

DEFINES =             $(STRDEFINES) -DGSBIT $(XPMDEFINES)

XFIGSRC =	d_arc.c d_arcbox.c d_box.c d_ellipse.c d_picobj.c \
		d_intspline.c d_line.c d_regpoly.c d_spline.c d_text.c \
		e_addpt.c e_align.c e_arrow.c e_break.c \
		e_convert.c e_copy.c e_delete.c e_deletept.c \
		e_edit.c e_flip.c e_glue.c e_move.c \
		e_movept.c e_rotate.c e_scale.c e_update.c \
		f_load.c f_neuclrtab.c f_picobj.c f_read.c f_readold.c \
		f_readeps.c f_readxbm.c f_readxpm.c f_readgif.c f_readjpg.c \
		f_save.c f_util.c \
		f_wrcom.c f_wrjpg.c f_wrgif.c f_wrxbm.c f_wrxpm.c \
		main.c mode.c object.c resources.c \
		u_bound.c u_create.c u_drag.c u_draw.c \
		u_elastic.c u_error.c u_fonts.c u_free.c u_geom.c \
		u_list.c u_markers.c u_pan.c u_print.c \
		u_redraw.c u_scale.c u_search.c u_translate.c u_undo.c \
		w_browse.c w_capture.c \
		w_canvas.c w_cmdpanel.c w_color.c w_cursor.c w_dir.c w_drawprim.c \
		w_export.c w_file.c w_fontbits.c w_fontpanel.c w_grid.c \
		w_icons.c w_indpanel.c w_modepanel.c w_mousefun.c w_msgpanel.c \
		w_print.c w_rottext.c w_rulers.c w_setup.c w_util.c w_zoom.c

XFIGOBJ =	d_arc.o d_arcbox.o d_box.o d_ellipse.o d_picobj.o \
		d_intspline.o d_line.o d_regpoly.o d_spline.o d_text.o \
		e_addpt.o e_align.o e_arrow.o e_break.o \
		e_convert.o e_copy.o e_delete.o e_deletept.o \
		e_edit.o e_flip.o e_glue.o e_move.o \
		e_movept.o e_rotate.o e_scale.o e_update.o \
		f_load.o f_neuclrtab.o f_picobj.o f_read.o f_readold.o \
		f_readeps.o f_readxbm.o f_readxpm.o f_readgif.o f_readjpg.o \
		f_save.o f_util.o \
		f_wrcom.o f_wrjpg.o f_wrgif.o f_wrxbm.o f_wrxpm.o \
		main.o mode.o object.o resources.o \
		u_bound.o u_create.o u_drag.o u_draw.o \
		u_elastic.o u_error.o u_fonts.o u_free.o u_geom.o \
		u_list.o u_markers.o u_pan.o u_print.o \
		u_redraw.o u_scale.o u_search.o u_translate.o u_undo.o \
		w_browse.o w_capture.o \
		w_canvas.o w_cmdpanel.o w_color.o w_cursor.o w_dir.o w_drawprim.o \
		w_export.o w_file.o w_fontbits.o w_fontpanel.o w_grid.o \
		w_icons.o w_indpanel.o w_modepanel.o w_mousefun.o w_msgpanel.o \
		w_print.o w_rottext.o w_rulers.o w_setup.o w_util.o w_zoom.o

XCOMM Other dependencies should be handled by "make depend"

MAINDEPFILES =  fig.icon.X patchlevel.h version.h

SRCS = $(XFIGSRC)
OBJS = $(XFIGOBJ)

EXTRA_INCLUDES = -I$(JPEGINCDIR) -I$(XPMINCDIR)
DEPLIBS = XawClientDepLibs

LOCAL_LIBRARIES = 	-L$(JPEGLIBDIR) -ljpeg
SYS_LIBRARIES= 		-lm $(DPSLIB) $(XPMLIB) $(TABLIB) XawClientLibs

#define PassCDebugFlags

xfig: $(DEPLIBJPEG)

XCOMM only compile our jpeg if the use doesn't have one installed

#ifndef USEINSTALLEDJPEG
$(JPEGLIBDIR)/libjpeg.a: $(JPEGLIBDIR)/jconfig.h
	cd $(JPEGLIBDIR); $(MAKE) libjpeg.a

$(JPEGLIBDIR)/jconfig.h:
	cd $(JPEGLIBDIR) ; ./configure CC='$(CC)'
#endif

PROGRAM = xfig
AllTarget(xfig)

ComplexProgramTarget(xfig)
MakeDirectories(install,$(XFIGLIBDIR))
InstallNonExec(CompKeyDB,$(XFIGLIBDIR))
InstallAppDefaults(Fig)
InstallAppDefaults(Fig-color)
SpecialObjectRule(main.o, $(MAINDEPFILES), $(USETAB) )
#ifndef USEINSTALLEDJPEG
SpecialObjectRule(f_readjpg.o, $(JPEGLIBDIR)/jconfig.h , $(PCXBUG))
#endif
SpecialObjectRule(w_canvas.o, , $(DIR_DEFS))
SpecialObjectRule(w_rottext.o, , $(CACHE))
