#-----------------------------------------------------------------------------
# Makefile for comm960 -- host/NINDY communications and download interface
#
# $Id: Makefile,v 1.14 89/11/30 18:25:09 chrisb Exp $
#-----------------------------------------------------------------------------

# The following 3 lines should be uncommented for system V (i386v).
#__i386v__#USG = -DUSG
#__i386v__#LIBS = -lPW
#__i386v__#SYSV_INCL = ${IPATH}/sysv.h

# The following lines should be uncommented for sun systems.
# (For some reason, shared libraries don't work when gdb960 forks/exec's
# comm960, which forks/exec's sx).
#__sun3__#LDFLAGS = -Bstatic
#__sun4__#LDFLAGS = -Bstatic
#__sun386i__#LDFLAGS = -Bstatic

TARG=comm960
OPT = -g
IPATH =	../../include
CFLAGS = ${OPT} ${USG} -I${IPATH} -DHOST=\"${HOST}\"
#	'HOST' will be defined in the host-specific makefile by 'make make'
OBJS = comm960.o


${TARG}: ${OBJS} VERSION
	make ver960.o
	${CC} ${LDFLAGS} -o ${TARG} ${OBJS} ver960.o ${LIBS}

comm960.o: ${IPATH}/b.out.h ${IPATH}/coff.h ${IPATH}/demux.h
comm960.o: ${IPATH}/ttycntl.h ${IPATH}/wait.h ${IPATH}/env.h ${SYSV_INCL}


#-----------------------------------------------------------------------------
#		'STANDARD' GNU/960 TARGETS BELOW THIS POINT
#
# 'VERSION' file must be present and contain a string of the form "x.y"
#-----------------------------------------------------------------------------

ver960.c: FORCE
	rm -f ver960.c
	echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c


# This target should be invoked before building a new release.
# 'VERSION' file must be present and contain a string of the form "x.y"
#
roll:
	@V=`cat VERSION`		; \
	MAJ=`sed 's/\..*//' VERSION`	; \
	MIN=`sed 's/.*\.//' VERSION`	; \
	V=$$MAJ.`expr $$MIN + 1`	; \
	rm -f VERSION			; \
	echo $$V >VERSION		; \
	echo Version $$V

# Dummy target to force execution of dependent targets.
#
FORCE:

# 'G960BASE' will be defined at invocation
#
install:
	make ${TARG} OPT=-O
	strip ${TARG}
	mv ${TARG} ${G960BASE}/bin

clean:
	rm -f ${TARG} *.o core

# Target to uncomment host-specific lines in this makefile.  Such lines must
# have the following string beginning in column 1: #__<hostname>__#
# Original Makefile is backed up as 'Makefile.old'.
#
# Invoke with:  make make HOST=xxx
#
make:
	-@if test $(HOST)x = x ; then \
		echo 'Specify "make make HOST=???"'; \
		exit 1; \
	fi ; \
	grep -s "^#The next line was generated by 'make make'" Makefile; \
	if test $$? = 0 ; then	\
		echo "Makefile has already been processed with 'make make'";\
		exit 1; \
	fi ; \
	mv -f Makefile Makefile.old; \
	echo "#The next line was generated by 'make make'"	 >Makefile ; \
	echo "HOST=$(HOST)"					>>Makefile ; \
	echo							>>Makefile ; \
	sed "s/^#__$(HOST)__#//" < Makefile.old			>>Makefile
