/* if, for whatever reason, you're unable to get the JPEG library to compile
 * on your machine, *COMMENT OUT* the following line
 */
#define HaveJpeg


/* if, for whatever reason, you're unable to get the TIFF library to compile
 * on your machine, *COMMENT OUT* the following line
 */
#define HaveTiff


/* 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
 */
PDS = -DHAVE_PDS


/* if, for whatever reason, you don't wish to use the fsQuick software
 * (which currently only affects xv's performance on a 1-bit display)
 * you should comment out the following line
 * (fsQuick.c contains some *huge* macro definitions which might blow up
 * your C preprocessor)
 */
FSQUICK = -DHAVE_FSQUICK

/* 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 a valid option for you, try uncommenting the following line.  The
 * behavior won't be 'right', but it will be less 'wrong'.
 */
/* DXWM = -DDXWM */

/*
 * if you are running on a SysV-based machine, such as HP, Silicon Graphics,
 * etc, uncomment the following line to get you *most* of the way there.
 */
/* UNIX = -DSVR4 */

/*
 * If you are running on a POSIX-compatible machine, such as an
 * IBM RS6000, you MAY need uncomment the 'NEED_DIRENT' line.
 * To determine if such is the case, do a 'man readdir' on your machine.  If
 * readdir() returns a pointer to 'struct direct', you will not have
 * to change anything.  If, however, readdir() returns a pointer to
 * 'struct dirent', you will have to add the '-DDIRENT' to CFLAGS
 *
 * One note: folks using an IBM RS/6000 don't have to touch this line.  
 *           I check for '6000'-hood in xv.h
 */
/* NEED_DIRENT = -DDIRENT */


/* If your machine doesn't have the 'strchr', 'memset' and 'memcpy'
 * functions, but does have 'bcopy', uncomment the following line:
 */
/* USEMEM= -DNEED_MEMROUTINES */


/* IF YOUR MACHINE DOESN'T HAVE 'vprintf()' OR 'vsprintf()'
 *
 * Vax BSD and IBM AOS don't have vprintf or vsprintf.
 * Note that our local library versions of sprintf have been updated
 * to return int, the number of characters in the formatted string,
 * whereas the versions in stock 4.3BSD do not so return.  You may
 * have to remove the "-DINTSPRINTF" below if you're compiling for
 * stock 4.3BSD or for some other Vax or RT library package where
 * sprintf returns char *.
 *
 * Also, I define NOVOID on the Vax because I'm using pcc to compile.
 * If you use gcc or some other better compiler, this should not be
 * necessary.  I define NOSTDHDRS on the RT because we don't have
 * standard ANSI header files installed for the RT, even though the RT
 * compiler claims to be ANSI-compliant.
 */
#if defined(VaxArchitecture) && !defined(UltrixArchitecture)
VPRINTF=	-DNEED_VPRINTF -DINTSPRINTF -DLONGINT -DNOVOID
#else 
#  if defined(RtArchitecture) && !defined(AIXArchitecture)
VPRINTF=	-DNEED_VPRINTF -DINTSPRINTF -DLONGINT -DNOSTDHDRS
#  else
#    if defined(SequentArchitecture)
VPRINTF= -DNEED_VPRINTF -DLONGINT -DNOSTDHDRS
#    endif
#  endif
#endif


/* If your machine does not have the 'setitimer()' call, 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:
 */
/* TIMERS = -DNOTIMER */


/* If you are using an AT&T machine, uncomment the following line
 * If you have problems compiling xv.c and xvdir.c because of the DIR
 * reference in dirent.h, append '-DATT' to the following line:
 */
/* ATT = -DSVR4 -DDIRENT -DUSLEEP -DATT */


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


/* for UMAX V by Encore Computers uncomment the following line for
 * the portable c compiler, and system specific definitions.
  * No other switches should be necessary
 */
/* UMAX = -q extensions=pcc_c -D__UMAXV__ -DSVR4 -DDIRENT */

/* If your machine doesn't have the 'random()' function, and only
 * has 'rand()', uncomment the following line:
 */
/* RAND= -DNO_RANDOM */

/* This should mark the end of the configuration parameters */

#ifdef HaveJpeg
JPEG = -DHAVE_JPEG
JPEGDIR = jpeg
LIBJPEG = $(JPEGDIR)/libjpeg.a
JPEGINCLUDE = -I$(JPEGDIR)
#endif

#ifdef HaveTiff
TIFF = -DHAVE_TIFF
TIFFDIR = tiff
LIBTIFF = $(TIFFDIR)/libtiff.a
TIFFINCLUDE = -I$(TIFFDIR)
#endif

