summaryrefslogtreecommitdiff
path: root/configure.src
blob: ff39a58aa9258d93475347b717a93ac12c8a869c (plain)
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
#!/bin/sh
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 2018. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# %CopyrightEnd%
#
#
# This is a handcrafted wrapper script which runs the actual (autoconf)
# 'configure' scripts in different parts of OTP.
#
# The true (autoconf) configure scripts are run in parallel unless
# --disable-parallel-configure is passed as argument to this script.
#
# The config cache feature is disabled since it mostly causes problems
# and especially when executing multiple configure scripts in parallel.
# On windows a static cache for each configure is used since it
# otherwise takes forever to run configure...
#

OTP_VERSION=@OTP_VERSION@

unset CDPATH

default_cflags="-g -O2"

pie_cflags=
pie_ldflags=
mXY_build=
static_cache=

bootstrap_only=no
parallel_otp_configure=yes
help=no
user_srcdir=
config_arguments=
skip_applications=
while test $# != 0; do
    case $1 in
	-srcdir=* | --srcdir=*)
	    user_srcdir=`expr "$1" : '[^=]*=\(.*\)'`
	    if test "$ERL_TOP" != ""; then
		echo "WARNING: Overriding ERL_TOP with $user_srcdir" 1>&2
		echo "" 1>&2
	    fi
	    ERL_TOP="$user_srcdir"
	    ;;
	-srcdir | --srcdir)
	    shift
	    test $# != 0 || {
		echo "ERROR: Missing source dir" 1>&2
		exit 1
	    }
	    user_srcdir="$1"
	    if test "$ERL_TOP" != ""; then
		echo "WARNING: Overriding ERL_TOP with $user_srcdir" 1>&2
		echo "" 1>&2
	    fi
	    ERL_TOP="$user_srcdir"
	    ;;
	--enable-bootstrap-only)
            config_arguments="$config_arguments --enable-bootstrap-only"
	    bootstrap_only=yes;;
	--disable-bootstrap-only)
            config_arguments="$config_arguments --disable-bootstrap-only"
	    bootstrap_only=no;;
	--enable-option-checking)
	    echo "ERROR: Cannot enable option checking" 1>&2
	    exit 1;;
	--disable-option-checking)
	    # Got it...
	    ;;
	--disable-parallel-configure)
	    parallel_otp_configure=no
	    ;;
	--config-cache | -C)
	    echo "WARNING: Ignoring config cache file since it will mess up the configuration" 1>&2
	    echo "" 1>&2
	    ;;
	-cache-file=* | --cache-file=* )
	    static_cache=`expr "$1" : '[^=]*=\(.*\)'`
	    if test "$static_cache" != "/dev/null"; then
		echo "WARNING: Only using config cache file '$static_cache' as static cache" 1>&2
		echo "" 1>&2
	    else
		static_cache=
	    fi
	    ;;
        -cache-file | --cache-file)
	    shift
	    test $# != 0 || {
		echo "ERROR: Missing cache file" 1>&2
		exit 1
	    }
	    static_cache=$1
	    if test "$static_cache" != "/dev/null"; then
		echo "WARNING: Only using config cache file '$static_cache' as static cache" 1>&2
		echo "" 1>&2
	    else
		static_cache=
	    fi
	    ;;
	--enable-m64-build)
	    mXY_build="-m64"
	    ;;
	--enable-m32-build)
	    mXY_build="-m32"
	    ;;
	--disable-m64-build)
	    if test "$mXY_build" = "-m64"; then
		mXY_build=
	    fi;;
	--disable-m32-build)
	    if test "$mXY_build" = "-m32"; then
		mXY_build=
	    fi;;
	--enable-pie)
	    pie_cflags="-fPIE"
	    pie_ldflags="-pie"
	    ;;
	--disable-pie)
	    pie_cflags="-fno-PIE"
	    pie_ldflags="-no-pie"
	    ;;
	CFLAGS=* | LDFLAGS=*)
	    flgs_var=`expr "$1" : '\([^=]*\)=.*'`
	    flgs_val=`expr "$1" : '[^=]*=\(.*\)'`
	    eval $flgs_var=\$flgs_val
	    ;;
	--help=r* | -help=r*)
	    help=all;;
        --help* | -help* | -h)
	    help=$1;;
        *)
	    case $1 in
		--without-*)
		    skip_app=`expr "$1" : '--without-\(.*\)'`
		    if test -d "lib/$skip_app"; then
			skip_applications="$skip_applications $skip_app"
		    fi;;
		*)
		    ;;
	    esac
            case $1 in
		*\'*)
                    1=`echo "$1" | sed "s/'/'\\\\\\\\''/g"` ;;
		*)
                ;;
            esac
            config_arguments="$config_arguments '$1'";;
    esac
    shift
