forked from ibmruntimes/openj9-openjdk-jdk17
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openssl.gmk
105 lines (93 loc) · 4.24 KB
/
openssl.gmk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# ===========================================================================
# (c) Copyright IBM Corp. 2018, 2023 All Rights Reserved
# ===========================================================================
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# IBM designates this particular file as subject to the "Classpath" exception
# as provided by IBM in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
# spec.gmk is generated by configure and contains definitions used in this makefile
ifeq (,$(wildcard $(SPEC)))
$(error OpenSSL.gmk needs SPEC set to a proper spec.gmk)
endif
include $(SPEC)
ifeq ($(OPENJDK_TARGET_OS), windows)
# Configure normally demands that we use an implementation of perl that produces
# paths with backslashes; CONFIGURE_INSIST bypasses that requirement.
# PERL must be an absolute path that will be usable by nmake (i.e. start with
# a drive letter and a colon).
OPENSSL_CONFIG_SETUP := export CONFIGURE_INSIST=true PERL='$(shell $(PATHTOOL) -m $(PERL))' &&
# Configure produces a makefile intended for use with nmake.
OPENSSL_MAKE := nmake
# LIB cannot have the surrounding double-quotes provided by custom-spec.gmk.
# MAKEFLAGS uses unix-style options (with a dash) which won't be understood by nmake.
OPENSSL_MAKE_SETUP := export LIB='$(subst ",,$(LIB))' && unset MAKEFLAGS &&
# The makefile produced by OpenSSL 3+ during the configure step needs to be
# patched. Patching involves adding double-quotes around the name of perl
# script files. For example,
# "$(PERL)" util/mkdef.pl
# must change to
# "$(PERL)" "util/mkdef.pl"
# otherwise nmake appears not to invoke perl as intended.
# Patching has no effect for earlier versions.
OPENSSL_PATCH := \
( $(CD) $(OPENSSL_DIR) \
&& $(MV) -f makefile makefile.orig \
&& $(SED) -e 's|\("$$(PERL)"\) \([A-Za-z0-9_/-]*\.pl\)|\1 "\2"|' < makefile.orig > makefile \
)
else # windows
OPENSSL_CONFIG_SETUP :=
OPENSSL_MAKE := $(MAKE)
OPENSSL_MAKE_SETUP :=
OPENSSL_PATCH :=
endif # windows
# Identify the desired openssl target configuration.
OPENSSL_TARGET :=
ifeq ($(OPENJDK_TARGET_OS), aix)
OPENSSL_TARGET := aix64-cc
else ifeq ($(OPENJDK_TARGET_OS), linux)
ifneq (,$(filter aarch64 ppc64le x86_64, $(OPENJDK_TARGET_CPU)))
OPENSSL_TARGET := linux-$(OPENJDK_TARGET_CPU)
else ifneq (,$(filter riscv64 s390x, $(OPENJDK_TARGET_CPU)))
OPENSSL_TARGET := linux64-$(OPENJDK_TARGET_CPU)
endif
else ifeq ($(OPENJDK_TARGET_OS), macosx)
ifneq (,$(filter arm64 x86_64, $(OPENJDK_TARGET_CPU)))
OPENSSL_TARGET := darwin64-$(OPENJDK_TARGET_CPU)-cc
else ifeq ($(OPENJDK_TARGET_CPU), aarch64)
OPENSSL_TARGET := darwin64-arm64-cc
endif
else ifeq ($(OPENJDK_TARGET_OS), windows)
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
OPENSSL_TARGET := VC-WIN64A
else
OPENSSL_TARGET := VC-WIN32
endif
endif # OPENJDK_TARGET_OS
ifeq (,$(OPENSSL_TARGET))
$(error Unsupported platform $(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU))
endif # OPENSSL_TARGET
ifneq (,$(CCACHE))
# If ccache is enabled and the environment contains either CC or CXX, their
# values (as defined in this make) are propagated to the instance of make
# which will build openssl causing it to fail. Instead, pass along CC and
# CXX without the ccache wrapper.
OPENSSL_MAKE += CC=$(ac_cv_prog_CC) CXX=$(ac_cv_prog_CXX)
endif # CCACHE
build_openssl :
@$(ECHO) Compiling OpenSSL in $(OPENSSL_DIR) for $(OPENSSL_TARGET)
( $(OPENSSL_CONFIG_SETUP) $(CD) $(OPENSSL_DIR) && $(PERL) Configure $(OPENSSL_TARGET) shared )
$(OPENSSL_PATCH)
( $(OPENSSL_MAKE_SETUP) $(CD) $(OPENSSL_DIR) && $(OPENSSL_MAKE) )
.PHONY : build_openssl