#
# Makefile for error-table routines
#
#	Copyright (C) 1988, 1989 by the Massachusetts Institute of Technology
#    	Developed by the MIT Student Information Processing Board (SIPB).
#    	For copying information, see the file mit-copyright.h in this release.
#
SHELL=	 /bin/sh
CC=	 @CC@
INSTALL= @INSTALL@
LEX=	 @LEX@
YACC=	 @YACC@
RANLIB=	 @RANLIB@
LEXLIB=	 @LEXLIB@

DEFS=	 @DEFS@
LIBS=	 @LIBS@
CFLAGS=	-O
INCLUDES= -I. -I../include

FILES=	Makefile.in et_name.c error_message.c compile_et.c \
		error_table.y et_lex.lex.l init_et.c \
		com_err.c \
		error_table.h  \
		test.c test1.et test2.et \
		compiler.h internal.h \
		com_err.texinfo texinfo.tex
CFILES=	compile_et.c error_table.c error_message.c et_name.c \
	init_et.c com_err.c

LIBOBJS= error_message.o et_name.o init_et.o com_err.o # perror.o

#
# what to build...
#
all:	compile_et libcom_err.a

lint:	llib-lcom_err.ln

archive:	et.tar

doc:	com_err.dvi

#
# rules
#
.SUFFIXES: .h .c .et .ps .x9700 .mss .dvi .texinfo

.et.c:
	./compile_et $*.et

.et.h:
	./compile_et $*.et

.texinfo.dvi:
	tex $<

.dvi.ps:
	rm -f $@.new
	dvi2ps -r $< > $@.new
	mv $@.new $@

.y.o:
	-rm -f $*.o y.tab.c y.tab.o
	${YACC} $(YFLAGS) $<
	${CC} $(CFLAGS) -c y.tab.c
	mv y.tab.o $@

.c.o:
	${CC} ${CFLAGS} ${INCLUDES} ${DEFS} -c $*.c

#
# real entries...
#
compile_et:	compile_et.o error_table.o
	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o ${LIBS} ${LEXLIB}

et.tar:	${FILES}
	rm -f et.tar
	tar cfrlv et.tar ${FILES}

tags:	TAGS

com_err.ps : com_err.dvi
com_err.dvi: com_err.texinfo

# Hardcoded depends
error_table.o: et_lex.lex.c

install: all
	${INSTALL} -c -s compile_et ${DESTDIR}${BINDIR}/compile_et
	${INSTALL} -c -m 444 ${DESTDIR}${INCDIR}/mit-sipb-copyright.h
	${INSTALL} -c libcom_err.a ${DESTDIR}${LIBDIR}/libcom_err.a
	${RANLIB} ${DESTDIR}${LIBDIR}/libcom_err.a
	${INSTALL} -c libcom_err_p.a ${DESTDIR}${LIBDIR}/libcom_err_p.a
	${RANLIB} ${DESTDIR}${LIBDIR}/libcom_err_p.a

TAGS:	et_name.c error_message.c compile_et.c error_table.c \
		lex.yy.c perror.c init_et.c
	etags et_name.c error_message.c compile_et.c \
		error_table.c perror.c init_et.c

libcom_err.a:	$(LIBOBJS)
	ar cruv libcom_err.a $(LIBOBJS)
	${RANLIB} libcom_err.a

libcom_err_p.a:	$(LIBOBJS)
	(cd profiled; ar uv ../libcom_err_p.a $(LIBOBJS); \
		${RANLIB} ../libcom_err_p.a)

libcom_err.o:	$(LIBOBJS)
	ld -r -s -o libcom_err.o $(LIBOBJS)
	chmod -x libcom_err.o

llib-lcom_err.ln: $(LINTFILES)
	lint -Ccom_err $(LINTFLAGS) $(LINTFILES)

clean:
	rm -f *~ \#* *.bak \
		*.otl *.aux *.toc *.PS *.dvi *.x9700 *.ps \
		*.cp *.fn *.ky *.log *.pg *.tp *.vr \
		*.o profiled/*.o libcom_err.a libcom_err_p.a \
		com_err.o compile_et \
		et.ar TAGS y.tab.c lex.yy.c error_table.c \
		et_lex.lex.c \
		test1.h test1.c test2.h test2.c test \
		eddep makedep

dist:	$(FILES) 
	-mkdir ../../dist/source/et
	cp -p $(FILES) ../../dist/source/et/
	cp -p Makefile.in ../../dist/source/et/

# for testing
test:	test.o test1.o test2.o libcom_err.a
	cc ${CFLAGS} -o test test.o test1.o test2.o libcom_err.a
test.o:	test1.h test2.h
test1.o : test1.c
test1.c : test1.et
test2.o : test2.c
test2.c : test2.et

compile_et.o: compile_et.c
compile_et.o: compiler.h
error_table.o: error_table.c
error_table.o: internal.h
error_table.o: error_table.h
error_table.o: et_lex.lex.c
error_message.o: error_message.c
error_message.o: error_table.h
error_message.o: internal.h
et_name.o: et_name.c
et_name.o: error_table.h
et_name.o: internal.h
init_et.o: init_et.c
init_et.o: error_table.h
com_err.o: com_err.c
com_err.o: error_table.h
com_err.o: internal.h
com_err.o: com_err.h
