# 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
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@

all: uss

CFLAGS=-I. -I${srcdir} ${DBUG} -I${TOP_OBJDIR}/src/config \
	-I${TOP_INCDIR} -I. ${XCFLAGS} ${ARCHFLAGS}

#
# 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}/libdes.a \
	${TOP_LIBDIR}/librx.a \
	${TOP_LIBDIR}/libsys.a \
	${TOP_LIBDIR}/liblwp.a \
	${TOP_LIBDIR}/libcmd.a \
	${TOP_LIBDIR}/libcom_err.a\
	${TOP_LIBDIR}/util.a \
	${XLIBS}

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} 
	${CC} ${CFLAGS} -o uss uss.o ${OBJS} ${LIBS}

uss.o:  uss.c AFS_component_version_number.c
	${CC} -c ${CFLAGS} ${srcdir}/uss.c

uss_procs.o : uss_procs.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_procs.c

uss_common.o : uss_common.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_common.c

uss_vol.o : uss_vol.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_vol.c

uss_acl.o : uss_acl.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_acl.c

uss_ptserver.o : uss_ptserver.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_ptserver.c

uss_kauth.o : uss_kauth.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_kauth.c

uss_fs.o : uss_fs.c
	${CC} -c ${CFLAGS} ${srcdir}/uss_fs.c

lex.yy.o : lex.yy.c y.tab.c
	${CC} -c ${CFLAGS} lex.yy.c

lex.yy.c : lex.l
	${LEX} ${srcdir}/lex.l

y.tab.o : y.tab.c
	${CC} -c ${CFLAGS} 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

#
# 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

include ../config/Makefile.version
