Newer
Older
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
136
137
138
139
140
#!/bin/sh
# Copyright 2018 Istituto Nazionale di Fisica Nucleare
#
# Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence"). You may
# not use this work except in compliance with the Licence. You may obtain a copy
# of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# Licence for the specific language governing permissions and limitations under
# the Licence.
# This script builds in debug mode and installs openresty together with the
# ngx_http_voms_module.
#
# The script requires the locations of the openresty bundle and of the
# ngx_http_voms_module code (for example as checked-out from git). The locations
# are expressed by the environment variables OPENRESTY_ROOT and
# NGX_HTTP_VOMS_MODULE_ROOT respectively, if available. If they are not set,
# they are guessed:
# * a unique openresty bundle is looked for in ${HOME}
# * the ngx_http_voms_module code is looked for in the working directory of the
# continuous integration environment first and then in ${HOME}
#
# The script works best (i.e. it is tested) if run within a docker container
# started from the storm2/ngx-voms-build image.
usage()
{
echo "USAGE: $0 [OPTIONS] [TEXT]"
echo ""
echo "The default optimization level is -O3"
echo ""
echo "OPTIONS"
echo ""
echo "-h|--help"
echo "-o|--opt-log to enable the --with-debug option and the optimization level -O2"
echo "-d|--debug to enable the --with-debug option and the optimization level -O0"
echo "-c|--coverage to add the --coverage option to the --with-{ld|cc}-opt option and enable the debug options"
echo ""
}
#The script at the moment allows only debug builds, i.e. "-O0". This option is kept in shell variables cc2, but there is no way to set it to something else. I propose that by default it is set to -O2 (or even -O3) and is set to -O0 only if the option --debug is passed to the script. Moreover --coverage should imply --debug.
cc1=-g
debug=""
cc3=""
cc2=-O2
ld=""
while [ "$1" != "" ]; do
option=`echo $1 | awk -F= '{print $1}'`
case $option in
-o|--opt-log)
debug='--with-debug'
cc2=-O2
echo Enabled the debug option $debug and the optimization level $cc2
;;
-d|--debug)
debug='--with-debug'
cc2=-O0
echo Enabled the debug option $debug and the optimization level $cc2
;;
-c|--coverage)
cc3=--coverage
ld='--with-ld-opt=--coverage'
echo Enabled the coverage options $cc3 $ld
;;
-h|--help)
usage
exit
;;
*)
debug=""
cc3=""
cc2=-O2
ld=""
;;
esac
shift
done
if [ ! -z "${cc3}" ]; then
if [ -z "${debug}" ]; then
debug="--with-debug"
cc2=-O0
echo Enabled the debug option $debug and the optimization level $cc2
fi
fi
if [ -f "${HOME}/openresty-env" ]; then
. ${HOME}/openresty-env
fi
gcc --version
openresty_root=${OPENRESTY_ROOT:-$(ls -d ${HOME}/openresty-*/ 2> /dev/null)}
if [ $(echo ${openresty_root} | wc -w) != 1 -o ! -d "${openresty_root}" ]; then
>&2 echo 'Invalid openresty environment ("'${openresty_root}'")'
exit 1
fi
module_root=${NGX_HTTP_VOMS_MODULE_ROOT:-${CI_PROJECT_DIR:-${HOME}/ngx_http_voms_module}}
if [ ! -d "${module_root}" ]; then
>&2 echo 'Invalid ngx_http_voms_module environment ("'${module_root}'")'
exit 1
fi
RESTY_PACKAGES_PREFIX=/usr/local/openresty
ZLIB_PREFIX=/usr
OPENSSL_PREFIX=/usr
PCRE_PREFIX=/usr
cd ${openresty_root}
./configure \
--with-cc="ccache gcc -fdiagnostics-color=always" \
--with-cc-opt="-DNGX_LUA_ABORT_AT_PANIC -I${ZLIB_PREFIX}/include -I${PCRE_PREFIX}/include -I${OPENSSL_PREFIX}/include" \
--with-ld-opt="-L${ZLIB_PREFIX}/lib -L${PCRE_PREFIX}/lib -L${OPENSSL_PREFIX}/lib -Wl,-rpath,${ZLIB_PREFIX}/lib:${PCRE_PREFIX}/lib:${OPENSSL_PREFIX}/lib" \
--with-luajit-xcflags="-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT" \
${RESTY_CONFIG_OPTIONS} \
${debug} \
--with-cc-opt="${cc1} ${cc2} ${cc3}" \
${ld} \
--add-module=${module_root}
nginx_version=$(find build -name nginx.h | xargs awk '/define NGINX_VERSION/ {print $3}' | tr -d '"')
cd build/nginx-${nginx_version}
patch -p1 < ${HOME}/nginx-httpg_no_delegation.patch
cd -
make -j $(nproc)
make install