#
# Makefile for error-table routines
#
# Copyright 1987, 1989 MIT Student Information Processing Board
# For copyright info, see mit-sipb-cr.h.

DEST=@DEST@
TOP_INCDIR=@TOP_INCDIR@
TOP_LIBDIR=@TOP_LIBDIR@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
libexecdir=@libexecdir@
libdir=@libdir@
includedir=@includedir@
mandir=@mandir@
afssrvbindir=@afssrvbindir@
afssrvsbindir=@afssrvsbindir@
afssrvlibexecdir=@afssrvlibexecdir@
COMPILE_ET=${TOP_SRCDIR}/comerr/compile_et
RXGEN=${TOP_SRCDIR}/rxgen/rxgen
TOP_SRCDIR=@TOP_SRCDIR@
SYS_NAME=@AFS_SYSNAME@

SHELL = /bin/sh

include ../config/Makefile.${SYS_NAME}

UKERNELDIR=../libuafs/

CFLAGS=${OPTMZ} -I${TOP_INCDIR} -I${TOP_SRCDIR}/config ${XCFLAGS}

all: ukinstall compile_et ${TOP_INCDIR}/afs/com_err.h ${TOP_INCDIR}/afs/error_table.h ${TOP_INCDIR}/afs/mit-sipb-cr.h ${TOP_LIBDIR}/libcom_err.a

et_lex.lex.c: et_lex.lex.l
	$(RM) -f et_lex.lex.c
	$(LEX) -t et_lex.lex.l > et_lex.lex.c

compile_et:	compile_et.o error_table.o
	case $(SYS_NAME) in \
	*_linux* ) \
	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -L${TOP_LIBDIR} -lafsutil;; \
	* ) \
	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -L${TOP_LIBDIR} -lafsutil -ll;; \
	esac

libcom_err.a: error_msg.o et_name.o com_err.o AFS_component_version_number.o
	$(RM) -f $@
	$(AR) crv $@ error_msg.o et_name.o com_err.o AFS_component_version_number.o
	$(RANLIB) $@
#
# Installation targets
#
ukinstall: \
	${UKERNELDIR}/afs \
	${UKERNELDIR}/afs/com_err.c \
	${UKERNELDIR}/afs/com_err.h \
	${UKERNELDIR}/afs/error_msg.c \
	${UKERNELDIR}/afs/error_table.h \
	${UKERNELDIR}/afs/mit-sipb-cr.h \
	${UKERNELDIR}/afs/internal.h \
	${UKERNELDIR}/afs/et_name.c

install:  ${DESTDIR}${bindir}/compile_et ${DESTDIR}${includedir}/afs/com_err.h ${DESTDIR}${includedir}/afs/error_table.h ${DESTDIR}${includedir}/afs/mit-sipb-cr.h ${DESTDIR}${libdir}/afs/libcom_err.a

${UKERNELDIR}/afs:
	mkdir -p $@

${UKERNELDIR}/afs/com_err.c: com_err.c
	${INSTALL} $? $@

${UKERNELDIR}/afs/com_err.h: com_err.h
	${INSTALL} $? $@

${UKERNELDIR}/afs/error_msg.c: error_msg.c
	${INSTALL} $? $@

${UKERNELDIR}/afs/error_table.h: error_table.h
	${INSTALL} $? $@

${UKERNELDIR}/afs/mit-sipb-cr.h: mit-sipb-cr.h
	${INSTALL} $? $@

${UKERNELDIR}/afs/internal.h: internal.h
	${INSTALL} $? $@

${UKERNELDIR}/afs/et_name.c: et_name.c
	${INSTALL} $? $@

${DEST}/bin/compile_et: compile_et
	${INSTALL} $? $@

${DEST}/include/afs/com_err.h: com_err.h
	${INSTALL} $? $@

${DEST}/include/afs/error_table.h: error_table.h 
	${INSTALL} $? $@

${DEST}/include/afs/mit-sipb-cr.h: mit-sipb-cr.h
	${INSTALL} $? $@

${DEST}/lib/afs/libcom_err.a: libcom_err.a
	${INSTALL} $? $@

clean:
	$(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.x9700 *.ps \
		*.cp *.fn *.ky *.log *.pg *.tp *.vr *.o libcom_err.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 \
		eddep makedep core AFS_component_version_number.c

test:
	cd test; $(MAKE)

compile_et.o:  AFS_component_version_number.c
error_table.o: et_lex.lex.c

include ../config/Makefile.version
${DESTDIR}${bindir}/compile_et: compile_et
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/com_err.h: com_err.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/com_err.h: com_err.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/error_table.h: error_table.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/error_table.h: error_table.h
	${INSTALL} $? $@

${DESTDIR}${includedir}/afs/mit-sipb-cr.h: mit-sipb-cr.h
	${INSTALL} $? $@

${TOP_INCDIR}/afs/mit-sipb-cr.h: mit-sipb-cr.h
	${INSTALL} $? $@

${DESTDIR}${libdir}/afs/libcom_err.a: libcom_err.a
	${INSTALL} $? $@

${TOP_LIBDIR}/libcom_err.a: libcom_err.a
	${INSTALL} $? $@

dest:  ${DEST}/bin/compile_et ${DEST}/include/afs/com_err.h ${DEST}/include/afs/error_table.h ${DEST}/include/afs/mit-sipb-cr.h ${DEST}/lib/afs/libcom_err.a

