finalcut/build.sh

149 lines
4.3 KiB
Bash
Raw Normal View History

2015-05-23 13:35:12 +02:00
#!/bin/sh
2015-10-04 19:01:34 +02:00
#CXX="clang++"
2015-08-22 18:53:52 +02:00
PREFIX="/usr"
2017-11-11 14:52:33 +01:00
RED="\\033[0;31m"
GREEN="\\033[0;32m"
NORMAL="\\033[m"
2015-08-10 00:56:32 +02:00
2018-09-22 01:11:05 +02:00
SRCDIR="$(dirname "$0")"
test -n "$SRCDIR" || SRCDIR=.
cd "$SRCDIR" || exit
# Get number of logical processor cores
if command -v getconf >/dev/null 2>&1
then
CPU_COUNT="$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null)" || CPU_COUNT="0"
fi
if [ "$CPU_COUNT" -eq 0 ]
then
if command -v nproc >/dev/null 2>&1
then
CPU_COUNT="$(nproc 2>/dev/null)" || CPU_COUNT="0"
fi
fi
test "$CPU_COUNT" -eq 0 && CPU_COUNT=1
2018-09-22 01:11:05 +02:00
if [ -n "$1" ]
then
2018-09-30 20:08:12 +02:00
if [ ! -f ./configure ]
then
if command -v autoreconf >/dev/null
2018-09-30 20:08:12 +02:00
then
autoreconf --install --force
else
echo "Build failed, please install autoconf first"
exit 255
2018-09-30 20:08:12 +02:00
fi
fi
2018-09-22 01:11:05 +02:00
fi
# Build commands
2015-05-23 13:35:12 +02:00
case "$1" in
2017-02-06 02:21:40 +01:00
"--release"|"release")
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-flto -fno-rtti"
2017-11-11 14:52:33 +01:00
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2017-11-11 14:52:33 +01:00
fi
2017-02-06 02:21:40 +01:00
;;
2015-05-23 13:35:12 +02:00
"--debug"|"debug")
2017-11-11 14:52:33 +01:00
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic"
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2017-11-11 14:52:33 +01:00
fi
2015-05-23 13:35:12 +02:00
;;
2017-01-22 23:04:40 +01:00
"--fulldebug"|"fulldebug")
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args -Wno-format-nonliteral"
2017-11-11 14:52:33 +01:00
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2017-11-11 14:52:33 +01:00
fi
2015-09-22 04:18:20 +02:00
;;
2015-05-23 13:35:12 +02:00
"--profile"|"profile")
2017-11-11 14:52:33 +01:00
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic"
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2017-11-11 14:52:33 +01:00
fi
2015-05-23 13:35:12 +02:00
;;
2015-10-15 02:37:02 +02:00
"--cpu-profiler"|"cpu-profiler")
2017-11-11 14:52:33 +01:00
if ! ./configure --prefix="$PREFIX" --with-profiler
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2017-11-11 14:52:33 +01:00
fi
2015-10-15 02:37:02 +02:00
;;
2018-02-25 21:42:18 +01:00
"--unit-test"|"unit-test")
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
2018-02-25 21:42:18 +01:00
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2018-02-25 21:42:18 +01:00
fi
;;
2017-11-11 14:52:33 +01:00
"--coverage"|"coverage")
2019-07-14 23:21:49 +02:00
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test --with-gcov
2017-11-11 14:52:33 +01:00
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255
2017-11-11 14:52:33 +01:00
fi
2015-08-10 21:50:27 +02:00
;;
"--help"|"help"|*)
echo "Usage:"
echo " $(basename "$0") {COMMAND}"
echo ""
echo "Commands:"
2017-02-06 02:21:40 +01:00
echo " release Compile for release"
echo " debug Compile with debug option"
echo " fulldebug Compile with all warning options"
echo " profile Compile with profile option (analysis with gprof)"
2018-02-25 21:42:18 +01:00
echo " unit-test Compile with CppUnit testing"
2015-10-15 02:37:02 +02:00
echo " cpu-profiler Link with Google cpu performance profiler"
2017-11-11 14:52:33 +01:00
echo " coverage Compile with options for coverage analysis with gcov"
2017-02-06 02:21:40 +01:00
echo " help Show this help"
2017-11-11 14:52:33 +01:00
exit
;;
2015-05-23 13:35:12 +02:00
esac
JOBS="$((CPU_COUNT/2))"
test "$JOBS" -eq 0 && JOBS=1
2017-11-11 14:52:33 +01:00
if make -h 2<&1 | grep -q "\\-\\-jobs"
then
MAKE="make V=1 -j$JOBS"
else
MAKE="make V=1"
fi
if $MAKE
2017-11-11 14:52:33 +01:00
then
printf '%bSuccessful compiled%b\n' "${GREEN}" "${NORMAL}"
2017-11-11 14:52:33 +01:00
else
printf '%bError on compile!%b\n' "${RED}" "${NORMAL}" 1>&2
2017-11-11 14:52:33 +01:00
exit 1
fi
2018-02-25 22:04:36 +01:00
if [ "$1" = "--unit-test" ] \
2018-02-25 22:48:18 +01:00
|| [ "$1" = "unit-test" ] \
|| [ "$1" = "--coverage" ] \
|| [ "$1" = "coverage" ]
2018-02-25 21:42:18 +01:00
then
2019-07-04 15:26:26 +02:00
rm test/*.log 2>/dev/null
2018-09-21 07:06:18 +02:00
cd test && make check-TESTS
2018-09-22 01:11:05 +02:00
cat ./*.log 2>/dev/null
cd .. || exit
2018-02-25 21:42:18 +01:00
fi
2015-05-23 13:35:12 +02:00
# make install