-
Notifications
You must be signed in to change notification settings - Fork 112
/
configure.in
197 lines (174 loc) · 6.65 KB
/
configure.in
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.67)
AC_INIT()
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
AC_CHECK_LIB([m], [main])
AC_CHECK_LIB([crypto], [main])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([string.h unistd.h],,[AC_MSG_ERROR(not found the header file for mod_mruby.)])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
# Checks for library functions.
AC_FUNC_STAT
AC_CHECK_FUNCS([memset putenv strtol])
# nginx src root
NGX_SRC_ROOT=no
AC_ARG_WITH(ngx_src_root, AC_HELP_STRING([--with-ngx-src-root=DIR],
[pathname to ngx_src_root [[ngx_src_root]]]),
[NGX_SRC_ROOT="$with_ngx_src_root"])
if test "$NGX_SRC_ROOT" = no; then
AC_MSG_ERROR([nginx src dir not found.])
fi
AC_SUBST(NGX_SRC_ROOT)
NGX_OPENSSL_SRC=
AC_ARG_WITH(openssl_src, AC_HELP_STRING([--with-openssl-src=DIR],
[set path to OpenSSL library sources]),
[NGX_OPENSSL_SRC="$with_openssl_src"])
if test "X$NGX_OPENSSL_SRC" != X ; then
MRUBY_BUILD_DEPEND_TARGETS=openssl
fi
AC_SUBST(NGX_OPENSSL_SRC)
AC_SUBST(MRUBY_BUILD_DEPEND_TARGETS)
BUILD_DIR=build
AC_ARG_WITH(build_dir, AC_HELP_STRING([--with-build-dir=DIR],
[set build directory path]),
[BUILD_DIR="$with_build_dir"])
AC_SUBST(BUILD_DIR)
AC_ARG_ENABLE(dynamic_module, AC_HELP_STRING([--enable-dynamic-module],
[Use nginx dynamic modules]))
if test "x$enable_dynamic_module" = xyes ; then
NGX_MAKEFILE_DEPENDS_TARGET=mrbgems_config_dynamic
NGX_CONFIG_ADD_MODULE_OPT_NAME=--add-dynamic-module
BUILD_DYNAMIC_MODULE=TRUE
NGX_MRUBY_CFLAGS=-fPIC
else
NGX_MAKEFILE_DEPENDS_TARGET=mrbgems_config
NGX_CONFIG_ADD_MODULE_OPT_NAME=--add-module
BUILD_DYNAMIC_MODULE=""
NGX_MRUBY_CFLAGS=""
fi
NGX_MRUBY_LDFLAGS=""
# We don't want use AC_CANONICAL_HOST. It requires install-sh and other helper files.
# AC_CANONICAL_HOST
host_os=`uname -s | tr [[:upper:]] [[:lower:]]`
if test "X$NGX_OPENSSL_SRC" = X ; then
if test "${host_os}" = darwin; then
# Homebrew, pkgsrc
for openssl_dir in /usr/local/opt/openssl /opt/pkg
do
if test -d ${openssl_dir}/include/openssl; then
NGX_MRUBY_LDFLAGS="-L${openssl_dir}/lib -lcrypto"
NGX_MRUBY_CFLAGS="${NGX_MRUBY_CFLAGS} -I${openssl_dir}/include"
break
fi
done
fi
fi
AC_SUBST(NGX_MAKEFILE_DEPENDS_TARGET)
AC_SUBST(NGX_CONFIG_ADD_MODULE_OPT_NAME)
AC_SUBST(BUILD_DYNAMIC_MODULE)
AC_SUBST(NGX_MRUBY_CFLAGS)
AC_SUBST(NGX_MRUBY_LDFLAGS)
if test "X$NGX_OPENSSL_SRC" != X ; then
NGX_OPENSSL_INSTALL_DIR=$NGX_OPENSSL_SRC/.openssl
NGX_CFLAGS=-I$NGX_OPENSSL_INSTALL_DIR/include
if test "x$enable_dynamic_module" = xyes ; then
NGX_LDFLAGS="-L$NGX_OPENSSL_INSTALL_DIR/lib\ -Wl,-rpath,$NGX_OPENSSL_INSTALL_DIR/lib"
else
NGX_LIBS="$NGX_OPENSSL_INSTALL_DIR/lib/libssl.a $NGX_OPENSSL_INSTALL_DIR/lib/libcrypto.a"
fi
# * github master branch (as of Feb 3 2020)
# * nginx doesn't support it yet.
# * VERSION exist, but no include/openssl/opensslv.h and no Makefile.
# * 1.1.x tar ball
# * include/openssl/opensslv.h exists, but no Makefile.
# * Makefile is generated at build time.
# * enable-tlsext is gone.
# * Makefile targets are build_all_generated install_sw
# * 1.0.x tar ball
# * crypto/opensslv.h and Makefile exist.
# * include/openssl/opensslv.h is generated at build time.
# * enable-tlsext is supported.
# * Makefile targets are build_all and install_sw.
if test -f $NGX_OPENSSL_SRC/VERSION; then
# MAJOR=3
# MINOR=0
# PATCH=0
# PRE_RELEASE_TAG=dev
OPENSSL_VERSION=`(. $NGX_OPENSSL_SRC/VERSION && echo "${MAJOR}.${MINOR}.${PATCH}-${PRE_RELEASE_TAG}")`
elif test -f $NGX_OPENSSL_SRC/crypto/opensslv.h; then
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2u-fips 20 Dec 2019"
# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2u 20 Dec 2019"
OPENSSL_VERSION=`grep OPENSSL_VERSION_TEXT $NGX_OPENSSL_SRC/crypto/opensslv.h | grep -o 'OpenSSL [[0-9a-z\.]]*' | head -1 | awk '{print $2}'`
elif test -f $NGX_OPENSSL_SRC/include/openssl/opensslv.h; then
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1d 10 Sep 2019"
OPENSSL_VERSION=`grep OPENSSL_VERSION_TEXT $NGX_OPENSSL_SRC/include/openssl/opensslv.h | grep -o 'OpenSSL [[0-9a-z\.]]*' | awk '{print $2}'`
else
$as_echo "$0: Can't find openssl version information." >&2
exit 255
fi
eval `echo $OPENSSL_VERSION | awk -F '.' '{print "OPENSSL_MAJOR_VERSION=" $1 "\nOPENSSL_MINOR_VERSION=" $2}'`
$as_echo "openssl version is $OPENSSL_VERSION ($OPENSSL_MAJOR_VERSION $OPENSSL_MINOR_VERSION)" >&2
if test $OPENSSL_MAJOR_VERSION -eq 1 -a $OPENSSL_MINOR_VERSION -le 0; then
OPENSSL_MAKE_TARGET="build_all install_sw"
OPENSSL_CONFIG_ENABLE_TLSEXT="enable-tlsext"
else
OPENSSL_MAKE_TARGET="build_all_generated install_sw"
OPENSSL_CONFIG_ENABLE_TLSEXT=""
fi
fi
AC_SUBST(NGX_OPENSSL_INSTALL_DIR)
AC_SUBST(OPENSSL_VERSION)
AC_SUBST(OPENSSL_MAKE_TARGET)
AC_SUBST(OPENSSL_CONFIG_ENABLE_TLSEXT)
AC_SUBST(NGX_CFLAGS)
AC_SUBST(NGX_LDFLAGS)
AC_SUBST(NGX_LIBS)
NGX_OPENSSL_OPT=
AC_ARG_WITH(openssl_opt, AC_HELP_STRING([--with-openssl-opt=OPTIONS],
[set additional build options for OpenSSL]),
[NGX_OPENSSL_OPT="$with_openssl_opt"])
AC_SUBST(NGX_OPENSSL_OPT)
NGX_CONFIG_OPT=
AC_ARG_WITH(ngx_config_opt, AC_HELP_STRING([--with-ngx-config-opt=OPT],
[nginx configure option [[ngx_config_opt]]]),
[NGX_CONFIG_OPT="$with_ngx_config_opt"])
if test "X$NGX_OPENSSL_SRC" != X ; then
NGX_CONFIG_OPT="$NGX_CONFIG_OPT --with-openssl=$NGX_OPENSSL_SRC"
fi
if test "X$NGX_OPENSSL_OPT" != X ; then
NGX_CONFIG_OPT="$NGX_CONFIG_OPT --with-openssl-opt=$NGX_OPENSSL_OPT"
fi
AC_SUBST(NGX_CONFIG_OPT)
# mruby root
MRUBY_ROOT=`pwd`/mruby
AC_ARG_WITH(mruby_root, AC_HELP_STRING([--with-mruby-root=DIR],
[pathname to mruby_root [[mruby_root]]]),
[MRUBY_ROOT="$with_mruby_root"])
AC_SUBST(MRUBY_ROOT)
# mruby include directory
MRUBY_INCDIR=""
AC_ARG_WITH(mruby_incdir, AC_HELP_STRING([--with-mruby-incdir=DIR],
[include directory for mruby [[mruby_incdir]]]),
[MRUBY_INCDIR="$with_mruby_incdir"])
AC_SUBST(MRUBY_INCDIR)
# mruby library directory which contains libmruby
MRUBY_LIBDIR=""
AC_ARG_WITH(mruby_libdir, AC_HELP_STRING([--with-mruby-libdir=DIR],
[library directory to libmruby [[mruby_libdir]]]),
[MRUBY_LIBDIR="$with_mruby_libdir"])
AC_SUBST(MRUBY_LIBDIR)
# ndk root
NDK_ROOT=`pwd`/dependence/ngx_devel_kit
AC_ARG_WITH(ndk_root, AC_HELP_STRING([--with-ndk-root=DIR],
[pathname to ndk_root [[ndk_root]]]),
[NDK_ROOT="$with_ndk_root"])
AC_SUBST(NDK_ROOT)
AC_CONFIG_FILES([Makefile config])
AC_OUTPUT