# Makefile for the file conversion utility
# Peter Webb, Summer 1990
# 
# This file must be modified in order to build the distribution properly.
# In particular, the parameters that specify the operating system and the
# location of HDF and X (if X is installed) must be changed to conform to your
# local configuration.
#
# Type 'make withoutx' for the version that does not use the X window system.
# Type 'make withx' if you want a X-based graphical user interface.

SHELL=/bin/sh

# The operating system.  Set this as appropriate for your machine.  Only one
# of these should be set at any given time.

#OS = BSD4 	# Berkelely Unix (SUNs, Ultrix, etc) 
OS = SYSV  	# System V Unix (Motorola, AT&T) 
#OS = UNICOS  	# Cray Unicos

# Particular machines.  Only one should be set at a time.

#MACHINE = -DSUN
#MACHINE = -DDEC
MACHINE = -DIRIS4

# Location of the pbmplus routines on your system - this can be blank, if
# you don't have pbmplus.  In fact, pbmplus is NOT necessary for running
# either version of reformat, but may be used in future releases.  pbmplus is
# distributed on the X tape from MIT.

PBM = 
# PBM = /stg3/pbmplus

# No change needed here.

DEFS = -D$(OS) -DPBM=\"$(PBM)\" $(X) $(MACHINE)

# Locations of the HDF include files and the object library.  Must be changed
# as appropriate for your system.

HDFINC = /stg3/include/hdf
HDFLIB = /stg3/lib/sgi

# If you are using X, this must be set to the top of the X source tree.

XINC = /sdg/include
XLIB = /sdg/lib

# Flags passed to the C compiler.  Leave these alone.

CFLAGS = $(DEFS) -O -DDEBUG -I. -I$(XINC) -I$(HDFINC)

# Used in the command-line interface version.

OFILES = cmdline.o error.o utils.o reformat.o \
	usage.o scandir.o tiff2ri8.o write_hdf.o\
	write_tiff.o write_gif.o write_fits.o append_type.o debug.o\
	gif2ri8.o fits2hdf.o strsave.o xwd2ri8.o write_xwd.o write_sunrst.o\
	write_raw8.o raw8tori8.o sun2ri8.o

# Support for the X graphical user interface.

XFILES = window.o callback.o init_widgets.o confirm.o

XOFILES = $(OFILES) $(XFILES)

tiff2ri8.o : tiff2ri8.h

window.o : window.h options.h

init_widgets.o : window.h

callback.o : window.h

$(XOFILES) : error.h extern.h types.h reformat.h $(CHECK) 

# Be sure to add -lbsd if compiling in a SYSV environment

LIBS =  $(HDFLIB)/libdf.a -lm

XLIBS = $(HDFLIB)/libdf.a $(XLIB)/libXaw.a $(XLIB)/libXmu.a $(XLIB)/libXext.a $(XLIB)/libXt.a $(XLIB)/libX11.a -lm

# Flags for use with lint

LINTFLAGS = -ac -I$(HDFINC) $(DEFS) 

withx :
	if test -f reformat -a -f xreformat; then \
 	  find reformat -newer xreformat -exec make clean ';' ; \
	else if test -f reformat ; then \
	         make clean ; \
	      fi \
	fi
	$(MAKE) "X = -DXGUI" xreformat ;

withoutx :
	if test -f xreformat -a -f reformat ; then \
	    find xreformat -newer reformat -exec make clean ';' ; \
 	else if test -f xreformat ; then \
	        make clean ; \
	     fi \
 	fi
	$(MAKE) reformat ;

syntax: $(OFILES:.o=.ln)

reformat : $(OFILES)
	$(CC) $(CFLAGS) -o $@ $(OFILES) $(LIBS)

xreformat : $(XOFILES)
	$(CC) $(CFLAGS) -o $@ $(XOFILES) $(XLIBS)

delint:
	rm -f $(OFILES:.o=.ln)

clean:
	rm -f $(XOFILES) $(OFILES:.o=.ln)

