This repository has been archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildenv
135 lines (117 loc) · 4.82 KB
/
buildenv
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Currently just checks for the presence of clang on the system, used to simplify zopen build
# In the future, this will be used to build clang from source
export ZOPEN_TYPE="BARE"
export ZOPEN_CATEGORIES="development"
export ZOPEN_NAME="comp_clang"
export ZOPEN_CONFIGURE=skip
export ZOPEN_CHECK=zopen_check
export ZOPEN_MAKE=skip
export ZOPEN_INSTALL=zopen_install
zopen_check()
{
# Nothing to check at this time
}
zopen_check_results()
{
# Nothing to check here, assume everything passed
echo "actualFailures:0"
echo "totalTests:1"
echo "expectedFailures:1"
echo "expectedTotalTests:1"
}
zopen_append_to_env()
{
cat <<zz
if [ ! -z "\$ZOPEN_IN_ZOPEN_BUILD" ]; then
#
# Find the path to clang
#
# Use ibm-clang preferably...
CLANG_PATH=\$(PATH="\$ZOPEN_OLD_PATH" /bin/type ibm-clang 2>/dev/null | cut -f3 -d' ')
if [ ! -z "\${CLANG_PATH}" ] ; then
# ibm-clang exists
#echo "Using ibm-clang: \${CLANG_PATH}"
CLANG_BIN=\$(basename \${CLANG_PATH})
else
#echo "ibm-clang does not exist, trying next compiler choice..."
CLANG_BIN=""
fi
# ...fall back on clang
if [ -z "\${CLANG_BIN}" ] ; then
CLANG_PATH=\$(PATH="\$ZOPEN_OLD_PATH" /bin/type clang 2>/dev/null | cut -f3 -d' ')
if [ ! -z "\${CLANG_PATH}" ] ; then
# clang exists
#echo "Using clang: \${CLANG_PATH}"
CLANG_BIN=\$(basename \${CLANG_PATH})
fi
fi
else
return 0 # This should do nothing if not in zopen build
fi
# If Clang is not found, exit with an error message
if [ -z "\${CLANG_PATH}" ]; then
echo "clang not found. Please download and install from https://epwt-www.mybluemix.net/software/support/trial/cst/programwebsite.wss?siteId=1803." >&2
return 1
fi
if ! \${CLANG_PATH} --version >/dev/null 2>&1; then
if ! STEPLIB="\$ZOPEN_OLD_STEPLIB" \${CLANG_PATH} --version >/dev/null 2>&1; then
echo "The clang executable is not a functional zos clang compiler. Please download and install from https://epwt-www.mybluemix.net/software/support/trial/cst/programwebsite.wss?siteId=1803." >&2
return 1
fi
# We need to set STEPLIB
export STEPLIB="\$ZOPEN_OLD_STEPLIB"
fi
if ! \${CLANG_PATH} --version 2>&1 | grep -q "s390x\?-ibm-zos"; then
echo "The clang executable is not a zos clang compiler. Please download and install from https://epwt-www.mybluemix.net/software/support/trial/cst/programwebsite.wss?siteId=1803." >&2
return 1
fi
if [ ! -z "\$ZOPEN_IN_ZOPEN_BUILD" ]; then
# Set the PATH environment variable to the directory of the Clang path
export PATH="\$(dirname "\${CLANG_PATH}"):\${PATH}"
# Set the CC/CXX environment variables to the proper compiler
if [ "\${CLANG_BIN}" = "ibm-clang" ] ; then
export CC="ibm-clang"
export CXX="ibm-clang++"
fi
if [ "\${CLANG_BIN}" = "clang" ] ; then
export CC="clang"
export CXX="clang++"
fi
export ZOPEN_CPPFLAGS="-DNSIG=42 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE -D_OPEN_SYS_FILE_EXT=1 -D_AE_BIMODAL=1 -D_ENHANCED_ASCII_EXT=0xFFFFFFFF"
export ZOPEN_CFLAGS="-fzos-le-char-mode=ascii -std=gnu11 -mnocsect -fno-short-enums -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -m64 -mzos-target=zosv2r4"
export ZOPEN_CXXFLAGS="-fzos-le-char-mode=ascii -mnocsect -fno-short-enums -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -m64 -mzos-target=zosv2r4"
export ZOPEN_LDFLAGS="-Wl,-bedit=no"
export ZOPEN_COMP="CLANG"
if \$buildInReleaseMode; then
ZOPEN_CFLAGS="\${ZOPEN_CFLAGS} -O3";
ZOPEN_CXXFLAGS="\${ZOPEN_CXXFLAGS} -O3";
else
ZOPEN_LDFLAGS=""
fi
# Confirm clang is at least OEL 2.0.0 (aka __COMPILER_VER__=50000000)
ccraw=\$(\${CC} -E -dM - </dev/null | grep '__COMPILER_VER__' | awk '{print substr(\$3,3)}')
if [ "\${ccraw}x" = "x" ]; then
echo "clang compiler specified, but it is not a 'IBM C/C++ for Open Enterprise Languages on z/OS' compiler" >&2
fi
if [ \${ccraw} -lt 50000000 ] ; then
echo "clang compiler specified, need to be running at least IBM C for Open Enterprise Languages on z/OS 2" >&2
fi
# Confirm clang++ is at least OEL 2.0.0 (aka __COMPILER_VER__=50000000)
ccraw=\$(\${CXX} -x c++ -E -dM - </dev/null | grep '__COMPILER_VER__' | awk '{print substr(\$3,3)}')
if [ "\${ccraw}x" = "x" ]; then
echo "clang++ compiler specified, but it is not a 'IBM C/C++ for Open Enterprise Languages on z/OS' compiler" >&2
fi
if [ \${ccraw} -lt 50000000 ] ; then
echo "clang compiler specified, need to be running at least IBM C for Open Enterprise Languages on z/OS 2" >&2
fi
fi
zz
}
zopen_install() {
mkdir -p $ZOPEN_INSTALL_DIR/bin
cp -r $ZOPEN_ROOT/bin/* $ZOPEN_INSTALL_DIR/bin
}
zopen_get_version()
{
PATH=$ZOPEN_OLD_PATH clang --version | head -1 | awk '{print $11; }'
}