# $OpenBSD$
# Build libssl/libcrypto using rsaref
# For non-commercial use in the USA only

all: libssl/obj/crypto-patent/libcrypto.a

install: libssl/obj/crypto-patent/libcrypto.a
	@cd libssl && \
	 OBJMACHINE= WRKOBJDIR= unset OBJMACHINE WRKOBJDIR && \
	 RSAREFDIR=${.CURDIR}/../source NOMAN= LIBDIR=${LOCALBASE}/lib \
	 make LIBDIR=${LOCALBASE}/lib -f Makefile.bsd-wrapper install

# force an obj link, then force the obj/Makefile to be created, then
# clean up any cruft left from previous builds and finally build
# the libraries.
#
libssl/obj/crypto-patent/libcrypto.a: .src-ready
	@cd libssl && \
	 OBJMACHINE= WRKOBJDIR= unset OBJMACHINE WRKOBJDIR && \
	 make -f Makefile.bsd-wrapper obj && \
	 make -f Makefile.bsd-wrapper prereq && \
	 make -f Makefile.bsd-wrapper cleandir && \
	 RSAREFDIR=${.CURDIR}/../source NOMAN= make -f Makefile.bsd-wrapper

# link and patch the libssl source.   This works because patch
# creates a new file, leaving the original linked file alone.
#
.src-ready:
	@echo "===>  Preparing ssl source"
	@mkdir libssl && \
	 cd libssl && \
	 lndir -s -e obj /usr/src/lib/libssl && \
	 ln -s src src-patent && \
	 patch --forward --quiet < ../patches
	@touch .src-ready
