# (C) Copyright International Business Machines Corporation 23 January 
# 1990.  All Rights Reserved. 
#  
# See the file USERAGREEMENT distributed with this software for full 
# terms and conditions of use. 
# SCCS Info: @(#)Makefile	1.11 3/15/90

include ../make/includefile

LIBDIRS = 	-L../lib -L../cherm -L../cfunc -L../fe -L../li

LIBS	=	-lhermi -lcherm -lcfunc -lfe -lhaux -ll

OBJS	=	asm.o asmlex.o main.o actions.o defacts.o linkacts.o \
		stubs.o

YACC	=	yacc
YFLAGS	=	-v


all:	asm

install: asm
	cp asm $(ASM)

asm:	$(OBJS)
	$(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS)	

lint:	asm
	$(LINT) $(LFLAGS) *.c

opfuncdefs.h oplex.lex: ../interface/greencard
	awk -f opcodes.awk ../interface/greencard

asm.c: asm.y 
	$(YACC) -d $(YFLAGS) asm.y
	mv y.tab.c asm.c
	mv y.tab.h tokens.h

exceps.lex: ../interface/predefined.d
	awk -f exceps.awk ../interface/predefined.d >exceps.lex

asmlex.l: asmlex.lex oplex.lex exceps.lex
	m4 asmlex.lex >asmlex.l

asmlex.c: asmlex.l 
	lex -t asmlex.l >asmlex.c

actions.cd: actions.d
	$(CHGRAM) actions.d >actions.cd

actions.c: actions.ch actions.cd
	$(CHERM) actions.ch | $(CHERM2) >actions.c

defacts.c: defacts.ch 
	$(CHERM) defacts.ch | $(CHERM2) >defacts.c

linkacts.c: linkacts.ch
	$(CHERM) linkacts.ch | $(CHERM2) >linkacts.c

asm.tex: asm.y
	rm -f asm.tex
	sed -f ../fe/texpp.sed < asm.y | $(CPP) -P | \
	  sed -f ../fe/yacc2tex.sed  | awk -f ../fe/yacc2tex.awk | \
	  tr A-Z a-z >asm.tex

asm.dvi: asm.tex
	tex asm

clean:	
	rm -f core *.o a.out *~ asm asm.c asm.tex asm.dvi asm.ps \
	  asmlex.l asmlex.c y.output exceps.lex tokens.h \
	  opfuncdefs.h oplex.lex defacts.c linkacts.c actions.c actions.cd

