# Makefile for xv


# your C compiler (and options) of choice

# if you want to use gcc, use this line, or something like it.
# CC = gcc -g -traditional
# CC = gcc -g -ansi -Dsparc
CC = gcc

# if compiling on a Mips machine, (not a DECstation), try this: 
#    CCOPTS = -Olimit 2000 -systype bsd43

CCOPTS = -O8
#CCOPTS = -g

# if you're using a Sun running OpenWindows, you may want to add these two
# options to the CCOPTS line, so it finds the libs and include files
#   -L/usr/openwin/lib -I/usr/openwin/include

# Likewise, if your X11 include files and libX11.a library aren't in the
# 'standard' places in which the C compiler looks, you should add '-L' and
# '-I' options on the CCOPTS line to tell the compiler where said files are.




################ CONFIGURATION OPTIONS #################

# By default, backing_store is turned on ('WhenMapped') for several XV windows.
# This is generally a good performance improvement, however, it has been known
# to crash some servers (most notably X11R3 running on an HP), so this is left
# as something that you could turn off, if necessary.
BACKING_STORE = -DBACKING_STORE


# if you are running on a SysV-based machine, such as HP, Silicon Graphics,
# Solaris, etc., uncomment the following line to get mostly there.  
UNIX = -DSVR4


# If your machine does not have the 'setitimer()' call (do 'man setitimer'
# to check), but does have the 'usleep()' call, uncomment the following line:
#TIMERS = -DUSLEEP
#
# alternately, if your machine does not have EITHER the 'setitimer()' or
# the 'usleep()' call, uncomment the following line:
#
# Note: SCO ODT 1.1 (UNIX 3.2v2) does not have itimers, ODT 2.0 (UNIX 3.2v4) 
# does.  Uncomment this accordingly.
#
#TIMERS = -DNOTIMER


# PostScript file input support:
#
# if you have the 'ghostscript' package installed (version 2.5 or later),
# you can use it let XV display postscript files.  Note: to do so, you're
# 'gs' *must* be built with 'pbmraw','pgmraw', and 'ppmraw' support, which
# is *NOT* turned on by default when you build gs.  It's easy.  See the gs
# distribution for how-to information.  (currently, it's just a matter of
# adding 'pbmraw.dev pgmraw.dev ppmraw.dev' to the DEVICE_DEVS line in the
# ghostscript Makefile, and typing make).  Also note that if your version
# of gs supports 'pnmraw' you should add that support as well, and change
# the GS_DEV line below to 'pnmraw' for optimum performance.  (Currently,
# this device isn't in ghostscript, but it should be appearing in a new
# version.
#
# if you wish to use gs, uncomment the following lines, and make sure that
# GS_PATH specifies the complete path to your gs executable.  GS_LIB should
# be set if there's some other gs libs that should be searched, but aren't
# by default.  (In which case you should probably just fix your 'gs' so it
# looks in the right places without being told...)
# Note that it is necessary to put a backslash in front of the " chars

#GS_PATH=-DGS_PATH=\"/pkg/bin/gs\"
#GS_LIB=-DGS_LIB=\"\"
#GS_DEV=-DGS_DEV=\"pbmraw\"


# if, for whatever reason, you're unable to get the JPEG library to compile
# on your machine, *COMMENT OUT* the following lines
#
# Also, comment out the LIBJPEG dependancy at the end of this Makefile
#
JPEG = -DHAVE_JPEG
JPEGDIR = jpeg
LIBJPEG = $(JPEGDIR)/libjpeg.a
JPEGINCLUDE = -I$(JPEGDIR)


# if, for whatever reason, you're unable to get the TIFF library to compile
# on your machine, *COMMENT OUT* the following lines
#
# Also, comment out the LIBTIFF dependancy at the end of this Makefile
#
TIFF = -DHAVE_TIFF
TIFFDIR = tiff
LIBTIFF = $(TIFFDIR)/libtiff.a
TIFFINCLUDE = -I$(TIFFDIR)


# if, for whatever reason, you're unable to get the PDS/VICAR support
# to compile (xvpds.c, and vdcomp.c), *COMMENT OUT* the following line,
# and also remove 'vdcomp' from the 'all:' dependancy 
PDS = -DHAVE_PDS


