xref: /freebsd/secure/lib/libcrypto/Makefile.inc (revision 0e33efe4e4b5d24e2d416938af8bc6e6e4160ec8)
1# $FreeBSD$
2
3.include <bsd.own.mk>
4
5# OpenSSL version used for manual page generation
6OPENSSL_VER=	1.0.2n
7OPENSSL_DATE=	2017-12-07
8
9LCRYPTO_SRC=	${SRCTOP}/crypto/openssl
10LCRYPTO_DOC=	${LCRYPTO_SRC}/doc
11
12CFLAGS+=	-I${LCRYPTO_SRC}
13CFLAGS+=	-DTERMIOS -DANSI_SOURCE
14CFLAGS+=	-DOPENSSL_THREADS -DDSO_DLFCN -DHAVE_DLFCN_H
15
16.include <bsd.endian.mk>
17
18.if ${TARGET_ENDIANNESS} == 1234
19CFLAGS+=-DL_ENDIAN
20.elif ${TARGET_ENDIANNESS} == 4321
21CFLAGS+=-DB_ENDIAN
22.endif
23
24.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm"
25ASM_${MACHINE_CPUARCH}=
26.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
27_ASM_AVX!=	{ \
28		    echo vzeroall | \
29		    ${CC} -x assembler -o /dev/null -c - 2> /dev/null; \
30		} && echo yes || echo no
31.if ${_ASM_AVX} == yes
32ASM_${MACHINE_CPUARCH}=
33.endif
34.endif
35
36.if defined(ASM_aarch64)
37CFLAGS+=-DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
38.elif defined(ASM_amd64)
39CFLAGS+=-DOPENSSL_IA32_SSE2
40CFLAGS+=-DAES_ASM -DBSAES_ASM -DVPAES_ASM
41CFLAGS+=-DECP_NISTZ256_ASM
42CFLAGS+=-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m
43CFLAGS+=-DMD5_ASM
44CFLAGS+=-DGHASH_ASM
45CFLAGS+=-DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
46CFLAGS+=-DWHIRLPOOL_ASM
47.elif defined(ASM_arm)
48CFLAGS+=-DAES_ASM -DBSAES_ASM
49CFLAGS+=-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m
50CFLAGS+=-DGHASH_ASM
51CFLAGS+=-DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
52.elif defined(ASM_i386)
53CFLAGS+=-DOPENSSL_IA32_SSE2
54CFLAGS+=-DAES_ASM -DVPAES_ASM
55CFLAGS+=-DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m
56CFLAGS+=-DMD5_ASM
57CFLAGS+=-DGHASH_ASM
58CFLAGS+=-DRMD160_ASM
59CFLAGS+=-DSHA1_ASM -DSHA256_ASM -DSHA512_ASM
60CFLAGS+=-DWHIRLPOOL_ASM
61.endif
62
63MANDIR=	${SHAREDIR}/openssl/man/man
64
65.if defined(LIB)
66_docs=	${LIB}
67_skip=	SSLeay_version des_modes
68_sec=	3
69.else
70_docs=	apps
71_skip=	c_rehash config
72_sec=	1
73.endif
74
75man-update:
76.for manpage in ${MAN}
77	@(sec=${manpage:E}; \
78	pod=${manpage:R}.pod; \
79	for i in ${_docs}; do \
80		test -f ${LCRYPTO_DOC}/$$i/$$pod && \
81		cp ${LCRYPTO_DOC}/$$i/$$pod .; \
82	done; \
83	pod2man --section=$$sec --release="${OPENSSL_VER}" \
84	  --date="${OPENSSL_DATE}" --center="OpenSSL"  \
85	  $$pod > ${.CURDIR}/man/${manpage}; \
86	rm -f $$pod; \
87	${ECHO} ${manpage})
88.endfor
89
90man-makefile-update:
91	rm -f ${.CURDIR}/Makefile.man
92	echo '# $$'FreeBSD'$$' >> ${.CURDIR}/Makefile.man
93	echo '# DO NOT EDIT: generated from man-makefile-update target' >> \
94	    ${.CURDIR}/Makefile.man
95	for i in ${_docs}; do \
96		for j in ${LCRYPTO_DOC}/$$i/*.pod; do \
97			test -f $$j || continue; \
98			fn=`basename $$j .pod`; \
99			if ! echo '${_skip}' | grep -qw "$$fn"; then \
100			${ECHO} "MAN+= $$fn.${_sec}"; \
101			fi; \
102		done; \
103	done | env LANG=C sort >> ${.CURDIR}/Makefile.man
104	for i in ${_docs}; do \
105		for j in ${LCRYPTO_DOC}/$$i/*.pod; do \
106			test -f $$j || continue; \
107			fn=`basename $$j .pod`; \
108			if ! echo '${_skip}' | grep -qw "$$fn"; then \
109			perl ${LCRYPTO_SRC}/util/extract-names.pl < $$j | \
110			  awk "/^$$fn\$$/ { next; } \
111			  { print \"MLINKS+= $$fn.${_sec} \" \$$1 \".${_sec}\" }"; \
112			fi; \
113		done; \
114	done | env LANG=C sort >> ${.CURDIR}/Makefile.man
115