# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
# 
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

srcdir=@srcdir@
include @TOP_OBJDIR@/src/config/Makefile.config
include @TOP_OBJDIR@/src/config/Makefile.lwp


all: uss

#
# Build targets
#
LIBS=${TOP_LIBDIR}/libvolser.a \
	${TOP_LIBDIR}/libvldb.a  \
	${TOP_LIBDIR}/libkauth.a \
	${TOP_LIBDIR}/libprot.a \
	${TOP_LIBDIR}/libubik.a \
	${TOP_LIBDIR}/libauth.a \
	${TOP_LIBDIR}/librxkad.a \
	${TOP_LIBDIR}/libsys.a \
	${TOP_LIBDIR}/librx.a \
	${TOP_LIBDIR}/libsys.a \
	${TOP_LIBDIR}/liblwp.a \
	${TOP_LIBDIR}/libcmd.a \
	${TOP_LIBDIR}/libafscom_err.a \
	${TOP_LIBDIR}/util.a \
	${TOP_LIBDIR}/libopr.a \
	${TOP_LIBDIR}/libafsrfc3961.a \
	${TOP_LIBDIR}/libafshcrypto_lwp.a

OBJS =  uss_procs.o \
	uss_common.o \
	uss_vol.o \
	uss_acl.o \
	uss_ptserver.o \
	uss_kauth.o \
	uss_fs.o \
	lex.yy.o \
	y.tab.o

uss: uss.o ${OBJS} $(LIBS)
	$(AFS_LDRULE) uss.o ${OBJS} ${LIBS} $(LIB_roken) $(LIB_crypt) $(XLIBS)

uss.o:  uss.c AFS_component_version_number.c

CFLAGS_lex.yy.o = @CFLAGS_NOUNUSED@ @CFLAGS_NOOLDSTYLE@ @CFLAGS_NOIMPLICIT_FALLTHROUGH@
lex.yy.o : lex.yy.c y.tab.c

lex.yy.c : lex.l
	${LEX} ${srcdir}/lex.l
	${MV} lex.yy.c lex.yy.c.orig
	${SED} -f ${srcdir}/yy-lsed lex.yy.c.orig > lex.yy.c

y.tab.o : y.tab.c

uss.c: uss_common.h uss_procs.h uss_kauth.h uss_fs.h

uss_procs.c : uss_procs.h uss_common.h uss_acl.h

uss_common.c : uss_common.h

uss_vol.c : uss_vol.h uss_common.h uss_fs.h

uss_acl.c : uss_acl.h uss_common.h uss_fs.h

uss_ptserver.c: uss_ptserver.h

uss_kauth.c: uss_kauth.h uss_common.h

uss_fs.c: uss_fs.h

y.tab.c : grammar.y
	${YACC} -d ${srcdir}/grammar.y
	${MV} y.tab.h y.tab.h.orig
	${MV} y.tab.c y.tab.c.orig
	${SED} -f ${srcdir}/yy-lsed y.tab.h.orig > y.tab.h
	${SED} -f ${srcdir}/yy-lsed y.tab.c.orig > y.tab.c

#
# Installation targets
#
install:
	${INSTALL} -d ${DESTDIR}${sbindir}
	${INSTALL_PROGRAM} uss ${DESTDIR}${sbindir}/uss

dest:
	${INSTALL} -d ${DEST}/etc
	${INSTALL_PROGRAM} uss ${DEST}/etc/uss

#
# Misc. targets
#
clean:
	$(RM) -f *.o uss y.tab.c y.tab.h lex.yy.c core AFS_component_version_number.c *.orig

include ../config/Makefile.version