#if defined(SCOArchitecture)
SCO= -DPOSIX -DNOITIMER
SYS_LIBRARIES=        $(XLIB) $(LIBJPEG) $(LIBTIFF) -lm -lc -lx 
#else
SYS_LIBRARIES=        $(XLIB) $(LIBJPEG) $(LIBTIFF) -lm
#endif


DEFINES= $(SCO) $(UNIX) $(NEED_DIRENT) $(VPRINTF) $(TIMERS) $(ATT) \
	$(USEMEM) $(HPUX7) $(JPEG) $(DXWM) $(UMAX) \
	$(FSQUICK) $(RAND) $(TIFF) $(PDS)

INCLUDES = $(JPEGINCLUDE) $(TIFFINCLUDE)

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/rb_off bitmaps/rb_on bitmaps/rb_off1 bitmaps/rb_on1 \
	  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_off bitmaps/cb_on bitmaps/cb_off1 \
	  bitmaps/cb_on1 bitmaps/h_sat bitmaps/h_desat bitmaps/root_weave \
          bitmaps/cboard50 bitmaps/mb_chk bitmaps/fliph bitmaps/flipv


SRCS1 =	xv.c xvevent.c xvroot.c xvmisc.c xvimage.c xvcolor.c xvsmooth.c \
	xv24to8.c xvgif.c xvpm.c xvinfo.c xvctrl.c xvscrl.c \
	xvgifwr.c xvdir.c xvbutt.c xvpbm.c xvxbm.c xvgam.c \
	xvdial.c xvgraf.c xvsunras.c xvjpeg.c xvps.c xvpopup.c xvdflt.c \
	xvtiff.c xvtiffwr.c xvpds.c xvrle.c xvgrab.c vprintf.c fsQuick.c

OBJS1 =	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 \
	xvgifwr.o xvdir.o xvbutt.o xvpbm.o xvxbm.o xvgam.o \
	xvdial.o xvgraf.o xvsunras.o xvjpeg.o xvps.o xvpopup.o xvdflt.o \
	xvtiff.o xvtiffwr.o xvpds.o xvrle.o xvgrab.o vprintf.o fsQuick.o

SRCS2=	bggen.c
OBJS2=	bggen.o

SRCS3=	vdcomp.c
OBJS3=	vdcomp.o

PROGRAMS= xv bggen vdcomp

all::
	@echo ""
	@echo "  Did you remember to 'make depend' first?"
	@echo ""

#ifdef HaveJpeg
all::	
	@echo "  building libjpeg.a ..."
	@echo ""
	( cd $(JPEGDIR) ; $(MAKE) CC='$(CC)' libjpeg.a )
	@echo ""
#endif

#ifdef HaveTiff
all::	
	@echo "  building libtiff.a ..."
	@echo ""
	( cd $(TIFFDIR) ; $(MAKE) CC='$(CC)')
	@echo ""
#endif

all::
	@echo "  building xv ..."
	@echo ""


#ifdef HaveJpeg
clean::
	@echo ""
	@echo "  cleaning in $(JPEGDIR) ..."
	@echo ""
	( cd $(JPEGDIR) ; $(MAKE) clean )
	@echo ""
#endif

#ifdef HaveTiff
clean::
	@echo "  cleaning in $(TIFFDIR) ..."
	@echo ""
	( cd $(TIFFDIR) ; $(MAKE) clean )
	@echo ""
#endif


/* depend:: bitmaps.h */


SRCS = $(SRCS1) $(SRCS2) $(SRCS3)
DependTarget()
  
AllTarget($(PROGRAMS))

NormalProgramTarget(xv,$(OBJS1),$(DEPLIBS),$(LOCAL_LIBRARIES),$(SYS_LIBRARIES))
NormalProgramTarget(bggen,$(OBJS2),$(DEPLIBS),\
			$(LOCAL_LIBRARIES),$(SYS_LIBRARIES))
NormalProgramTarget(vdcomp,$(OBJS3),$(DEPLIBS),\
			$(LOCAL_LIBRARIES),$(SYS_LIBRARIES))

 
InstallProgram(xv,$(BINDIR))
InstallProgram(bggen,$(BINDIR))
InstallProgram(vdcomp,$(BINDIR))
 
InstallManPageLong(docs/xv,$(MANDIR),xv)
InstallManPageLong(docs/bggen,$(MANDIR),bggen)

/* ComplexProgramTarget_1(xv,,)
 * ComplexProgramTarget_2(bggen,,)
 * ComplexProgramTarget_3(vdcomp,,)
 * 
 * InstallManPage(docs/xv,$(MANDIR))
 * InstallManPage(docs/bggen,$(MANDIR))
 */

tar:
	tar cf xv.tar Makefile *.c *.h bitmaps docs $(MISC)

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