1#!/bin/sh 2# 3# %CopyrightBegin% 4# 5# Copyright Ericsson AB 2018-2021. All Rights Reserved. 6# 7# Licensed under the Apache License, Version 2.0 (the "License"); 8# you may not use this file except in compliance with the License. 9# You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, software 14# distributed under the License is distributed on an "AS IS" BASIS, 15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16# See the License for the specific language governing permissions and 17# limitations under the License. 18# 19# %CopyrightEnd% 20# 21# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 22# WARNING! 23# DO NOT EDIT the 'configure' file which is automatically generated from 24# 'configure.src'! In order to update 'configure' edit 'configure.src' and 25# execute './otp_build update_configure [--no-commit]'. 26# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 27# 28# This is a handcrafted wrapper script which runs the actual (autoconf) 29# 'configure' scripts in different parts of OTP. 30# 31# The true (autoconf) configure scripts are run in parallel unless 32# --disable-parallel-configure is passed as argument to this script. 33# 34# The config cache feature is disabled since it mostly causes problems 35# and especially when executing multiple configure scripts in parallel. 36# On windows a static cache for each configure is used since it 37# otherwise takes forever to run configure... 38# 39 40unset CDPATH 41 42default_cflags="-g -O2" 43 44pie_cflags= 45pie_ldflags= 46mXY_build= 47static_cache= 48 49bootstrap_only=no 50parallel_otp_configure=yes 51help=no 52user_srcdir= 53config_arguments= 54skip_applications= 55while test $# != 0; do 56 case $1 in 57 -srcdir=* | --srcdir=*) 58 user_srcdir=`expr -- "$1" : '[^=]*=\(.*\)'` 59 if test "$ERL_TOP" != ""; then 60 echo "WARNING: Overriding ERL_TOP with $user_srcdir" 1>&2 61 echo "" 1>&2 62 fi 63 ERL_TOP="$user_srcdir" 64 ;; 65 -srcdir | --srcdir) 66 shift 67 test $# != 0 || { 68 echo "ERROR: Missing source dir" 1>&2 69 exit 1 70 } 71 user_srcdir="$1" 72 if test "$ERL_TOP" != ""; then 73 echo "WARNING: Overriding ERL_TOP with $user_srcdir" 1>&2 74 echo "" 1>&2 75 fi 76 ERL_TOP="$user_srcdir" 77 ;; 78 --enable-bootstrap-only) 79 config_arguments="$config_arguments --enable-bootstrap-only" 80 bootstrap_only=yes;; 81 --disable-bootstrap-only) 82 config_arguments="$config_arguments --disable-bootstrap-only" 83 bootstrap_only=no;; 84 --enable-option-checking) 85 echo "ERROR: Cannot enable option checking" 1>&2 86 exit 1;; 87 --disable-option-checking) 88 # Got it... 89 ;; 90 --disable-parallel-configure) 91 parallel_otp_configure=no 92 ;; 93 --config-cache | -C) 94 echo "WARNING: Ignoring config cache file since it will mess up the configuration" 1>&2 95 echo "" 1>&2 96 ;; 97 -cache-file=* | --cache-file=* ) 98 static_cache=`expr -- "$1" : '[^=]*=\(.*\)'` 99 if test "$static_cache" != "/dev/null"; then 100 echo "WARNING: Only using config cache file '$static_cache' as static cache" 1>&2 101 echo "" 1>&2 102 else 103 static_cache= 104 fi 105 ;; 106 -cache-file | --cache-file) 107 shift 108 test $# != 0 || { 109 echo "ERROR: Missing cache file" 1>&2 110 exit 1 111 } 112 static_cache=$1 113 if test "$static_cache" != "/dev/null"; then 114 echo "WARNING: Only using config cache file '$static_cache' as static cache" 1>&2 115 echo "" 1>&2 116 else 117 static_cache= 118 fi 119 ;; 120 --enable-m64-build) 121 mXY_build="-m64" 122 ;; 123 --enable-m32-build) 124 mXY_build="-m32" 125 ;; 126 --disable-m64-build) 127 if test "$mXY_build" = "-m64"; then 128 mXY_build= 129 fi;; 130 --disable-m32-build) 131 if test "$mXY_build" = "-m32"; then 132 mXY_build= 133 fi;; 134 --enable-pie) 135 pie_cflags="-fPIE" 136 pie_ldflags="-pie" 137 ;; 138 --disable-pie) 139 pie_cflags="-fno-PIE" 140 pie_ldflags="-no-pie" 141 ;; 142 CFLAGS=* | LDFLAGS=*) 143 flgs_var=`expr -- "$1" : '\([^=]*\)=.*'` 144 flgs_val=`expr -- "$1" : '[^=]*=\(.*\)'` 145 eval $flgs_var=\$flgs_val 146 ;; 147 --help=r* | -help=r*) 148 help=all;; 149 --help* | -help* | -h) 150 help=$1;; 151 *) 152 case $1 in 153 --without-*) 154 skip_app=`expr -- "$1" : '--without-\(.*\)'` 155 if test -d "lib/$skip_app"; then 156 skip_applications="$skip_applications $skip_app" 157 fi;; 158 *) 159 ;; 160 esac 161 case $1 in 162 *\'*) 163 1=`echo "$1" | sed "s/'/'\\\\\\\\''/g"` ;; 164 *) 165 ;; 166 esac 167 config_arguments="$config_arguments '$1'";; 168 esac 169 shift 170done 171 172if test $parallel_otp_configure = yes; then 173 case `uname -s` in 174 MSYS* | msys* | CYGWIN* | cygwin ) 175 ;; 176 *) 177 trap 'kill -KILL -$$' 1 2 3 6 15 178 ;; 179 esac 180fi 181 182# 183# Figure ERL_TOP out... 184# 185 186root_dir= 187dir_chk_data=`date` 188 189if root_dir=`dirname "$0" 2>/dev/null` \ 190 && test "$root_dir" != "" \ 191 && cd "$root_dir" 2>/dev/null; then 192 root_dir=`pwd 2>/dev/null` 193 if test $? -ne 0; then 194 root_dir= 195 else 196 case "$root_dir" in 197 /*) 198 echo "$dir_chk_data" > "$root_dir"/config.dir.check.$$ 2>/dev/null 199 ;; 200 *) 201 root_dir= 202 esac 203 fi 204else 205 root_dir= 206fi 207 208if test "$root_dir" = ""; then 209 case X"$ERL_TOP" in 210 X) 211 echo "ERROR: Cannot figure out the root directory of" 1>&2 212 echo " the OTP source. Please set the ERL_TOP" 1>&2 213 echo " environment variable." 1>&2 214 exit 1 215 ;; 216 X/*) 217 cd "$ERL_TOP" 2>/dev/null || { 218 echo "ERROR: Cannot change directory to ERL_TOP " 1>&2 219 echo " '$ERL_TOP'" 1>&2 220 exit 1 221 } 222 ;; 223 X*) 224 echo "ERROR: ERL_TOP '$ERL_TOP' is not an absolute path" 1>&2 225 exit 1 226 ;; 227 esac 228else 229 case X"$ERL_TOP" in 230 X) 231 ERL_TOP="$root_dir" 232 rm -f "$root_dir"/config.dir.check.$$ 233 ;; 234 X/*) 235 cd "$ERL_TOP" 2>/dev/null || { 236 rm -f "$root_dir"/config.dir.check.$$ 237 echo "ERROR: Cannot change directory into ERL_TOP " 1>&2 238 echo " '$ERL_TOP'" 1>&2 239 exit 1 240 } 241 dir_chk=`cat ./config.dir.check.$$ 2>/dev/null` || dir_chk=error 242 rm -f "$root_dir"/config.dir.check.$$ 243 test "$dir_chk" = "$dir_chk_data" || { 244 echo "ERROR: ERL_TOP '$ERL_TOP' is not the same" 1>&2 245 echo " as 'configure' location '$root_dir'" 1>&2 246 exit 1 247 } 248 ;; 249 X*) 250 rm -f "$root_dir"/config.dir.check.$$ 251 echo "ERROR: ERL_TOP '$ERL_TOP' is not an absolute path" 1>&2 252 exit 1 253 ;; 254 esac 255fi 256 257export ERL_TOP 258 259rm -f "$ERL_TOP/lib/SKIP-APPLICATIONS" 260 261case "$help" in 262 no) 263 ;; 264 all) 265 (cd "$ERL_TOP/make" && ./configure --help) 266 app_dirs= 267 for app_dir in erts lib/*; do 268 if test -f "$app_dir/configure"; then 269 echo "" 270 echo "=== $app_dir ===" 271 (cd "$ERL_TOP/$app_dir" && ./configure --help=short) 272 fi 273 done 274 exit 0;; 275 *) 276 (cd "$ERL_TOP/make" && ./configure "$help") 277 exit 0;; 278esac 279 280if test "$mXY_build" = "" && test "$pie_cflags" = ""; then 281 if test "$CFLAGS" != ""; then 282 config_arguments="$config_arguments CFLAGS='$CFLAGS'" 283 unset CFLAGS 284 fi 285 286 if test "$LDFLAGS" != ""; then 287 config_arguments="$config_arguments LDFLAGS='$LDFLAGS'" 288 unset LDFLAGS 289 fi 290else 291 if test "$CFLAGS" = ""; then 292 CFLAGS=$default_cflags 293 fi 294 config_arguments="$config_arguments CFLAGS='$mXY_build $pie_cflags $CFLAGS'" 295 unset CFLAGS 296 config_arguments="$config_arguments LDFLAGS='$mXY_build $pie_ldflags $LDFLAGS'" 297 unset LDFLAGS 298 case $mXY_build in 299 -m32) 300 config_arguments="$config_arguments --enable-m32-build" 301 ;; 302 -m64) 303 config_arguments="$config_arguments --enable-m64-build" 304 ;; 305 esac 306fi 307 308config_arguments="$config_arguments --disable-option-checking" 309 310if test $bootstrap_only = no; then 311 check_conf_dirs=`echo lib/*` 312else 313 check_conf_dirs="@BOOTSTRAP_LIB_APP_DIRS@" 314fi 315 316# 'erts' *needs* to be last in app_dirs! Any apps 317# after it wont be able to run in parallel with 318# erts... 319 320app_dirs= 321for app_dir in make $check_conf_dirs erts; do 322 if test -f "$app_dir/configure"; then 323 if test "$static_cache" != ""; then 324 cp -f "$static_cache" "$ERL_TOP/$app_dir/local.static.config.cache" 325 fi 326 rm -f $app_dir/configure.result.failed 327 rm -f $app_dir/configure.result.command 328 rm -f $app_dir/configure.result.stdout 329 rm -f $app_dir/configure.result.stderr 330 app_dirs="$app_dirs $app_dir" 331 fi 332done 333 334if test "$static_cache" = ""; then 335 local_cache_file=/dev/null 336else 337 local_cache_file=./local.static.config.cache 338fi 339 340for app_dir in $app_dirs; do 341 cd "$ERL_TOP/$app_dir" 342 cmd_str="./configure $config_arguments --cache-file=$local_cache_file --srcdir=\"$ERL_TOP/$app_dir\"" 343 if test $parallel_otp_configure = no; then 344 echo "=== Running configure in $ERL_TOP/$app_dir ===" 345 eval $cmd_str 346 echo "" 347 elif test $app_dir != erts; then 348 echo $cmd_str >./configure.result.command 349 eval $cmd_str 1>./configure.result.stdout 2>./configure.result.stderr || echo "fatal" > "./configure.result.failed" & 350 else 351 # ERTS configure gets to use stdout/stderr; the others are printed when done... 352 echo "=== Running configure in $ERL_TOP/erts ===" 353 echo $cmd_str 354 eval $cmd_str || { 355 rm -f erts/configure.result.* lib/*/configure.result.* 356 echo "ERROR: $ERL_TOP/$app_dir/configure failed!" 1>&2 357 kill -KILL -$$ 358 exit 1 359 } 360 fi 361done 362 363cd "$ERL_TOP" 364 365if test $parallel_otp_configure = yes; then 366 # Wait for all sub-configures to finish... 367 wait 368 369 for app_dir in $app_dirs; do 370 if test -f "$app_dir/configure.result.command"; then 371 echo "" 372 echo "=== Running configure in $ERL_TOP/$app_dir ===" 373 cat "$app_dir/configure.result.command" 374 rm -f "$app_dir/configure.result.command" 375 fi 376 if test -f "$app_dir/configure.result.stdout"; then 377 cat "$app_dir/configure.result.stdout" 378 rm -f "$app_dir/configure.result.stdout" 379 fi 380 if test -f "$app_dir/configure.result.stderr"; then 381 cat "$app_dir/configure.result.stderr" 1>&2 382 rm -f "$app_dir/configure.result.stderr" 383 fi 384 if test -f "$app_dir/configure.result.failed"; then 385 rm -f erts/configure.result.* lib/*/configure.result.* 386 echo "ERROR: $ERL_TOP/$app_dir/configure failed!" 1>&2 387 exit 1 388 fi 389 done 390fi 391 392 393echo "" 394 395pattern="lib/*/SKIP" 396files=`echo $pattern` 397if test "$files" != "$pattern" || test "$skip_applications" != ""; then 398 echo '*********************************************************************' 399 echo '********************** APPLICATIONS DISABLED **********************' 400 echo '*********************************************************************' 401 echo 402 if test "$files" != "$pattern"; then 403 for skipfile in $files; do 404 app=`dirname $skipfile`; app=`basename $app` 405 printf "%-15s: " $app; cat $skipfile 406 done 407 fi 408 for skipapp in $skip_applications; do 409 printf "%-15s: User gave --without-%s option\n" $skipapp $skipapp 410 echo "$skipapp" >> "$ERL_TOP/lib/SKIP-APPLICATIONS" 411 done 412 echo 413 echo '*********************************************************************' 414fi 415pattern="lib/*/CONF_INFO" 416files=`echo $pattern` 417if test "$files" != "$pattern" || test -f erts/CONF_INFO; then 418 echo '*********************************************************************' 419 echo '********************** APPLICATIONS INFORMATION *******************' 420 echo '*********************************************************************' 421 echo 422 test "$files" != "$pattern" || files="" 423 test ! -f erts/CONF_INFO || files="$files erts/CONF_INFO" 424 for infofile in $files; do 425 app=`dirname $infofile`; app=`basename $app` 426 printf "%-15s: " $app; cat $infofile 427 done 428 echo 429 echo '*********************************************************************' 430fi 431if test -f "erts/doc/CONF_INFO"; then 432 echo '*********************************************************************' 433 echo '********************** DOCUMENTATION INFORMATION ******************' 434 echo '*********************************************************************' 435 echo 436 printf "%-15s: \n" documentation; 437 havexsltproc="yes" 438 for cmd in `cat erts/doc/CONF_INFO`; do 439 echo " $cmd is missing." 440 if test $cmd = "xsltproc"; then 441 havexsltproc="no" 442 fi 443 done 444 if test $havexsltproc = "no"; then 445 echo ' The documentation cannot be built.' 446 else 447 echo ' Using fakefop to generate placeholder PDF files.' 448 fi 449 echo 450 echo '*********************************************************************' 451fi 452