# - added SLACKWARE/Linux support 28. Nov. 98 MN
# - added REDHAT/Linux support 22. Nov. 98 Carl Anderson
# - Corrected 15. April 1998 - Markue Neteler
# - corrected LIBRULE 3. June 98 - MN

# 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 $$@'
LIBRULE = 'ar ruv $$@ $$?'

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

#
#  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 = -g -DLTP_X11 -DBIG_ENDIAN -DMULTIUSER -DREDHAT51 -DSUNOS -DX11BIT24

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

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

# The next line is for compilation on the intel REDHAT51
REDHAT_CFLAGS = -g -DLTP_X11 -DMULTIUSER -DX11BIT24 -DDEBUG -DSUNOS -DREDHAT51 

# The next line is for compilation on the intel SLACKWARE/Linux
SLACKWARE_CFLAGS = -g -DLTP_X11 -DMULTIUSER -DX11BIT24 -DDEBUG -DSUNOS

# -DDEBUG for verbose debugging messages
# -DX11BIT24 for 24 bit support
# -DDEBUGCOLOR for color check in main.c


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


########### 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/grass42/ltp

#  directory where ltplus and ltpgo  executables will go
LTP_BIN_DIR	= ${LTP_BASE_DIR}/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 	= ${SUN_CFLAGS} 
#C_FLAGS		= ${REDHAT_CFLAGS}
C_FLAGS		= ${SLACKWARE_CFLAGS}
# 
CC=gcc

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


all: make.header ltplus ltpgo

make.header:
	echo C_FLAGS = ${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 '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 CC=\"${CC}\")

fmlibrary:
	cat make.head fm/Makefile.orig > fm/Makefile
	(cd fm; make CC=${CC})

ltplus: fclibrary fmlibrary
	cat make.head in/Makefile.orig > in/Makefile
	mkdir -p ${LTP_BASE_DIR};
	mkdir -p ${LTP_BIN_DIR}
	(cd in; make CC=${CC})

ltpgo:
	cat make.head ipc/Makefile.orig > ipc/Makefile
	(cd ipc; make CC=${CC})

clean: 
	-(cd fc; make clean)
	-(cd fm; make clean)
	-(cd in; make clean)
	-(cd ipc; make clean)
	rm -rf OBJ*
