#
# $Id: Makefile.in,v 1.3 2005/09/30 04:26:15 quozl Exp $
#
# This is the Makefile for the U.S. RES-RSA package.  It is no longer
# dependent on the Vanilla server Makefile system.
#

#
# Compiler defines
#

CC =		gcc
AR =		ar
RANLIB =	ranlib
CFLAGS =	-O2 

#
# GMP include dir and library
#

GMP_INC =	
GMP_LIB =	 -lgmp

#
# External include header file
#
RSA_HDR =	rsa.h

#
# Custom (non GMP) RSA lib sources
#

RSA_LIB =	librsa.a
RSA_LIBSRC = 	rsa_math.c rsa_encode.c
RSA_LIBHDR =	rsa_math.h
RSA_LIBOBJ =	$(RSA_LIBSRC:.c=.o)

#
# GMP RSA lib sources
#

RSA_GMPLIB =	librsa-gmp.a
RSA_GMPSRC =	rsa_gmp.c rsa_encode_gmp.c
RSA_GMPHDR =	rsa_gmp.h
RSA_GMPOBJ =	$(RSA_GMPSRC:.c=.o)

#
# mkkey sources
#

MKKEY =		mkkey
MKKEY_SRC =	mkkey.c
MKKEY_OBJ =	$(MKKEY_SRC:.c=.o)

#
# Do nothing for default 'all' rule.  The Vanilla server compiles the
# rsa_util.c file independently, and mkkey is not needed for the server.
#

all:		Makefile $(RSA_LIB) librsa-gmp.a mkkey


Makefile: Makefile.in config.status
	./config.status
     
config.status: configure
	./config.status --recheck

#
# Build the non-GMP RSA lib
#

$(RSA_LIB):	$(RSA_LIBOBJ)
		$(AR) cvr $(RSA_LIB) $(RSA_LIBOBJ)
		$(RANLIB) $(RSA_LIB)

#
# Build the GMP RSA lib
#

$(RSA_GMPLIB):	$(RSA_GMPOBJ)
		$(AR) cvr $(RSA_GMPLIB) $(RSA_GMPOBJ)
		$(RANLIB) $(RSA_LIB)

#
# mkkey client RSA code and key generator, not needed for the server
#

$(MKKEY):	$(MKKEY_OBJ)
		$(CC) $(CFLAGS) $(GMP_INC) -o $(MKKEY) $(MKKEY_OBJ) $(GMP_LIB)

#
# GMP is not on this system
#

nogmp:;		@/bin/echo $(RSA_GMPLIB) and $(MKKEY) require GMP 1.3.2 or higher.

clean:;		@/bin/rm -f $(RSA_LIBOBJ) $(RSA_GMPOBJ) $(MKKEY_OBJ) core

reallyclean:	clean
		@/bin/rm -f $(RSA_LIB) $(RSA_GMPLIB) $(MKKEY) *.bak

#
# Maintainer dist clean
#

distclean:	reallyclean
		@/bin/rm -f config.cache config.h config.log config.status \
		*.c~ *.h~

#
# Do nothing for install, depend rules for now.
#

install:

depend:;	touch .depend
		@makedepend -f.depend $(CFLAGS) $(CPPFLAGS) $(GMP_INC) $(RSA_LIBSRC) \
			$(RSA_GMPSRC) $(MKKEY_SRC)

rmdependencies:
	rm -rf .depend

#
# Default compile rule
#

.SUFFIXES:	.c
.c.o:;		$(CC) $(CFLAGS) $(GMP_INC) -c $<

#
# Silently include dependency file
#

sinclude .depend