# if you are running under DXWM, I pity you.  XV doesn't work correctly
# under DXWM.  You should probably be running MWM.  However, if such is
# not an option for you, try uncommenting the following line.  The
# behavior won't be 'right', but it will be less 'wrong'.
#DXWM = -DDXWM


#if your system doesn't have u_long, u_short ... typedefined  
#uncomment the following line:
#BSDTYPES = -DBSDTYPES


# if your system *doesn't* have a /usr/include/dirent.h, (ie, isn't POSIX
# compliant, then you may have to uncomment the following line to use the
# 'old-style' directory-handling structures
#
#NODIRENT = -DNODIRENT


# for UMAX V by Encore Computers uncomment the following line for
# the portable c compiler, system specific definitions and
# location of local X11 library(if site specific, modify -L option)
# No other switches should be necessary
#
#UMAX =  -q extensions=pcc_c -D__UMAXV__ -L/usr2/usr/lib/X11 -DSVR4


# if your machine doesn't have 'random()', but does have 'rand()',
# uncomment the following line:
#
#RAND = -DNO_RANDOM


# IF YOUR MACHINE DOESN'T HAVE 'vprintf()' OR 'vsprintf()'
#  (see vprintf.c for more information, if needed)
#  (for BSD 4.3 VAX, uncomment the following line)
#VPRINTF = -DNEED_VPRINTF -DINTSPRINTF -DLONGINT -DNOVOID
#  (for (stock) IBM RT AOS 4.3, uncomment the following line)
#VPRINTF = -DNEED_VPRINTF -DLONGINT -DNOSTDHDRS
#  (for Sequent running DYNIX 3.1.4, uncomment the following line)
#VPRINTF = -DNEED_VPRINTF -DLONGINT -DNOSTDHDRS




# If you are using an HP running HPUX 7.0, uncomment the following line
#
#HPUX7 = -DSVR4 +Ns4000 -DHPUX7


# If you are using an SGI system, uncomment the following line
SGI = -Dsgi


# For Interactive Unix System machines 
#   you'll want to modify LIBS to 
# LIBS = -lX11 $(LIBJPEG) $(LIBTIFF) -lm -lnsl_s -linet -lgen


# For SCO 1.1 (UNIX 3.2v2) machines, uncomment the following:
#
#SCO = -Dsco -DPOSIX -DNOTIMER
#
# For ODT 2.0 (UNIX 3.2v4) machines, uncomment the following:
#
#SCO= -DPOSIX -DNO_RANDOM 
#
# Also, you'll want to add '-lc -lx' to the end of the LIBS def below
#
# -lx must be after -lc so you get the right directory routines.
#


################ END OF CONFIGURATION OPTIONS #################





CFLAGS = $(CCOPTS) $(JPEG) $(JPEGINCLUDE) $(TIFF) $(TIFFINCLUDE) $(PDS) \
	$(GS_PATH) $(GS_DEV) $(GS_LIB) \
	$(BACKING_STORE) $(NODIRENT) $(VPRINTF) $(TIMERS) \
	$(UNIX) $(BSDTYPES) $(RAND) $(DXWM) \
	$(SGI) $(SCO) $(HPUX7) $(UMAX)

LIBS = -lX11 $(LIBJPEG) $(LIBTIFF) -lm

