# This is the top level make file for ltplus.
# You should edit only the top section of this file
# to reflect your system configuration before you use this makefile.


###############################################################################

# if your system does not have 'ranlib' then use the one with lorder and tsort

#LIBRULE = 'ar rc $$@ `lorder $$(OBJ) | tsort`'
LIBRULE = 'ar ruv $$@ $$?; ranlib $$@'

###############################################################################

#
#  for Machines with  'Big-endian' word ordering you must specify -DBIG_ENDIAN
#   This is All sun machines except 386i, any 68000 based machine
#
#  Little-endian machines include  Dec-stations, 386 based machines and
#    Intergraphs

#  -DLTP_X11 is to compile in X11 code instead of VGA


# The next line is for compilation on the Suns
#SUN_CFLAGS = -O -DLTP_X11 -DBIG_ENDIAN -DMULTIUSER 

# The next line is for compilation for DECStations/Ultrix
#DEC_CFLAGS = -O -DLTP_X11 -DMULTIUSER -DULTRIX

# The next line is for Mips RISCos or CDC EP/IX
MIPS_CFLAGS = -O -DLTP_X11 -DBIG_ENDIAN -DMULTIUSER
CC = /usr/bin/cc

# The next line is for compilation for XENIX
XENIX_CFLAGS = -O -DXENIX

###############################################################################


########### User modifiable parameters ########################################

#  Command to start a window under X
#XTERM_CMD	= /usr/openwin/bin/xterm
XTERM_CMD	= xterm

#  command to copy files
#COPY_CMD	= copy
COPY_CMD	= cp

#  command to compress raster bitmaps  (ltplus default is 'pack')
RASTER_PACK	= pack

#  command to compress all other files  (ltplus default is 'compress')
GENERAL_PACK	= compress

#  directory where ltplus files exist  [ Will probably need to edit this ]
#				       [ or move files to /usr/local/ltp ]
#LTP_BASE_DIR	= /usr/local/ltp
LTP_BASE_DIR	= /GRASS.bin/4.1/mips/etc

#  directory where ltplus and ltpgo  executables will go
#LTP_BIN_DIR	= /usr/local/bin
LTP_BIN_DIR	= /GRASS.bin/4.1/mips/bin

#  compilation flags.  Generally set from options above by Operating system type
#C_FLAGS 	= ${SUN_CFLAGS} 
#C_FLAGS 	= ${XENIX_CFLAGS} 
#C_FLAGS 	= ${DEC_CFLAGS} 
C_FLAGS	= ${MIPS_CFLAGS} 

###############################################################################
###########   >>>>>    Do not edit below this line     <<<<<  #################
###############################################################################


all: make.header ltplus ltpgo

make.header:
	echo C_FLAGS = ${SUN_CFLAGS} 		> make.head
	echo XTERM_CMD=${XTERM_CMD}  		>> make.head
	echo RASTER_PACK=${RASTER_PACK} 	>> make.head
	echo GENERAL_PACK=${GENERAL_PACK}  	>> make.head
	echo LTP_BASE_DIR=${LTP_BASE_DIR} 	>> make.head
	echo LTP_BIN_DIR=${LTP_BIN_DIR}		>> make.head
	echo COPY_CMD=${COPY_CMD}		>> make.head
	echo LIBRULE=${LIBRULE} 		>> make.head
	echo CC=${CC}				>> make.head

	echo 'CFLAGS=${C_FLAGS} \
		-DXTERM_CMD=\"${XTERM_CMD}\" \
		-DRASTER_PACK=\"${RASTER_PACK}\" \
		-DGENERAL_PACK=\"${GENERAL_PACK}\" \
		-DLTP_BASE_DIR=\"${LTP_BASE_DIR}\" \
		-DCOPY_CMD=\"${COPY_CMD}\" \
		-DLTP_BIN_DIR=\"${LTP_BIN_DIR}\" '  >> make.head


fclibrary:
	cat make.head fc/Makefile.orig > fc/Makefile 
	(cd fc; make)

fmlibrary:
	cat make.head fm/Makefile.orig > fm/Makefile
	(cd fm; make)

ltplus: fclibrary fmlibrary
	cat make.head in/Makefile.orig > in/Makefile
	(cd in; make)

ltpgo:
	cat make.head ipc/Makefile.orig > ipc/Makefile
	(cd ipc; make)

clean: 
	-(cd fc; make clean)
	-(cd fm; make clean)
	-(cd in; make clean)
	-(cd ipc; make clean)
