blob: c6d146335e7de7bfb22812fb56ed3bf354e0f606 [file] [log] [blame]
Petr Vorelfa5b22d2017-10-04 12:22:58 +02001#!/bin/sh
Petr Vorel24519c12018-12-18 10:31:51 +01002# Copyright (c) 2017-2018 Petr Vorel <pvorel@suse.cz>
Petr Vorelfa5b22d2017-10-04 12:22:58 +02003# Script for travis builds.
4#
5# TODO: Implement comparison of installed files. List of installed files can
6# be used only for local builds as Travis currently doesn't support sharing
7# file between jobs, see
8# https://github.com/travis-ci/travis-ci/issues/6054
9
10set -e
11
Petr Vorel9039d442019-04-12 01:31:15 +020012CFLAGS="${CFLAGS:--Werror=implicit-function-declaration}"
13CC="${CC:-gcc}"
14
Petr Vorel73e4ec42017-12-14 17:58:56 +010015DEFAULT_PREFIX="$HOME/ltp-install"
Petr Vorel612fd8b2018-01-26 19:34:20 +010016DEFAULT_BUILD="native"
17DEFAULT_TREE="in"
Petr Vorel73e4ec42017-12-14 17:58:56 +010018CONFIGURE_OPTS_IN_TREE="--with-open-posix-testsuite --with-realtime-testsuite"
Petr Vorelfa5b22d2017-10-04 12:22:58 +020019# TODO: open posix testsuite is currently broken in out-tree-build. Enable it once it's fixed.
20CONFIGURE_OPTS_OUT_TREE="--with-realtime-testsuite"
Petr Vorelfa5b22d2017-10-04 12:22:58 +020021MAKE_OPTS="-j$(getconf _NPROCESSORS_ONLN)"
22
23build_32()
24{
Petr Vorel612fd8b2018-01-26 19:34:20 +010025 echo "===== 32-bit ${1}-tree build into $PREFIX ====="
Petr Voreldba3b822019-08-02 15:17:50 +020026 CFLAGS="-m32 $CFLAGS" LDFLAGS="-m32 $LDFLAGS"
27 build $1
Petr Vorelfa5b22d2017-10-04 12:22:58 +020028}
29
30build_native()
31{
Petr Vorel612fd8b2018-01-26 19:34:20 +010032 echo "===== native ${1}-tree build into $PREFIX ====="
33 build $1
Petr Vorelfa5b22d2017-10-04 12:22:58 +020034}
35
Petr Vorel29a9e7a2017-12-14 19:03:48 +010036build_cross()
37{
38 local host="${CC%-gcc}"
39 [ -n "$host" ] || \
40 { echo "Missing CC variable, pass it with -c option." >&2; exit 1; }
41
Petr Vorel612fd8b2018-01-26 19:34:20 +010042 echo "===== cross-compile ${host} ${1}-tree build into $PREFIX ====="
43 build $1 "--host=$host" CROSS_COMPILE="${host}-"
44}
45
46build()
47{
48 local tree="$1"
49 shift
50
51 echo "=== autotools ==="
52 make autotools
53
54 if [ "$tree" = "in" ]; then
55 build_in_tree $@
56 else
57 build_out_tree $@
58 fi
Petr Vorel29a9e7a2017-12-14 19:03:48 +010059}
60
Petr Vorelfa5b22d2017-10-04 12:22:58 +020061build_out_tree()
62{
63 local tree="$PWD"
64 local build="$tree/../ltp-build"
65 local make_opts="$MAKE_OPTS -C $build -f $tree/Makefile top_srcdir=$tree top_builddir=$build"
66
Petr Vorelfa5b22d2017-10-04 12:22:58 +020067 mkdir -p $build
Petr Vorelfa5b22d2017-10-04 12:22:58 +020068 cd $build
Petr Voreldba3b822019-08-02 15:17:50 +020069 run_configure $tree/configure $CONFIGURE_OPTS_OUT_TREE $@
Petr Vorelfa5b22d2017-10-04 12:22:58 +020070
Petr Vorel612fd8b2018-01-26 19:34:20 +010071 echo "=== build ==="
Petr Vorelfa5b22d2017-10-04 12:22:58 +020072 make $make_opts
Petr Vorel612fd8b2018-01-26 19:34:20 +010073
74 echo "=== install ==="
Petr Vorelfa5b22d2017-10-04 12:22:58 +020075 make $make_opts DESTDIR="$PREFIX" SKIP_IDCHECK=1 install
76}
77
78build_in_tree()
79{
Petr Voreldba3b822019-08-02 15:17:50 +020080 run_configure ./configure $CONFIGURE_OPTS_IN_TREE --prefix=$PREFIX $@
Petr Vorelfa5b22d2017-10-04 12:22:58 +020081
82 echo "=== build ==="
83 make $MAKE_OPTS
84
85 echo "=== install ==="
86 make $MAKE_OPTS install
87}
88
Petr Vorel73e4ec42017-12-14 17:58:56 +010089run_configure()
90{
91 local configure=$1
92 shift
93
Petr Voreldba3b822019-08-02 15:17:50 +020094 export CC CFLAGS LDFLAGS
95 echo "CC='$CC' CFLAGS='$CFLAGS' LDFLAGS='$LDFLAGS'"
96
Petr Vorel73e4ec42017-12-14 17:58:56 +010097 echo "=== configure $configure $@ ==="
98 if ! $configure $@; then
99 echo "== ERROR: configure failed, config.log =="
100 cat config.log
101 exit 1
102 fi
103
104 echo "== include/config.h =="
105 cat include/config.h
106}
107
Petr Vorelfa5b22d2017-10-04 12:22:58 +0200108usage()
109{
110 cat << EOF
111Usage:
Petr Vorel612fd8b2018-01-26 19:34:20 +0100112$0 [ -c CC ] [ -o TREE ] [ -p DIR ] [ -t TYPE ]
Petr Vorel73e4ec42017-12-14 17:58:56 +0100113$0 -h
Petr Vorelfa5b22d2017-10-04 12:22:58 +0200114
115Options:
Petr Vorel73e4ec42017-12-14 17:58:56 +0100116-h Print this help
117-c CC Define compiler (\$CC variable)
Petr Vorel612fd8b2018-01-26 19:34:20 +0100118-o TREE Specify build tree, default: $DEFAULT_TREE
Petr Vorel73e4ec42017-12-14 17:58:56 +0100119-p DIR Change installation directory. For in-tree build is this value passed
120 to --prefix option of configure script. For out-of-tree build is this
121 value passed to DESTDIR variable (i.e. sysroot) of make install
122 target, which means that LTP will be actually installed into
123 DIR/PREFIX (i.e. DIR/opt/ltp).
124 Default for in-tree build: '$DEFAULT_PREFIX'
125 Default for out-of-tree build: '$DEFAULT_PREFIX/opt/ltp'
126-t TYPE Specify build type, default: $DEFAULT_BUILD
Petr Vorelfa5b22d2017-10-04 12:22:58 +0200127
Petr Vorel612fd8b2018-01-26 19:34:20 +0100128BUILD TREE:
129in in-tree build
130out out-of-tree build
131
Petr Vorelfa5b22d2017-10-04 12:22:58 +0200132BUILD TYPES:
Petr Vorel73e4ec42017-12-14 17:58:56 +010013332 32-bit in-tree build
Petr Vorel29a9e7a2017-12-14 19:03:48 +0100134cross cross-compile in-tree build (requires set compiler via -c switch)
Petr Vorel73e4ec42017-12-14 17:58:56 +0100135native native in-tree build
Petr Vorelfa5b22d2017-10-04 12:22:58 +0200136EOF
137}
138
Petr Vorel73e4ec42017-12-14 17:58:56 +0100139PREFIX="$DEFAULT_PREFIX"
140build="$DEFAULT_BUILD"
Petr Vorel612fd8b2018-01-26 19:34:20 +0100141tree="$DEFAULT_TREE"
Petr Vorel73e4ec42017-12-14 17:58:56 +0100142
Petr Vorel612fd8b2018-01-26 19:34:20 +0100143while getopts "c:ho:p:t:" opt; do
Petr Vorel73e4ec42017-12-14 17:58:56 +0100144 case "$opt" in
145 c) CC="$OPTARG";;
146 h) usage; exit 0;;
Petr Vorel612fd8b2018-01-26 19:34:20 +0100147 o) case "$OPTARG" in
148 in|out) tree="$OPTARG";;
149 *) echo "Wrong build tree '$OPTARG'" >&2; usage; exit 1;;
150 esac;;
Petr Vorel73e4ec42017-12-14 17:58:56 +0100151 p) PREFIX="$OPTARG";;
152 t) case "$OPTARG" in
Petr Vorel612fd8b2018-01-26 19:34:20 +0100153 32|cross|native) build="$OPTARG";;
Petr Vorel73e4ec42017-12-14 17:58:56 +0100154 *) echo "Wrong build type '$OPTARG'" >&2; usage; exit 1;;
155 esac;;
156 ?) usage; exit 1;;
157 esac
158done
Petr Vorelfa5b22d2017-10-04 12:22:58 +0200159
160cd `dirname $0`
Petr Vorel24519c12018-12-18 10:31:51 +0100161
162echo "=== ver_linux ==="
163./ver_linux
164echo
165
166echo "=== compiler version ==="
167$CC --version
168
Petr Vorel612fd8b2018-01-26 19:34:20 +0100169eval build_$build $tree