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

LIBOBJS=cmd_errors.o cmd.o 
LIB64OBJS=cmd_errors64.o cmd64.o 

all: ${TOP_LIBDIR}/libcmd.a ${TOP_INCDIR}/afs/cmd.h

all64: all ${TOP_LIBDIR}/libcmd64.a

${TOP_LIBDIR}/libcmd.a: libcmd.a
	${INSTALL_DATA} $? $@

${TOP_LIBDIR}/libcmd64.a: libcmd64.a
	${INSTALL_DATA} $? $@

${TOP_INCDIR}/afs/cmd.h: cmd.h
	${INSTALL_DATA} $? $@

cmd.h: cmd_errors.et cmd.p.h
	$(RM) -f cmd.h cmd_errors.c
	${COMPILE_ET} -p ${srcdir} cmd_errors -h cmd

cmd_errors.c: cmd.h 

cmd_errors.o: cmd_errors.c

cmd.o: cmd.c cmd.h

cmd_errors64.o: cmd_errors.c
	${CC} ${OPTMZ} -I. -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCFLAGS64} -c -o cmd_errors64.o cmd_errors.c

cmd64.o: cmd.c cmd.h
	${CC} ${OPTMZ} -I. -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCFLAGS64} -c -o cmd64.o ${srcdir}/cmd.c

libcmd64.a: ${LIB64OBJS} AFS_component_version_number64.o
	-$(RM) -f $@
	$(AR) crv $@ ${LIB64OBJS} AFS_component_version_number64.o
	$(RANLIB) $@

libcmd.a: ${LIBOBJS} AFS_component_version_number.o
	-$(RM) -f $@
	$(AR) crv $@ ${LIBOBJS} AFS_component_version_number.o
	$(RANLIB) $@

AFS_component_version_number64.o: AFS_component_version_number.c
	${CC} ${OPTMZ} -I${TOP_INCDIR} ${XCFLAGS64} -c -o AFS_component_version_number64.o AFS_component_version_number.c

#
# Install targets
#
install: libcmd.a cmd.h
	${INSTALL} -d ${DESTDIR}${libdir}/afs
	${INSTALL} -d ${DESTDIR}${includedir}/afs
	${INSTALL_DATA} libcmd.a ${DESTDIR}${libdir}/afs/libcmd.a
	${INSTALL_DATA} cmd.h ${DESTDIR}${includedir}/afs/cmd.h

install64: install libcmd64.a
	${INSTALL_DATA} libcmd64.a ${DESTDIR}${libdir}/afs/libcmd64.a

dest: libcmd.a cmd.h
	${INSTALL} -d ${DEST}/lib/afs
	${INSTALL} -d ${DEST}/include/afs
	${INSTALL_DATA} libcmd.a ${DEST}/lib/afs/libcmd.a
	${INSTALL_DATA} cmd.h ${DEST}/include/afs/cmd.h

dest64: dest libcmd64.a
	${INSTALL_DATA} libcmd64.a ${DEST}/lib/afs/libcmd64.a

#
# Misc targets
#
test tests: 
	(cd test; $(MAKE) )

clean:
	$(RM) -f  *.a *.o ctest dtest cmd.h cmd_errors.c core AFS_component_version_number.c

include ../config/Makefile.version
