Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/openssl/BSDmakefile
34677 views
# This BSD makefile helps provide a deterministic means of doing a "clean"
# vendor import of OpenSSL.
#
# Recommended use:
#
#   % make clean
#   % make all

NO_OBJ=

LCRYPTO_SRC=	${SRCTOP}/crypto/openssl
LCRYPTO_DOC=	${LCRYPTO_SRC}/doc

CAT?=		/bin/cat
MV?=		/bin/mv
PERL?=		perl

BN_CONF_H=		include/crypto/bn_conf.h
BN_CONF_H_ORIG=		${BN_CONF_H}.orig
CONFIGURATION_H=	include/openssl/configuration.h
CONFIGURATION_H_ORIG=	${CONFIGURATION_H}.orig

.PHONY: configure patch all
.ORDER: configure patch all

configure:
	@cd ${.CURDIR} && \
	    ${PERL} ./Configure \
	    disable-aria \
	    disable-egd \
	    disable-idea \
	    disable-mdc2 \
	    disable-sm2 \
	    disable-sm3 \
	    disable-sm4 \
	    enable-ec_nistp_64_gcc_128 \
	    enable-ktls \
	    enable-sctp \
	    --openssldir=etc \
	    --prefix=/usr
	@cd ${.CURDIR} && gmake configdata.pm
	@cd ${LCRYPTO_SRC} && ${PERL} \
	    ${LCRYPTO_SRC}/freebsd/dump_version_from_configdata.pl > \
	    ${SRCTOP}/secure/lib/libcrypto/Makefile.version

all: patch
	# Passing `-j ${.MAKE.JOBS}` doesn't work here for some reason.
	@cd ${.CURDIR} && gmake build_all_generated

	# Clean the pkgconfig files:
	# 1. Fix --prefix (not sure why configure --prefix isn't honored properly).
	# 2. Remove duplicate path in CFLAGS.
	# 3. Remove duplicate path in includedir(s).
	@find . -name \*.pc -print -exec sed -i '' -E \
	    -e 's,^prefix=.+,prefix=/usr,' \
	    -e 's,[[:space:]]+(\-I)?\$\{prefix\}/\./include[[:space:]]*,,g' \
	    {} +

	@cd ${SRCTOP}/secure/lib/libcrypto && \
	    ${MAKE} cleanasm && \
	    ${MAKE} buildasm

	@rsync -a --delete \
	    --exclude 'Makefile*' --exclude '*.1' \
	    ${LCRYPTO_DOC}/man/ \
	    ${SRCTOP}/secure/lib/libcrypto/man

	@rsync -a --delete \
	    --exclude 'Makefile*' --exclude '*.[357]' \
	    ${LCRYPTO_DOC}/man/man1/ \
	    ${SRCTOP}/secure/usr.bin/openssl/man


# This doesn't use standard patching since the generated files can vary
# depending on the host architecture.
patch: configure
	# Spam arch-specific overrides to config files.

	@cd ${.CURDIR} && gmake ${BN_CONF_H} && \
	${MV} ${BN_CONF_H} ${BN_CONF_H_ORIG} && \
	${CAT} ${BN_CONF_H}.orig \
	    ${LCRYPTO_SRC}/freebsd/${BN_CONF_H} >> \
	    ${BN_CONF_H}

	@cd ${.CURDIR} && \
	 ${MV} ${CONFIGURATION_H} ${CONFIGURATION_H_ORIG} && \
	 ${CAT} ${CONFIGURATION_H_ORIG} \
	    ${LCRYPTO_SRC}/freebsd/${CONFIGURATION_H} >> \
	    ${CONFIGURATION_H}


clean: .PHONY
	@cd ${.CURDIR} && rm -f ${BN_CONF_H_ORIG} ${CONFIGURATION_H_ORIG}

	@cd ${SRCTOP}/secure/lib/libcrypto && ${MAKE} cleanasm

	-@cd ${.CURDIR} && gmake ${.TARGET}

.include <sys.mk>