#
#
#                         DES SOFTWARE PACKAGE
#                             Version 2.2
#
#                                        _
# Copyright (c) 1990,1991,1992,1993 Stig Ostholm.
# All Rights Reserved
#
#
# The author takes no responsibility of actions caused by the use of this
# software package and does not guarantee the correctness of the functions.
#
# This software package may be freely distributed for non-commercial purpose
# as long as the copyright notice is kept. Any changes made should be
# accompanied by a comment indicating who made the change, when it was made
# and what was changed.
#
# This software package, or any parts of it, may not be used or in any way
# re-distributed for commercial purpose without the authors permission.
# The author keeps the right to decide between of what is commercial and
# what is non-commercial purpose.
#
# Restrictions due to national laws governing the use, import or export of
# cryptographic software is the responsibility of the software user/importer/
# exporter to follow.
#
#
#                                              _
#                                         Stig Ostholm
#                                         Chalmers University of Technology
#                                         Department of Computer Engineering
#                                         S-412 96 Gothenburg
#                                         Sweden
#                                         ----------------------------------
#                                         Email: ostholm@ce.chalmers.se
#                                         Phone: +46 31 772 1703
#                                         Fax:   +46 31 772 3663
#

#
# All make programs dont have the .h suffix defined
#
.SUFFIXES: .h .x

       TOPDIR = ..
      SUBDIRS = dea strkey misc extra

#          CC = gcc
#  DEFINE_TTY = -DTTY=\"/dev/tty\"
      DEFINES = ${DEFINE_TTY}
     INCLUDES = -I. -I${TOPDIR}/include -I${TOPDIR}/config/include -Imisc
        CCOPT = -O
#       CCOPT = -g
       CFLAGS = ${CCOPT} ${DEFINES} ${INCLUDES}

      INSTALL = install -c
       RANLIB = ranlib

           RM = rm -f
           MV = mv
         ECHO = echo
         MAKE = make

       LIBDIR = 

    MAKE_ARGS = 'TOPDIR=${TOPDIR}/..' 'MAKE=${MAKE}' 'ECHO=${ECHO}' 'RM=${RM}' \
		'CC=${CC}' 'CCOPT=${CCOPT}' 'BINDIR=${BINDIR}' \
		'LIBDIR=${LIBDIR}' 'INCDIR=${INCDIR}' 'MANDIR=${MANDIR}'

 MAKE_SUBDIRS = case '${MFLAGS}' in -*s*) :;; *) set -x;; esac; \
		for D in ${SUBDIRS}; do \
			( cd $$D && ${MAKE} ${MFLAGS} ${MAKE_ARGS} $@ ); \
		done


      TAB_SRCS = tab_parity.c

      TAB_HDRS = tab_parity.h

      TAB_OBJS = tab_parity.o

     TAB_PROGS = tab_parity.x

   SUBDIR_LIBS = dea/libdea.a strkey/libstrkey.a misc/libmisc.a extra/libextra.a

          SRCS = des_core.c \
		 des_ecb.c des_ecb2.c des_cbc.c des_pcbc.c des_cfb8.c des_ofb8.c \
		 des_cksum.c \
		 des_ivec.c \
		 des_rblock.c des_rkey.c \
		 des_checkkp.c des_fixkp.c \
		 des_isweak.c des_issweak.c des_nkey.c \
		 des_ksched.c \
		 des_hexblock.c des_print.c \
		 des_readblk.c des_passwd.c des_readhex.c des_read.c \
		 ${TAB_SRC}

          OBJS = des_core.o \
		 des_ecb.o des_ecb2.o des_cbc.o des_pcbc.o des_cfb8.o des_ofb8.o \
		 des_cksum.o \
		 des_ivec.o \
		 des_rblock.o des_rkey.o \
		 des_checkkp.o des_fixkp.o \
		 des_isweak.o des_issweak.o des_nkey.o \
		 des_ksched.o \
		 des_hexblock.o des_print.o \
		 des_readblk.o des_passwd.o des_readhex.o des_read.o \
		 ${TAB_OBJS}


           LIB = libdes.a


       REMOVES = ${LIB} ${TAB_SRCS} ${TAB_HDRS} ${TAB_PROGS}


