# Description file for rle get programs. ($rget)

# These lines are processed by an awk script to include or
# remove specific programs
# In an Alpha_1 system, they would be automatically inserted by the configure
# action.
#
#begin defs

##define FB		BRL extended frame buffer library
#define XWINDOWS	X Window system
#define DEV_GRINNELL	Grinnell GMR27 frame buffer
##define APOLLO		Apollo computer display
#define CX3D		Chromatics CX3D system
##define IRIS		Silicon Graphics Iris 2000/3000
##define IRIS4D		Silicon Graphics Iris/4D
##define BOBCAT		HP bobcat
##define SUNTOOLS	For Suns running SunTools
##define SUNCC		For SUN CC flags

#end defs

#
# DEST is where to install the tools 
# RI is the include directory for RLE files
# RL is the library directory (for librle.a)

DEST = ../../bin
RI = ../include
RL = ../lib

LIBES = $(RL)/librle.a
CFLAGS = -O $(DFLAGS) $(IFLAGS) $(MachFLAGS)
IFLAGS = -I. -I$(RI)
# System V make pays attention to the SHELL environment variable. Override it.
SHELL = /bin/sh

# Executables.  The .out will be stripped off in the install action.
#ifadd	FB		PGMS		getfb.out
#ifadd	XWINDOWS	PGMS		getX.out
#ifadd  APOLLO		PGMS		getap.out
#ifadd	IRIS		PGMS		getmex.out
#ifadd	IRIS		PGMS		getiris.out
#ifadd	IRIS4D		PGMS		get4d.out
#ifadd	BOBCAT		PGMS		getbob.out
#ifadd  BOBCAT		PGMS		getren.out
#ifadd	BOBCAT		PGMS		read98721.out
#ifadd	SUNTOOLS	PGMS		getsun.out
#ifadd	DEV_GRINNELL	DIRS		gmr27
#ifadd	CX3D		DIRS		cx3d
#emit PGMS
PGMS =  getX.out

#emit DIRS
DIRS =  gmr27 cx3d

# ALLDIRS is all subdirectories, regardless of whether they are active
ALLDIRS = gmr27 cx3d

# Machine dependent compiler flags
#ifadd	SUNCC		MachFLAGS	-f68881
#emit MachFLAGS
MachFLAGS = 

# Default is what is to be made if nothing is specified.
default: $(PGMS) subdirs

subdirs:
	@ echo Make subdirs
	@-if [ 'x$(DIRS)' != x ] ; then eval \
		'for dir in $(DIRS) ; do\
			(cd $$dir ; make $(MFLAGS) ) ; \
		done' ; \
	  else \
		true ; \
	  fi

# Everything depends on the svfb globals and libraries.
$(PGMS): $(RI)/svfb_global.h $(LIBES)

# Programs that need specific make rules (presumably all of them)

#ifdef FB
# getfb - get to a BRL libfb display
#@LIBFB = /usr/brl/lib/libfb.a
#@getfb.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(LIBFB) -lm -o $*.new
#@	mv $*.new $@
#endif

#ifdef XWINDOWS
# getX - get to an X display
XLIBES = -lX
getX.out:
	$(CC) $(CFLAGS) $< $(LIBES) $(XLIBES) -lm -o $*.new
	mv $*.new $@
#endif

#ifdef APOLLO
# getap - get to an Apollo display
# will build with the default rule
#endif APOLLO

#ifdef IRIS
# getmex - get to a mex window on an Iris 2000 or 3000.
#@IRISLIBES = -Zg
#@getmex.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(IRISLIBES) -lm -o $*.new
#@	mv $*.new $@
# getiris - get to an Iris ( no mex )
#@getiris.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(IRISLIBES) -lm -o $*.new
#@	mv $*.new $@
#endif

#ifdef IRIS4D
# get4d - get to a max window on an Iris/4D.
#@IRIS4DLIBES = -lgl_s
#@get4d.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(IRIS4DLIBES) -lm -o $*.new
#@	mv $*.new $@
#endif

#ifdef BOBCAT
# getbob - get to an HP Bobcat (series hp9000/300)
#@BOBLIBES = -ldd98700 -ldd98710 -ldd98721 -ldd300h -lddbyte -lsb1 -lsb2
#@getbob.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(BOBLIBES) -lm -o $*.new
#@	mv $*.new $@
#@getren.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(BOBLIBS) -lm -o $*.new
#@	mv $*.new $@
#@read98721.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(BOBLIBS) -lm -o $*.new
#@	mv $*.new $@
#endif

#ifdef SUNTOOLS
# getsun - display on Suns running SunTools
#@SUNTOOLLIBS = -lsuntool -lsunwindow -lpixrect
#@getsun.out:
#@	$(CC) $(CFLAGS) $< $(LIBES) $(SUNTOOLLIBS) -lm -o $*.new
#@	mv $*.new $@
#endif

# Incremental install, copies everything ("$?") since last install to DEST dir.
install: install-pgm install-subdirs

install-pgm: $(PGMS)
	-for pgm in $?; do cp $$pgm $(DEST)/`basename $$pgm .out`; done
	touch install-pgm

install-subdirs: subdirs
	@ echo Install on subdirs
	@-if [ 'x$(DIRS)' != x ] ; then eval \
		'for dir in $(DIRS) ; do\
			(cd $$dir ; make $(MFLAGS) install) ; \
		done' ; \
	  else \
		true ; \
	  fi

# Reconstruct makefile for current set of defines
# Due to the way makefile dependencies work, we can't do this here
# (I want makedefs to depend on makefile, so makefile can't depend on
# makedefs)  Therefore, 'make depend' will rebuild the makefile (or
# 'make makedefs'
makefile: 

makedefs: makefile
	awk -f makedef.awk makefile >makefile.tmp
	mv makefile.tmp makefile
	touch makedefs

# No automatic dependency generation (but rebuild makefile if necessary)
depend: makedefs
	touch depend

# Clean up installed stuff and binaries
pristine: clean
	-for pgm in $(PGMS); do rm -f $(DEST)/`basename $$pgm .out`; done
	-for dir in $(ALLDIRS); do \
		if [ -d $$dir ] ; then \
			(cd $$dir; make $(MFLAGS) pristine); \
		else \
			true; \
		fi; \
	done

# Clean up binaries.
clean:
	-rm -f $(PGMS) install*
	-rm -f *.o *.out *.new
	-for dir in $(ALLDIRS); do \
		if [ -d $$dir ] ; then \
			(cd $$dir; make $(MFLAGS) clean); \
		else \
			true; \
		fi; \
	done

# Default rule for making a program from its .c file.
# The mv will not be done if there is an error, so a broken program
# will not be left around.
.SUFFIXES:
.SUFFIXES: .out .c
.c.out:
	$(CC) $(CFLAGS) $< $(LIBES) -lm -o $*.new
	mv $*.new $@
# Dependency lines.  Make sure to #ifdef them.
# DO NOT DELETE THIS LINE

#ifdef XWINDOWS
getX.o: ${RI}/svfb_global.h
#endif XWINDOWS
#ifdef APOLLO
#@getap.o: ${RI}/svfb_global.h
#endif APOLLO
#ifdef FB
#@getfb.o: ${RI}/svfb_global.h
#endif FB
#ifdef IRIS
#@getmex.o: ${RI}/svfb_global.h
#@getiris.o: ${RI}/svfb_global.h
#endif IRIS
#ifdef IRIS4D
#@get4d.o: ${RI}/svfb_global.h
#endif IRIS4D
