build.sh: Allow to overwrite prefix
RFC PATCH 3/3 build.sh: Allow to overwrite prefix
with LTP_PREFIX environment variable.
---
Note about using environment variables and parameters not prefixed with '-' (no options):
I like getopt(s) and the reason I didn't use them is:
* I don't like short opts which provides getopts build-in (the one we use in LTP).
* Long getopts are supported by getopt binary from util-linux which I didn't want to depend on.
--- build.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
build.sh +10 -7
@@ -9,9 +9,9 @@ set -e -PREFIX="$HOME/ltp-install" +LTP_PREFIX="${LTP_PREFIX:-$HOME/ltp-install}" -CONFIGURE_OPTS_IN_TREE="--with-open-posix-testsuite --with-realtime-testsuite --prefix=$PREFIX" +CONFIGURE_OPTS_IN_TREE="--with-open-posix-testsuite --with-realtime-testsuite --prefix=$LTP_PREFIX" # TODO: open posix testsuite is currently broken in out-tree-build. Enable it once it's fixed. CONFIGURE_OPTS_OUT_TREE="--with-realtime-testsuite"
@@ -20,13 +20,13 @@ MAKE_OPTS="-j$(getconf _NPROCESSORS_ONLN)" build_32() { - echo "===== 32-bit in-tree build into $PREFIX =====" + echo "===== 32-bit in-tree build into $LTP_PREFIX =====" build_in_tree CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32" } build_native() { - echo "===== native in-tree build into $PREFIX =====" + echo "===== native in-tree build into $LTP_PREFIX =====" build_in_tree }
@@ -37,7 +37,7 @@ build_cross() [ -n "$host" ] || \ { echo "Missing CROSS_COMPILE and CC variables. You need to set at least one" >&2; exit 1; } - echo "===== cross-compile ${host} in-tree build into $PREFIX =====" + echo "===== cross-compile ${host} in-tree build into $LTP_PREFIX =====" build_in_tree "--host=$host" CROSS_COMPILE="${host}-" }
@@ -47,7 +47,7 @@ build_out_tree() local build="$tree/../ltp-build" local make_opts="$MAKE_OPTS -C $build -f $tree/Makefile top_srcdir=$tree top_builddir=$build" - echo "===== native out-of-tree build into $PREFIX =====" + echo "===== native out-of-tree build into $LTP_PREFIX =====" mkdir -p $build echo "=== autotools ==="
@@ -64,7 +64,7 @@ build_out_tree() cat include/config.h make $make_opts - make $make_opts DESTDIR="$PREFIX" SKIP_IDCHECK=1 install + make $make_opts DESTDIR="$LTP_PREFIX" SKIP_IDCHECK=1 install } build_in_tree()
@@ -106,6 +106,9 @@ native native in-tree build out out-of-tree build Default build is native in-tree build. + +LTP is installed into '$LTP_PREFIX'. +The destination can be changed by setting LTP_PREFIX environment variable. EOF }
Signature · 1 line
2.15.0
RFC PATCH 3/3 build.sh: Allow to overwrite prefix
Hi!
Quoted 2 lines
I like getopt(s) and the reason I didn't use them is:
* I don't like short opts which provides getopts build-in (the one we use in LTP).
Why so, readability concerns?
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 3/3 build.sh: Allow to overwrite prefix
Hi Cyril,
Quoted 4 lines
Quoted 2 lines
I like getopt(s) and the reason I didn't use them is:
* I don't like short opts which provides getopts build-in (the one we use in LTP).Why so, readability concerns?
Yes. It works well how it is, I just find it quite unusual not to use getopt(s). And mixing parameters with and without '-' as I did is bad.
Whole point of these changes is to make the script usable also for local development (sometimes one may want to run two builds, thats why it's good to allow overwrite prefix).
Maybe I should have used getopts short option with values, even I don't like short values:
./build.sh [ -t 32|cross|out ] [ -p PREFIX_DIR ] [ -c CC ]
I decided leave out-of-tree on it's own (native only). But it would be possible to have e.g. out-of-tree 32-bit compilation, but I don't see much advantages for it.
Kind regards,
Petr
RFC PATCH 3/3 build.sh: Allow to overwrite prefix
Hi!
Quoted 8 lines
Yes. It works well how it is, I just find it quite unusual not to use getopt(s). And mixing parameters with and without '-' as I did is bad.
Whole point of these changes is to make the script usable also for local development (sometimes one may want to run two builds, thats why it's good to allow overwrite prefix).Maybe I should have used getopts short option with values, even I don't like short values:
./build.sh [ -t 32|cross|out ] [ -p
PREFIX_DIR] [ -c CC ]
This does not seem that bad to me.
I would like to avoid passing half of the parameters via argv and half via env variables if possible.
Quoted 2 lines
I decided leave out-of-tree on it's own (native only). But it would be possible to have e.g. out-of-tree 32-bit compilation, but I don't see much advantages for it.
I think that as well, the out/in tree build is orthogonal problem to the compiler and it's unlikely that things would break.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 3/3 build.sh: Allow to overwrite prefix
Hi!
Quoted 8 lines
Quoted 3 lines
Maybe I should have used getopts short option with values, even I don't like short values:
./build.sh [ -t 32|cross|out ] [ -p
PREFIX_DIR] [ -c CC ]This does not seem that bad to me.
I would like to avoid passing half of the parameters via argv and half via env variables if possible.
Right. I rewrote the script and clean it a bit (see master). Everything now uses getopts (shell built-in).
IMHO script is now suitable for local development as well.
I also added that 2 ARM cross-compile builds.
Kind regards,
Petr