# This rule should be defined in all make programs.
#
#.c.o:
#	${CC} ${CFLAGS} -c $* $<

.x.c:
	${RM} tmp.c
	./$*.x -c $* > tmp.c
	${MV} tmp.c $@

.x.h:
	${RM} tmp.h
	./$*.x -h $* > tmp.h
	${MV} tmp.h $@


all	: ${LIB}


${LIB}	:: ${OBJS}
	ar r $@ $?
	${RANLIB} $@

${LIB}	::
	@ case '${MFLAGS}' in -*s*) :;; *) set -x;; esac; \
	  for D in ${SUBDIRS}; do \
		( cd $$D && ${MAKE} ${MFLAGS} all ); \
	  done

${LIB}	:: ${SUBDIR_LIBS}
	@ case '${MFLAGS}' in -*s*) :;; *) set -x;; esac; \
	  for SL in $?; do \
		eval `IFS=/; set $$SL; ${ECHO} D=$$1 L=$$2` && \
		( cd $$D && ar r ../$@ `ar t $$L | grep -v SYMDEF` ); \
	  done
	${RANLIB} $@

install	: ${LIB}
	@ case "${LIBDIR}" in \
	'')	${ECHO} 'Define destination directory LIBDIR'; exit 1;; \
	*)	case '${MFLAGS}' in -*s*) :;; *) set -x;; esac; \
		${INSTALL} ${LIB} ${LIBDIR};; \
	esac
	@ ${MAKE_SUBDIRS}

clean	:
	${RM} ${REMOVES} *.o *.x core a.out tmp.c tmp.h *.NEW *.BAK
	@ ${MAKE_SUBDIRS}

depend  : ${THDRS}
	${TOPDIR}/util/mkdepend.sh ${MFLAGS} 'CC=${CC}' 'CFLAGS=${CFLAGS}' 'RM=${RM}' -f Makefile ${SRCS}
	@ ${MAKE_SUBDIRS}


tab_parity.x	: gen_parity.c ${TOPDIR}/config/config.h
	${CC} ${CFLAGS} -o $@ gen_parity.c ${LDFLAGS}

tab_parity.h	: tab_parity.x

tab_parity.c	: tab_parity.x tab_parity.h


des_rblock.o	: des_rblock.c
	@ case '${MFLAGS}' in -*s*) :;; *) ${ECHO} 'Ignore warnings for des_rblock.c';; esac
	${CC} ${CFLAGS} -c des_rblock.c


# To keep old make programs happy.
des_cbc.o	: des_cbc.c
des_cfb8.o	: des_cfb8.c
des_cksum.o	: des_cksum.c
des_ecb.o	: des_ecb.c
des_ecb2.o	: des_ecb2.c
des_hexblock.o	: des_hexblock.c
des_issweak.o	: des_issweak.c
des_isweak.o	: des_isweak.c
des_sched.o	: des_sched.c
des_nkey.o	: des_nkey.c
des_ofb8.o	: des_ofb8.c
des_passwd.o	: des_passwd.c
des_pcbc.o	: des_pcbc.c
des_print.o	: des_print.c
des_read.o	: des_read.c
des_readblk.o	: des_readblk.c
des_readhex.o	: des_readhex.c
des_rkey.o	: des_rkey.c
des_ksched.o	: des_ksched.c
des_fixkp.o	: des_fixkp.c tab_parity.h
des_checkkp.o	: des_checkkp.c tab_parity.h

des_ivec.o	: des_ivec.c

quad_cksum.o	: quad_cksum.c

gen_parity.o	: gen_parity.c

tab_parity.o	: tab_parity.c

# DEPEND
#
# Don not change the lines below, run make depend
#
