#-----------------------------------------------------------------------------
#			Makefile for gdb960
#
# $Id: Makefile,v 1.23 89/11/30 18:28:22 chrisb Exp $
#-----------------------------------------------------------------------------

# The following lines should be uncommented for system V (i386v).
#__i386v__#USG = -DUSG
#__i386v__#USG_OBJS = regex.o
#__i386v__#LIBS = -lPW

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

OBJS =	blockframe.o breakpoint.o command.o environ.o eval.o expprint.o \
	expread.o findvar.o infcmd.o inflow.o infrun.o main.o obstack.o \
	i960-md.o i960-pinsn.o printcmd.o remote.o source.o stack.o symmisc.o \
	symtab.o utils.o valarith.o valops.o valprint.o values.o \
	version.o $(USG_OBJS)

BOUTOBJS = boutcore.o dbxread.o

COFFOBJS = coffcore.o coffread.o


gdb960: $(OBJS) $(BOUTOBJS) VERSION
	make ver960.o
	$(CC) -o gdb960 $(OBJS) $(BOUTOBJS) ver960.o $(LIBS)

# The following target makes a version that will handle COFF object files
# produced by Intel's asm960.
gdb960c: $(OBJS) $(COFFOBJS) VERSION
	make ver960.o
	$(CC) -o gdb960c $(OBJS) $(COFFOBJS) ver960.o $(LIBS)


boutcore.o:	core.c defs.h param.h ${IPATH}/b.out.h
	$(CC) $(CFLAGS) -c core.c
	mv core.o boutcore.o

coffcore.o:	core.c defs.h param.h ${IPATH}/coff.h
	$(CC) $(CFLAGS) -DCOFF_FORMAT -c core.c
	mv core.o coffcore.o


param.h:  m-i960.h
	ln -s m-i960.h param.h 2>/dev/null || ln m-i960.h param.h

blockframe.o:	blockframe.c defs.h param.h symseg.h symtab.h frame.h
breakpoint.o:	breakpoint.c defs.h param.h symseg.h symtab.h frame.h
command.o:	command.c command.h
coffread.o:	coffread.c defs.h param.h symseg.h symtab.h ${IPATH}/coff.h
dbxread.o:	dbxread.c defs.h param.h symseg.h symtab.h ${IPATH}/b.out.h
dbxread.o:	${IPATH}/stab.h ${IPATH}/stab.def
environ.o:	environ.c environ.h
expprint.o:	expprint.c defs.h symseg.h symtab.h expression.h
expread.tab.c:	expread.y
	@echo 'Expect 101 shift/reduce conflicts and 1 reduce/reduce conflict.'
	yacc expread.y
	mv y.tab.c expread.tab.c
expread.o:	expread.tab.c defs.h param.h symseg.h symtab.h frame.h \
			expression.h
	$(CC) -c ${CFLAGS} expread.tab.c
	mv expread.tab.o expread.o
eval.o:		eval.c defs.h symseg.h symtab.h value.h expression.h
findvar.o:	findvar.c defs.h param.h symseg.h symtab.h frame.h value.h
i960-pinsn.o:	i960-pinsn.c defs.h
i960-md.o:	i960-md.c defs.h frame.h param.h symtab.h value.h
infcmd.o:	infcmd.c defs.h param.h symseg.h symtab.h frame.h inferior.h
infcmd.o:	environ.h value.h
inflow.o:	inflow.c defs.h param.h frame.h inferior.h
infrun.o:	infrun.c defs.h param.h symseg.h symtab.h frame.h inferior.h
infrun.o:	${IPATH}/wait.h
main.o:		main.c defs.h command.h
obstack.o:	obstack.c
printcmd.o:	printcmd.c defs.h param.h symseg.h symtab.h value.h expression.h
printcmd.o:	frame.h
regex.o:	regex.c regex.h
remote.o:	remote.c defs.h param.h frame.h inferior.h ${IPATH}/wait.h
remote.o:	${IPATH}/demux.h ${IPATH}/ttycntl.h ${IPATH}/env.h
source.o:	source.c defs.h param.h symseg.h symtab.h
stack.o:	stack.c defs.h param.h symseg.h symtab.h frame.h
symmisc.o:	symmisc.c defs.h symseg.h symtab.h
symtab.o:	symtab.c defs.h param.h symseg.h symtab.h
utils.o:	utils.c defs.h
valarith.o:	valarith.c defs.h param.h symseg.h symtab.h value.h expression.h
valops.o:	valops.c defs.h param.h symseg.h symtab.h value.h
valprint.o:	valprint.c defs.h param.h symseg.h symtab.h value.h
values.o:	values.c defs.h param.h symseg.h symtab.h value.h
version.o:	version.c

#-----------------------------------------------------------------------------
#		'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/${TARG}

clean:
	rm -f gdb960 gdb960c ${OBJS} ${BOUTOBJS} ${COFFOBJS} ${USG_OBJS} 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
