#
#	Makefile for as	
# (c) Copyright 1986 Gould Inc.
#
# @(#) (Gould) $Header: Makefile,v 5.2 88/08/30 01:10:14 pcc Released $
DESTDIR		=
BASEDIR		= $(DESTDIR)/usr/src/src/bin/as
CC		= /bin/cc
LD		= /bin/ld
HOST_CC		= /bin/cc
HOST_LD		= /bin/ld
HOST_INC	=
INSTALL		= /usr/bin/install
CO		= co
MACHINE		=
CFLAGS		= $(OPT) -DLDPOOL -DSPAN -DMODULAR_ADDRESS_ARITHMETIC \
		  -DE_SV -DDYN_BASE\
		  $(MACHINE) -I$(DESTDIR)/usr/include
OPT		= -O

HDRS		= gramops.h operand.h ophash.h optab1.h \
		  parse.h struct.h y.tab.h

SRCS		= aout.c main.c opcode.c ophash.c pass.c pass2.c \
		  pseudo.c stab.c strnum.c sym.c yylex.c gram.y \
		  builder.c makevers.c

OBJS		= aout.o gram.o main.o opcode.o ophash.o pass.o pass2.o\
		  pseudo.o stab.o strnum.o sym.o yylex.o

as:	optable.h $(OBJS) makevers
	makevers > vers.c
	$(CC) $(CFLAGS) -o as vers.c $(OBJS)

install: 
	$(INSTALL) as $(DESTDIR)/bin/as

clean:
	rm -f *.o core builder makevers as collision optable.h vers.c

builder:	ophash.h ophash.c optab1.h builder.c
	$(HOST_CC) $(CFLAGS) -c ophash.c
	$(HOST_CC) $(CFLAGS) -o builder ophash.o builder.c
	rm -f ophash.o

test:	ophash.h ophash.c optab1.h builder.c
	$(CC) $(CFLAGS) -DTEST -c ophash.c
	$(CC) $(CFLAGS) -DTEST -o tester ophash.o builder.c
	tester > hashtest

optable.h:	optab1.h builder
	builder -p optable.h > collision

makevers:	makevers.c
	$(HOST_CC) -o makevers makevers.c

depend:
	make HOST_CC="$(HOST_CC)" CFLAGS="$(CFLAGS)" optable.h
	$(CC) -M $(CFLAGS) $(SRCS) > makedep
	cp Makefile Makefile.bak
	echo >> Makefile
	echo '# DO NOT DELETE THIS LINE -- DEPENDENCIES START HERE' \
	   >> Makefile
	echo >> Makefile
	cat makedep >> Makefile
	rm -f makedep

base:;		-mkdir $(BASEDIR)
		for i in $(SRCS) $(HDRS) Makefile; do \
		$(CO) $(COFLAGS) -p$(REV) RCS/$$i,v > $(BASEDIR)/$$i; \
		done