done

if test $parallel_otp_configure = yes; then
    case `uname -s` in
	MSYS* | msys* | CYGWIN* | cygwin )
            ;;
	*)
	    trap 'kill -KILL -$$' 1 2 3 6 15
	    ;;
    esac
fi

#
# Figure ERL_TOP out...
#

root_dir=
dir_chk_data="$OTP_VERSION"

if root_dir=`dirname "$0" 2>/dev/null` \
	&& test "$root_dir" != "" \
	&& cd "$root_dir" 2>/dev/null; then
    root_dir=`pwd 2>/dev/null`
    if test $? -ne 0; then
	root_dir=
    else
	case "$root_dir" in
	    /*)
		echo $dir_chk_data > "$root_dir"/config.dir.check.$$ 2>/dev/null
		;;
	    *)
		root_dir=
	esac
    fi
else
    root_dir=
fi

if test "$root_dir" = ""; then
    case X"$ERL_TOP" in
	X)
	    echo "ERROR: Cannot figure out the root directory of" 1>&2
	    echo "       the OTP source. Please set the ERL_TOP" 1>&2
	    echo "       environment variable." 1>&2
	    exit 1
	    ;;
	X/*)
	    cd "$ERL_TOP" 2>/dev/null || {
		echo "ERROR: Cannot change directory to ERL_TOP " 1>&2
		echo "       '$ERL_TOP'" 1>&2
		exit 1
	    }
	    ;;
	X*)
	    echo "ERROR: ERL_TOP '$ERL_TOP' is not an absolute path" 1>&2
	    exit 1
	    ;;
    esac
else
    case X"$ERL_TOP" in
	X)
	    ERL_TOP="$root_dir"
	    rm -f "$root_dir"/config.dir.check.$$
	    ;;
	X/*)
	    cd "$ERL_TOP" 2>/dev/null || {
		rm -f "$root_dir"/config.dir.check.$$
		echo "ERROR: Cannot change directory into ERL_TOP " 1>&2
		echo "       '$ERL_TOP'" 1>&2
		exit 1
	    }
	    dir_chk=`cat ./config.dir.check.$$ 2>/dev/null` || dir_chk=error
	    rm -f "$root_dir"/config.dir.check.$$
	    test "$dir_chk" = "$dir_chk_data" || {
		echo "ERROR: ERL_TOP '$ERL_TOP' is not the same" 1>&2
		echo "       as 'configure' location '$root_dir'" 1>&2
		exit 1
	    }
	    ;;
	X*)
	    rm -f "$root_dir"/config.dir.check.$$
	    echo "ERROR: ERL_TOP '$ERL_TOP' is not an absolute path" 1>&2
	    exit 1
	    ;;
    esac
fi

export ERL_TOP

rm -f "$ERL_TOP/lib/SKIP-APPLICATIONS"

case "$help" in
    no)
        ;;
    all)
	(cd "$ERL_TOP/make" && ./configure --help)
	app_dirs=
	for app_dir in erts lib/*; do
	    if test -f "$app_dir/configure"; then
		echo ""
		echo "=== $app_dir ==="
		(cd "$ERL_TOP/$app_dir" && ./configure --help=short)
	    fi
	done
	exit 0;;
    *)
	(cd "$ERL_TOP/make" && ./configure "$help")
	exit 0;;
esac

if test "$mXY_build" = "" && test "$pie_cflags" = ""; then
    if test "$CFLAGS" != ""; then
	config_arguments="$config_arguments CFLAGS='$CFLAGS'"
	unset CFLAGS
    fi

    if test "$LDFLAGS" != ""; then
	config_arguments="$config_arguments LDFLAGS='$LDFLAGS'"
	unset LDFLAGS
    fi
else
    if test "$CFLAGS" = ""; then
	CFLAGS=$default_cflags
    fi
    config_arguments="$config_arguments CFLAGS='$mXY_build $pie_cflags $CFLAGS'"
    unset CFLAGS
    config_arguments="$config_arguments LDFLAGS='$mXY_build $pie_ldflags $LDFLAGS'"
    unset LDFLAGS
    case $mXY_build in
	-m32)
            config_arguments="$config_arguments --enable-m32-build"
	    ;;
	-m64)
            config_arguments="$config_arguments --enable-m64-build"
	    ;;
    esac
fi

config_arguments="$config_arguments --disable-option-checking"

if test $bootstrap_only = no; then
    check_conf_dirs=`echo lib/*`
else
    check_conf_dirs="@BOOTSTRAP_LIB_APP_DIRS@"
fi

# 'erts' *needs* to be last in app_dirs! Any apps
# after it wont be able to run in parallel with
# erts...

app_dirs=
for app_dir in make $check_conf_dirs erts; do
    if test -f "$app_dir/configure"; then
       if test "$static_cache" != ""; then
          cp -f "$static_cache" "$ERL_TOP/$app_dir/local.static.config.cache"
       fi
       rm -f $app_dir/configure.result.failed
       rm -f $app_dir/configure.result.command
       rm -f $app_dir/configure.result.stdout
       rm -f $app_dir/configure.result.stderr
       app_dirs="$app_dirs $app_dir"
    fi
done

if test "$static_cache" = ""; then
   local_cache_file=/dev/null
else
   local_cache_file=./local.static.config.cache
fi

for app_dir in $app_dirs; do
    cd "$ERL_TOP/$app_dir"
    cmd_str="./configure $config_arguments --cache-file=$local_cache_file --srcdir=\"$ERL_TOP/$app_dir\""
    if test $parallel_otp_configure = no; then
	echo "=== Running configure in $ERL_TOP/$app_dir ==="
	eval $cmd_str
	echo ""
    elif test $app_dir != erts; then
	echo $cmd_str >./configure.result.command
	eval $cmd_str 1>./configure.result.stdout 2>./configure.result.stderr || echo "fatal" > "./configure.result.failed" &
    else
	# ERTS configure gets to use stdout/stderr; the others are printed when done...
	echo "=== Running configure in $ERL_TOP/erts ==="
	echo $cmd_str
	eval $cmd_str || {
	    rm -f erts/configure.result.* lib/*/configure.result.*
	    echo "ERROR: $ERL_TOP/$app_dir/configure failed!" 1>&2
	    kill -KILL -$$
	    exit 1
	}
    fi
