Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Petr Vorel | 24519c1 | 2018-12-18 10:31:51 +0100 | [diff] [blame] | 2 | # Copyright (c) 2017-2018 Petr Vorel <pvorel@suse.cz> |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 3 | # 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 | |
| 10 | set -e |
| 11 | |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 12 | DEFAULT_PREFIX="$HOME/ltp-install" |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 13 | DEFAULT_BUILD="native" |
| 14 | DEFAULT_TREE="in" |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 15 | CONFIGURE_OPTS_IN_TREE="--with-open-posix-testsuite --with-realtime-testsuite" |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 16 | # TODO: open posix testsuite is currently broken in out-tree-build. Enable it once it's fixed. |
| 17 | CONFIGURE_OPTS_OUT_TREE="--with-realtime-testsuite" |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 18 | MAKE_OPTS="-j$(getconf _NPROCESSORS_ONLN)" |
Petr Vorel | 24519c1 | 2018-12-18 10:31:51 +0100 | [diff] [blame] | 19 | CC=gcc |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 20 | |
| 21 | build_32() |
| 22 | { |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 23 | echo "===== 32-bit ${1}-tree build into $PREFIX =====" |
| 24 | build $1 CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32" |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | build_native() |
| 28 | { |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 29 | echo "===== native ${1}-tree build into $PREFIX =====" |
| 30 | build $1 |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 31 | } |
| 32 | |
Petr Vorel | 29a9e7a | 2017-12-14 19:03:48 +0100 | [diff] [blame] | 33 | build_cross() |
| 34 | { |
| 35 | local host="${CC%-gcc}" |
| 36 | [ -n "$host" ] || \ |
| 37 | { echo "Missing CC variable, pass it with -c option." >&2; exit 1; } |
| 38 | |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 39 | echo "===== cross-compile ${host} ${1}-tree build into $PREFIX =====" |
| 40 | build $1 "--host=$host" CROSS_COMPILE="${host}-" |
| 41 | } |
| 42 | |
| 43 | build() |
| 44 | { |
| 45 | local tree="$1" |
| 46 | shift |
| 47 | |
| 48 | echo "=== autotools ===" |
| 49 | make autotools |
| 50 | |
| 51 | if [ "$tree" = "in" ]; then |
| 52 | build_in_tree $@ |
| 53 | else |
| 54 | build_out_tree $@ |
| 55 | fi |
Petr Vorel | 29a9e7a | 2017-12-14 19:03:48 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 58 | build_out_tree() |
| 59 | { |
| 60 | local tree="$PWD" |
| 61 | local build="$tree/../ltp-build" |
| 62 | local make_opts="$MAKE_OPTS -C $build -f $tree/Makefile top_srcdir=$tree top_builddir=$build" |
| 63 | |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 64 | mkdir -p $build |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 65 | cd $build |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 66 | run_configure $tree/configure $CONFIGURE_OPTS_OUT_TREE CC="$CC" $@ |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 67 | |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 68 | echo "=== build ===" |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 69 | make $make_opts |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 70 | |
| 71 | echo "=== install ===" |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 72 | make $make_opts DESTDIR="$PREFIX" SKIP_IDCHECK=1 install |
| 73 | } |
| 74 | |
| 75 | build_in_tree() |
| 76 | { |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 77 | run_configure ./configure $CONFIGURE_OPTS_IN_TREE CC="$CC" --prefix=$PREFIX $@ |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 78 | |
| 79 | echo "=== build ===" |
| 80 | make $MAKE_OPTS |
| 81 | |
| 82 | echo "=== install ===" |
| 83 | make $MAKE_OPTS install |
| 84 | } |
| 85 | |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 86 | run_configure() |
| 87 | { |
| 88 | local configure=$1 |
| 89 | shift |
| 90 | |
| 91 | echo "=== configure $configure $@ ===" |
| 92 | if ! $configure $@; then |
| 93 | echo "== ERROR: configure failed, config.log ==" |
| 94 | cat config.log |
| 95 | exit 1 |
| 96 | fi |
| 97 | |
| 98 | echo "== include/config.h ==" |
| 99 | cat include/config.h |
| 100 | } |
| 101 | |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 102 | usage() |
| 103 | { |
| 104 | cat << EOF |
| 105 | Usage: |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 106 | $0 [ -c CC ] [ -o TREE ] [ -p DIR ] [ -t TYPE ] |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 107 | $0 -h |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 108 | |
| 109 | Options: |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 110 | -h Print this help |
| 111 | -c CC Define compiler (\$CC variable) |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 112 | -o TREE Specify build tree, default: $DEFAULT_TREE |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 113 | -p DIR Change installation directory. For in-tree build is this value passed |
| 114 | to --prefix option of configure script. For out-of-tree build is this |
| 115 | value passed to DESTDIR variable (i.e. sysroot) of make install |
| 116 | target, which means that LTP will be actually installed into |
| 117 | DIR/PREFIX (i.e. DIR/opt/ltp). |
| 118 | Default for in-tree build: '$DEFAULT_PREFIX' |
| 119 | Default for out-of-tree build: '$DEFAULT_PREFIX/opt/ltp' |
| 120 | -t TYPE Specify build type, default: $DEFAULT_BUILD |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 121 | |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 122 | BUILD TREE: |
| 123 | in in-tree build |
| 124 | out out-of-tree build |
| 125 | |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 126 | BUILD TYPES: |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 127 | 32 32-bit in-tree build |
Petr Vorel | 29a9e7a | 2017-12-14 19:03:48 +0100 | [diff] [blame] | 128 | cross cross-compile in-tree build (requires set compiler via -c switch) |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 129 | native native in-tree build |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 130 | EOF |
| 131 | } |
| 132 | |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 133 | PREFIX="$DEFAULT_PREFIX" |
| 134 | build="$DEFAULT_BUILD" |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 135 | tree="$DEFAULT_TREE" |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 136 | |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 137 | while getopts "c:ho:p:t:" opt; do |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 138 | case "$opt" in |
| 139 | c) CC="$OPTARG";; |
| 140 | h) usage; exit 0;; |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 141 | o) case "$OPTARG" in |
| 142 | in|out) tree="$OPTARG";; |
| 143 | *) echo "Wrong build tree '$OPTARG'" >&2; usage; exit 1;; |
| 144 | esac;; |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 145 | p) PREFIX="$OPTARG";; |
| 146 | t) case "$OPTARG" in |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 147 | 32|cross|native) build="$OPTARG";; |
Petr Vorel | 73e4ec4 | 2017-12-14 17:58:56 +0100 | [diff] [blame] | 148 | *) echo "Wrong build type '$OPTARG'" >&2; usage; exit 1;; |
| 149 | esac;; |
| 150 | ?) usage; exit 1;; |
| 151 | esac |
| 152 | done |
Petr Vorel | fa5b22d | 2017-10-04 12:22:58 +0200 | [diff] [blame] | 153 | |
| 154 | cd `dirname $0` |
Petr Vorel | 24519c1 | 2018-12-18 10:31:51 +0100 | [diff] [blame] | 155 | |
| 156 | echo "=== ver_linux ===" |
| 157 | ./ver_linux |
| 158 | echo |
| 159 | |
| 160 | echo "=== compiler version ===" |
| 161 | $CC --version |
| 162 | |
Petr Vorel | 612fd8b | 2018-01-26 19:34:20 +0100 | [diff] [blame] | 163 | eval build_$build $tree |