#
# OpenSSL/engines/Makefile
#

DIR=	engines
TOP=	..
CC=	cc
INCLUDES= -I../include
CFLAG=-g
MAKEFILE=	Makefile
AR=		ar r

PEX_LIBS=
EX_LIBS= -lgdi32

CFLAGS= $(INCLUDES) $(CFLAG)

GENERAL=Makefile
TEST=
APPS=

LIB=$(TOP)/libcrypto.a
LIBNAMES= mscrypto

LIBSRC= e_mscrypto.c
LIBOBJ= e_mscrypto.o

SRC= $(LIBSRC)

EXHEADER= 
HEADER=	mscrypto_err.c mscrypto_err.h

ALL=    $(GENERAL) $(SRC) $(HEADER)

top:
	(cd ..; $(MAKE) DIRS=$(DIR) LIBDEPS='-L.. -lcrypto $(EX_LIBS)' all)

all:	lib

lib:	$(LIBOBJ)
	@if [ -n "$(SHARED_LIBS)" ]; then \
		set -e; \
		for l in $(LIBNAMES); do \
			$(MAKE) -f ../Makefile.shared -e \
				LIBNAME=$$l LIBEXTRAS=e_$$l.o \
				LIBDEPS='-L.. -lcrypto $(EX_LIBS)' \
				link_o.$(SHLIB_TARGET); \
		done; \
	else \
		$(AR) $(LIB) $(LIBOBJ); \
		$(RANLIB) $(LIB) || echo Never mind.; \
	fi; \
	touch lib

files:
	$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO

links:

# XXXXX This currently only works on systems that use .so as suffix
# for shared libraries as well as for Cygwin which uses the
# dlfcn_name_converter and therefore stores the engines with .so suffix, too.
# XXXXX This was extended to HP-UX dl targets, which use .sl suffix.
# XXXXX This was extended to mingw targets, which use eay32.dll suffix without lib as prefix.
install:
	[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
	if [ -n "$(SHARED_LIBS)" ]; then \
		set -e; \
		for l in $(LIBNAMES); do \
			( echo installing $$l; \
			  pfx=lib; \
			  if [ "$(PLATFORM)" != "Cygwin" ]; then \
				case "$(CFLAGS)" in \
				*DSO_DLFCN*)	sfx=".so";;	\
				*DSO_DL*)	sfx=".sl";;	\
				*DSO_WIN32*)	sfx="eay32.dll"; pfx=;;	\
				*)		sfx=".bad";;	\
				esac; \
				cp $$pfx$$l$$sfx $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines/$$pfx$$l$$sfx.new; \
			  else \
				sfx=".so"; \
				cp cyg$$l.dll $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines/$$pfx$$l$$sfx.new; \
			  fi; \
			  chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines/$$pfx$$l$$sfx.new; \
			  mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines/$$pfx$$l$$sfx.new $(INSTALL_PREFIX)$(INSTALLTOP)/lib/engines/$$pfx$$l$$sfx ); \
		done; \
	fi

tags:
	ctags $(SRC)

errors:
	set -e; for l in $(LIBNAMES); do \
		$(PERL) ../util/mkerr.pl -conf e_$$l.ec \
			-nostatic -staticloader -write *.c; \
	done

tests:

lint:
	lint -DLINT $(INCLUDES) $(SRC)>fluff

depend:
	@if [ -z "$(THIS)" ]; then \
	    $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; \
	else \
	    $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC); \
	fi

dclean:
	$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
	mv -f Makefile.new $(MAKEFILE)

clean:
	rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff

# DO NOT DELETE THIS LINE -- make depend depends on it.

e_mscrypto.o: ../include/openssl/asn1.h ../include/openssl/bio.h
e_mscrypto.o: ../include/openssl/bn.h ../include/openssl/buffer.h
e_mscrypto.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
e_mscrypto.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
e_mscrypto.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
e_mscrypto.o: ../include/openssl/err.h ../include/openssl/evp.h
e_mscrypto.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
e_mscrypto.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
e_mscrypto.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
e_mscrypto.o: ../include/openssl/pem.h ../include/openssl/pem2.h
e_mscrypto.o: ../include/openssl/pkcs7.h ../include/openssl/safestack.h
e_mscrypto.o: ../include/openssl/sha.h ../include/openssl/stack.h
e_mscrypto.o: ../include/openssl/symhacks.h ../include/openssl/x509.h
e_mscrypto.o: ../include/openssl/x509_vfy.h e_mscrypto.c kt_rsa.c
e_mscrypto.o: mscrypto_err.c mscrypto_err.h mscrypto_int.h
e_mscrypto.o: mscrypto_rsa_decrypt.c mscrypto_rsa_encrypt.c mscrypto_rsa_sign.c
e_mscrypto.o: mscrypto_rsa_verify.c
