#-----------------------------------------------------------------------------
#		Makefile for gas960
#
# $Id$
#-----------------------------------------------------------------------------

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

# The following two lines should be uncommented for HP-UX
#__hp9000__#USG = -DUSG

# The following line should be uncommented for Macintosh A/UX.
#__mac-aux__#USG = -DUSG

#Always build with static libraries on Sun systems
#__sun3__#LDFLAGS = -Bstatic
#__sun386i__#LDFLAGS = -Bstatic
#__sun4__#LDFLAGS = -Bstatic

# Essential under System V, harmless elsewhere
SHELL = /bin/sh

TARG	= gas960
OPT	= -g
IPATH	= ../../include
CFLAGS	= ${OPT} ${USG} -DI80960 -I${IPATH}


OBJS =	app.o append.o as.o atof-generic.o bignum-copy.o expr.o \
	flonum-const.o flonum-copy.o flonum-mult.o frags.o gdb-blocks.o \
	gdb-file.o gdb-lines.o gdb-symbols.o gdb.o hash.o hex-value.o \
	input-file.o input-scrub.o messages.o obstack.o output-file.o read.o \
	strstr.o subsegs.o symbols.o version.o write.o xmalloc.o xrealloc.o

# Note that we use the 386 floating-point support for the i80960
I960OBJ	= i960.o i960-opcode.o atof-i386.o

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

hash.o:	hash.c
	${CC} -c ${CFLAGS} -Derror=as_fatal hash.c

xmalloc.o:	xmalloc.c
	${CC} -c ${CFLAGS} -Derror=as_fatal xmalloc.c

xrealloc.o:	xrealloc.c
	${CC} -c ${CFLAGS} -Derror=as_fatal xrealloc.c

app.o:		as.h

as.o:		${IPATH}/b.out.h as.h read.h struc-symbol.h write.h
atof-generic.o:	flonum.h
bignum-copy.o:	bignum.h
expr.o:		${IPATH}/b.out.h as.h expr.h flonum.h obstack.h read.h
expr.o:		struc-symbol.h symbols.h
flonum-const.o:	flonum.h
flonum-copy.o:	flonum.h
flonum-mult.o:	flonum.h
flonum-normal.o:flonum.h
flonum-print.o:	flonum.h
frags.o:	${IPATH}/b.out.h as.h frags.h obstack.h struc-symbol.h subsegs.h
gdb.o:		as.h
gdb-blocks.o:	as.h
gdb-lines.o:	as.h frags.h obstack.h
gdb-symbols.o:	${IPATH}/b.out.h as.h struc-symbol.h
hash.o:		hash.h
i960.o:		as.h ${IPATH}/b.out.h expr.h flonum.h frags.h hash.h
i960.o:		i960-opcode.h md.h obstack.h struc-symbol.h write.h
i960-opcode.o:	i960-opcode.h
input-file.o:	input-file.h
input-scrub.o:	as.h input-file.h read.h
messages.o:	as.h
obstack.o:	obstack.h
read.o:		${IPATH}/b.out.h as.h expr.h flonum.h frags.h hash.h md.h
read.o:		obstack.h read.h struc-symbol.h symbols.h
subsegs.o:	${IPATH}/b.out.h as.h frags.h obstack.h struc-symbol.h subsegs.h
subsegs.o:	write.h
symbols.o:	${IPATH}/b.out.h as.h frags.h hash.h obstack.h struc-symbol.h
symbols.o:	symbols.h
write.o:	${IPATH}/b.out.h as.h md.h obstack.h struc-symbol.h subsegs.h
write.o:	symbols.h write.h

flonum.h:	bignum.h

#-----------------------------------------------------------------------------
#		'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}
	rm -f ${G960BASE}/bin/${TARG}
	mv ${TARG} ${G960BASE}/bin/${TARG}

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