# 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

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

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: ${DESTDIR}${libdir}/afs/libcmd.a ${DESTDIR}${includedir}/afs/cmd.h

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

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

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

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

#
# 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
${DESTDIR}${libdir}/afs/libcmd.a: libcmd.a
	${INSTALL} $? $@

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

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

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

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

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

dest: ${DEST}/lib/afs/libcmd.a ${DEST}/include/afs/cmd.h

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