done

cd "$ERL_TOP"

if test $parallel_otp_configure = yes; then
    # Wait for all sub-configures to finish...
    wait

    for app_dir in $app_dirs; do
	if test -f "$app_dir/configure.result.command"; then
	    echo ""
	    echo "=== Running configure in $ERL_TOP/$app_dir ==="
	    cat "$app_dir/configure.result.command"
	    rm -f "$app_dir/configure.result.command"
	fi
	if test -f "$app_dir/configure.result.stdout"; then
	    cat "$app_dir/configure.result.stdout"
	    rm -f "$app_dir/configure.result.stdout"
	fi
	if test -f "$app_dir/configure.result.stderr"; then
	    cat "$app_dir/configure.result.stderr" 1>&2
	    rm -f "$app_dir/configure.result.stderr"
	fi
	if test -f "$app_dir/configure.result.failed"; then
	    rm -f erts/configure.result.* lib/*/configure.result.*
	    echo "ERROR: $ERL_TOP/$app_dir/configure failed!" 1>&2
	    exit 1
	fi
    done
fi


echo ""

pattern="lib/*/SKIP"
files=`echo $pattern`
if test "$files" != "$pattern" || test "$skip_applications" != ""; then
  echo '*********************************************************************'
  echo '**********************  APPLICATIONS DISABLED  **********************'
  echo '*********************************************************************'
  echo
  if test "$files" != "$pattern"; then
    for skipfile in $files; do
      app=`dirname $skipfile`; app=`basename $app`
      printf "%-15s: " $app; cat $skipfile
    done
  fi
  for skipapp in $skip_applications; do
    printf "%-15s: User gave --without-%s option\n" $skipapp $skipapp
    echo "$skipapp" >> "$ERL_TOP/lib/SKIP-APPLICATIONS"
  done
  echo
  echo '*********************************************************************'
fi
pattern="lib/*/CONF_INFO"
files=`echo $pattern`
if test "$files" != "$pattern" || test -f erts/CONF_INFO; then
  echo '*********************************************************************'
  echo '**********************  APPLICATIONS INFORMATION  *******************'
  echo '*********************************************************************'
  echo
  test "$files" != "$pattern" || files=""
  test ! -f erts/CONF_INFO || files="$files erts/CONF_INFO"
  for infofile in $files; do
    app=`dirname $infofile`; app=`basename $app`
    printf "%-15s: " $app; cat $infofile
  done
  echo
  echo '*********************************************************************'
fi
if test -f "erts/doc/CONF_INFO"; then
  echo '*********************************************************************'
  echo '**********************  DOCUMENTATION INFORMATION  ******************'
  echo '*********************************************************************'
  echo
  printf "%-15s: \n" documentation;
  havexsltproc="yes"
  for cmd in `cat erts/doc/CONF_INFO`; do
	echo "                 $cmd is missing."
  if test $cmd = "xsltproc"; then
    havexsltproc="no"
  fi
  done
  if test $havexsltproc = "no"; then
    echo '                 The documentation cannot be built.'
  else
    echo '                 Using fakefop to generate placeholder PDF files.'
  fi
  echo
  echo '*********************************************************************'
fi