BITMAPS = bitmaps/grasp bitmaps/penn bitmaps/down bitmaps/down1 \
	  bitmaps/up bitmaps/up1 bitmaps/scrlgray bitmaps/gray50 \
	  bitmaps/gray25 bitmaps/i_fifo bitmaps/i_chr bitmaps/i_dir \
	  bitmaps/i_blk bitmaps/i_lnk bitmaps/i_sock bitmaps/i_reg \
	  bitmaps/i_exe bitmaps/rb_frame bitmaps/rb_frame1 bitmaps/rb_body \
	  bitmaps/rb_top bitmaps/rb_dtop bitmaps/rb_bot bitmaps/rb_dbot \
	  bitmaps/rb_dot bitmaps/uph bitmaps/uph1 bitmaps/downh \
	  bitmaps/downh1 \
	  bitmaps/fc_left bitmaps/fc_leftm bitmaps/fc_mid bitmaps/fc_midm \
	  bitmaps/fc_right bitmaps/fc_rightm bitmaps/fc_left1 \
	  bitmaps/fc_left1m bitmaps/fc_right1 bitmaps/fc_right1m \
	  bitmaps/icon bitmaps/dial_cw1 bitmaps/dial_cw2 bitmaps/dial_ccw1 \
	  bitmaps/dial_ccw2 bitmaps/iconmask bitmaps/gf1_addh \
	  bitmaps/gf1_delh bitmaps/gf1_line bitmaps/gf1_rst \
	  bitmaps/gf1_spln bitmaps/gf1_gamma \
	  bitmaps/h_rotl bitmaps/h_rotr bitmaps/h_sinc bitmaps/h_sdec \
	  bitmaps/h_flip bitmaps/cb_check \
	  bitmaps/h_sat bitmaps/h_desat bitmaps/root_weave \
          bitmaps/cboard50 bitmaps/mb_chk bitmaps/fliph bitmaps/flipv \
	  bitmaps/p10 bitmaps/m10

OBJS = 	xv.o xvevent.o xvroot.o xvmisc.o xvimage.o xvcolor.o xvsmooth.o \
	xv24to8.o xvgif.o xvpm.o xvinfo.o xvctrl.o xvscrl.o xvalg.o xvxpm.o\
	xvgifwr.o xvdir.o xvbutt.o xvpbm.o xvxbm.o xvgam.o xvbmp.o \
	xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
	xvtiff.o xvtiffwr.o xvpds.o xvrle.o xviris.o xvgrab.o vprintf.o \
	xvbrowse.o xvtext.o xvpcx.o

MISC = README INSTALL CHANGELOG IDEAS

.c.o:	; $(CC) -c $(CFLAGS) $*.c

all: $(LIBJPEG) $(LIBTIFF) xv bggen vdcomp xcmap

xv: $(OBJS) $(LIBJPEG) $(LIBTIFF)
	$(CC) -o xv $(CFLAGS) $(OBJS) $(LIBS)

bggen: bggen.c
	$(CC) $(CFLAGS) -o bggen bggen.c

vdcomp: vdcomp.c
	$(CC) $(CFLAGS) -o vdcomp vdcomp.c

xcmap:  xcmap.c
	$(CC) $(CFLAGS) -o xcmap xcmap.c $(LIBS)

xvclean:
	rm -f $(OBJS) xv
	
clean:  xvclean
	rm -f bggen vdcomp xcmap
# comment out one or both of the following if you aren't using the JPEG and
# TIFF libraries
	( cd $(JPEGDIR) ; make clean )
	( cd $(TIFFDIR) ; make clean )


tar:
	tar cf xv.tar Makefile* Imakefile *.c *.h bitmaps \
		docs unsupt vms $(JPEGDIR) $(TIFFDIR) $(MISC) 


$(OBJS):   xv.h
xv.o:      bitmaps.h
xvbutt.o:  bitmaps.h
xvctrl.o:  bitmaps.h
xvdial.o:  bitmaps.h
xvinfo.o:  bitmaps.h
xvmisc.o:  bitmaps.h
xvscrl.o:  bitmaps.h
xvgraf.o:  bitmaps.h

xvdflt.o:  bitmaps/xvpic_logo_top bitmaps/xvpic_logo_bot bitmaps/xvpic_logo_out
xvdflt.o:  bitmaps/xv_rev bitmaps/xv_jhb bitmaps/xv_cpyrt
xvdflt.o:  bitmaps/xf_left bitmaps/xf_right bitmaps/font5x9.h


bitmaps.h: $(BITMAPS)
	cat $(BITMAPS) > bitmaps.h




# if, for whatever reason, you're unable to get the JPEG library to compile
# on your machine, *COMMENT OUT* the following lines
#
$(LIBJPEG):
	( cd $(JPEGDIR) ; make CC='$(CC)' libjpeg.a )

# if, for whatever reason, you're unable to get the TIFF library to compile
# on your machine, *COMMENT OUT* the following lines
#
$(LIBTIFF):
	( cd $(TIFFDIR) ; make CC='$(CC)')

