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