Blame autobuild/build.sh

c0f946
#!/usr/bin/env bash
8cebc4
#
8cebc4
# SynfigStudio build script
8cebc4
# Copyright (c) 2008-2018 Konstantin Dmitriev
8cebc4
#
8cebc4
# This package is free software; you can redistribute it and/or
8cebc4
# modify it under the terms of the GNU General Public License as
8cebc4
# published by the Free Software Foundation; either version 2 of
8cebc4
# the License, or (at your option) any later version.
8cebc4
#
8cebc4
# This package is distributed in the hope that it will be useful,
8cebc4
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8cebc4
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8cebc4
# General Public License for more details.
8cebc4
8cebc4
# = Usage: =
8cebc4
#    ./build.sh [package] [mode]
8cebc4
#
8cebc4
# where:
8cebc4
#   - [package] is all|etl|core|studio
8cebc4
#   - [mode] is full|clean|configure|make
8cebc4
#   
8cebc4
#
8cebc4
# = Examples: =
8cebc4
#
luz.paz 99f3ef
# == Standard mode ==
8cebc4
# Configure and (re)build:
8cebc4
#    ./build.sh
8cebc4
# Configure and make clean build:
8cebc4
#    ./build.sh all full
8cebc4
# Quick rebuild (without configure):
8cebc4
#    ./build.sh all make
luz.paz 99f3ef
# Quick rebuild of synfig-core (without configure):
8cebc4
#    ./build.sh core make
8cebc4
8cebc4
set -e
8cebc4
8cebc4
REPO_DIR=`dirname "$0"`
44d59a
pushd "${REPO_DIR}/.." > /dev/null
8cebc4
REPO_DIR=`pwd`
8cebc4
popd > /dev/null
8cebc4
8cebc4
RELEASE=8
8cebc4
if [ -z "$PREFIX" ]; then
8cebc4
#PREFIX=$HOME/synfig
8cebc4
PREFIX=`pwd`/build
8cebc4
fi
8cebc4
8cebc4
MAKE_THREADS=2					#count of threads for make
8cebc4
8cebc4
# Allow overriding PREFIX and other settings
8cebc4
if [ -f "./build.conf" ] ; then
8cebc4
	. "./build.conf"
8cebc4
fi
8cebc4
8cebc4
if [ -z $DEBUG ]; then
8cebc4
	export DEBUG=0
8cebc4
fi
8cebc4
8cebc4
if [[ $DEBUG == 1 ]]; then
8cebc4
	DEBUG='--enable-debug --enable-optimization=0'
8cebc4
else
8cebc4
	DEBUG=''
8cebc4
fi
8cebc4
5ac3ae
mkdir -p ETL
5ac3ae
mkdir -p synfig-core
5ac3ae
mkdir -p synfig-studio
5ac3ae
mkdir -p "${PREFIX}/bin"
8cebc4
7dbe2c
#========================== VARIABLES ==================================
7dbe2c
7dbe2c
if [[ `uname` == "Linux" ]]; then
44d59a
	export PKG_CONFIG_PATH="${PREFIX}/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/`uname -i`-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}"
7dbe2c
fi
c46c13
if [[ `uname -o` == "Msys" ]]; then
c46c13
	PATH="${PREFIX}/lib/ccache/bin:${PATH}"
c46c13
	# copy MLT
c46c13
	MLT_REV=1   # Change this when something is changed inside of if block below
44d59a
	if [ ! -f "${PREFIX}/mlt-${VERSION_MLT}-${MLT_REV}.done" ]; then
c46c13
		VERSION_MLT="6.16.0"
44d59a
		cp -rf /opt/mlt-${VERSION_MLT}/*.dll "${PREFIX}/bin/"
44d59a
		cp -rf /opt/mlt-${VERSION_MLT}/*.exe "${PREFIX}/bin/"
44d59a
		cp -rf /opt/mlt-${VERSION_MLT}/share "${PREFIX}/bin/"
44d59a
		mkdir -p "${PREFIX}/bin/lib/"
44d59a
		cp -rf /opt/mlt-${VERSION_MLT}/lib/mlt "${PREFIX}/bin/lib/"
44d59a
		touch "${PREFIX}/mlt-${VERSION_MLT}-${MLT_REV}.done"
c46c13
	fi
c46c13
	export PKG_CONFIG_PATH="/opt/mlt-${VERSION_MLT}/lib/pkgconfig:${PKG_CONFIG_PATH}"
c46c13
fi
7dbe2c
if [[ `uname` == "Darwin" ]]; then
7dbe2c
	# autopoint is not in PATH after install via brew (conflicting with system gettext https://github.com/Homebrew/legacy-homebrew/issues/24070)
7dbe2c
	# so we can do `brew link --force gettext` or just add it to PATH before configuring which is preferable because we need it only for compiling
7dbe2c
	export PATH="/usr/local/opt/ccache/libexec:/usr/local/opt/gettext/bin:${PATH}"
3c6820
	export LDFLAGS="-L/usr/local/opt/gettext/lib ${LDFLAGS}"
5b767d
	export LDFLAGS="-L$(brew --prefix libomp)/lib ${LDFLAGS}"
d8e465
	export LDFLAGS="-L$(brew --prefix libtool)/lib ${LDFLAGS}"
fd00fd
	export CPPFLAGS="-I/usr/local/opt/gettext/include ${CPPFLAGS}"
4738a9
	export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig:${PKG_CONFIG_PATH}"
03c5b9
03c5b9
	# Force use system perl, see https://github.com/synfig/synfig/issues/794
44d59a
	cat > "${PREFIX}/bin/perl" <
03c5b9
#!/bin/sh
03c5b9
03c5b9
/usr/bin/perl "\$@"
03c5b9
EOF
44d59a
	chmod +x "${PREFIX}/bin/perl"
03c5b9
7dbe2c
fi
44d59a
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
44d59a
export PATH="${PREFIX}/bin:$PATH"
44d59a
export LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
fd00fd
export LDFLAGS="-Wl,-rpath -Wl,\\\$\$ORIGIN/lib ${LDFLAGS}"
7dbe2c
export CFLAGS="-fdiagnostics-color=always $CFLAGS"
7dbe2c
export CXXFLAGS="-fdiagnostics-color=always $CXXFLAGS"
7dbe2c
7dbe2c
#========================== FUNCTIONS ==================================
7dbe2c
7dbe2c
travis_fold_start()
7dbe2c
{
7dbe2c
	if [ -n "$TRAVIS" ]; then
7dbe2c
		echo -e "travis_fold:start:$1\033[33;1m$2\033[0m"
7dbe2c
	fi
7dbe2c
}
7dbe2c
7dbe2c
travis_fold_end()
7dbe2c
{
7dbe2c
	if [ -n "$TRAVIS" ]; then
7dbe2c
		echo -e "\ntravis_fold:end:$1\r"
7dbe2c
	fi
7dbe2c
}
8cebc4
c46c13
ccache_show_stats()
c46c13
{
c46c13
	if ( which ccache > /dev/null ); then
c46c13
	ccache -s
c46c13
	fi
c46c13
}
c46c13
8cebc4
#============================== ETL ====================================
8cebc4
8cebc4
etl_clean() {
8cebc4
cd ETL
8cebc4
echo "Cleaning source tree..."
8cebc4
make clean || true
8cebc4
cd ..
8cebc4
}
8cebc4
8cebc4
etl_configure()
8cebc4
{
8cebc4
cd ETL
8cebc4
echo "Going to configure..."
44d59a
pushd "${REPO_DIR}/ETL/" >/dev/null
44d59a
/bin/bash "${REPO_DIR}/ETL/bootstrap.sh"
8cebc4
popd
44d59a
/bin/bash "${REPO_DIR}/ETL/configure" --prefix="${PREFIX}" --includedir="${PREFIX}/include" $DEBUG
8cebc4
cd ..
8cebc4
}
8cebc4
8cebc4
etl_make()
8cebc4
{
8cebc4
cd ETL
8cebc4
make -j$MAKE_THREADS
7dbe2c
sed -i.bak "s|^Cflags: -I\\\${includedir}|Cflags: -I$REPO_DIR\/ETL -I\\\${includedir}|" ETL.pc
8cebc4
make install
8cebc4
cd ..
c46c13
c46c13
ccache_show_stats
c46c13
8cebc4
}
8cebc4
8cebc4
etl_build()
8cebc4
{
8cebc4
etl_configure
8cebc4
etl_make
8cebc4
}
8cebc4
8cebc4
etl_full()
8cebc4
{
8cebc4
etl_clean
8cebc4
etl_configure
8cebc4
etl_make
8cebc4
}
8cebc4
8cebc4
#======================== Synfig-Core ==================================
8cebc4
8cebc4
core_clean()
8cebc4
{
8cebc4
cd synfig-core
8cebc4
echo "Cleaning source tree..."
8cebc4
make clean || true
8cebc4
cd ..
8cebc4
}
8cebc4
8cebc4
core_configure()
8cebc4
{
8cebc4
cd synfig-core
44d59a
pushd "${REPO_DIR}/synfig-core/" >/dev/null
44d59a
/bin/bash "${REPO_DIR}/synfig-core/bootstrap.sh"
8cebc4
popd >/dev/null
8cebc4
if [ -e /etc/debian_version ] && [ -z "$BOOST_CONFIGURE_OPTIONS" ]; then
8cebc4
	# Debian/Ubuntu multiarch
8cebc4
	MULTIARCH_LIBDIR="/usr/lib/`uname -m`-linux-gnu/"
8cebc4
	if [ -e "${MULTIARCH_LIBDIR}/libboost_program_options.so" ]; then
8cebc4
		export BOOST_CONFIGURE_OPTIONS="--with-boost-libdir=$MULTIARCH_LIBDIR"
8cebc4
	fi
8cebc4
fi
44d59a
/bin/bash "${REPO_DIR}/synfig-core/configure" --prefix="${PREFIX}" \
44d59a
	--includedir="${PREFIX}/include" \
8cebc4
	--disable-static --enable-shared \
8cebc4
	--with-magickpp \
lenixlobo 66bf67
	--without-libavcodec \
8cebc4
	--without-included-ltdl \
8cebc4
	$BOOST_CONFIGURE_OPTIONS \
8cebc4
	$DEBUG
8cebc4
cd ..
8cebc4
}
8cebc4
8cebc4
core_make()
8cebc4
{
8cebc4
cd synfig-core
8cebc4
make -j$MAKE_THREADS
7dbe2c
sed -i.bak "s|^includedir=.*$|includedir=$REPO_DIR\/synfig-core\/src|" synfig.pc
8cebc4
make install
8cebc4
cd ..
c46c13
c46c13
ccache_show_stats
c46c13
8cebc4
}
8cebc4
8cebc4
core_build()
8cebc4
{
8cebc4
core_configure
8cebc4
core_make
8cebc4
}
8cebc4
8cebc4
core_full()
8cebc4
{
8cebc4
core_clean
8cebc4
core_configure
8cebc4
core_make
8cebc4
}
8cebc4
8cebc4
#======================== Synfig-Studio ==================================
8cebc4
8cebc4
studio_clean()
8cebc4
{
8cebc4
cd synfig-studio
8cebc4
echo "Cleaning source tree..."
8cebc4
make clean || true
8cebc4
cd ..
8cebc4
}
8cebc4
8cebc4
studio_configure()
8cebc4
{
8cebc4
cd synfig-studio
44d59a
pushd "${REPO_DIR}/synfig-studio/" >/dev/null
44d59a
/bin/bash "${REPO_DIR}/synfig-studio/bootstrap.sh"
8cebc4
popd >/dev/null
7dbe2c
if [[ `uname` == "Linux" ]]; then
7dbe2c
	export CONFIGURE_OPTIONS="--enable-jack"
c46c13
elif [[ `uname -o` == "Msys" ]]; then
c46c13
	# currently where is a bug in synfig-core (in MinGW build) which causes 
c46c13
	# synfig-core to halt before exit, so we skip image generation
c46c13
	export CONFIGURE_OPTIONS="--without-images"
7dbe2c
else
7dbe2c
	export CONFIGURE_OPTIONS=""
7dbe2c
fi
7dbe2c
44d59a
/bin/bash "${REPO_DIR}/synfig-studio/configure" --prefix="${PREFIX}" \
44d59a
	--includedir="${PREFIX}/include" \
8cebc4
	--disable-static \
8cebc4
	--enable-shared \
7dbe2c
	${CONFIGURE_OPTIONS} \
8cebc4
	--enable-warnings=max $DEBUG
8cebc4
cd ..
8cebc4
}
8cebc4
8cebc4
studio_make()
8cebc4
{
8cebc4
cd synfig-studio
c46c13
8cebc4
make -j$MAKE_THREADS
8cebc4
make install
c46c13
c46c13
ccache_show_stats
c46c13
8cebc4
for n in AUTHORS COPYING NEWS README
8cebc4
do
44d59a
  	cp -f "${REPO_DIR}/synfig-studio/$n" "${PREFIX}"
8cebc4
done
917586
917586
if [ ! -z "$NIX_BUILD_CORES" ]; then
604ba3
	source "`head -n 1 ${MAKE_WRAPPER_PATH}/nix-support/propagated-build-inputs | sed -e 's/[[:space:]]*$//'`/nix-support/setup-hook"
604ba3
	source "${MAKE_WRAPPER_PATH}/nix-support/setup-hook"
5e783e
	wrapProgram "${PREFIX}/bin/synfigstudio" \
917586
		  --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
917586
		  --prefix XCURSOR_PATH : "$ADWAITA_PATH/share/icons" \
917586
		  --set XCURSOR_THEME "Adwaita"
917586
fi
917586
8cebc4
cd ..
34ed8c
msg_done
8cebc4
}
8cebc4
8cebc4
studio_build()
8cebc4
{
8cebc4
studio_configure
8cebc4
studio_make
8cebc4
}
8cebc4
8cebc4
studio_full()
8cebc4
{
8cebc4
studio_clean
8cebc4
studio_configure
8cebc4
studio_make
8cebc4
}
8cebc4
8cebc4
#=============================== ALL ===================================
8cebc4
8cebc4
all_clean()
8cebc4
{
8cebc4
etl_clean
8cebc4
core_clean
8cebc4
studio_clean
8cebc4
}
8cebc4
8cebc4
all_configure()
8cebc4
{
8cebc4
etl_configure
8cebc4
core_configure
8cebc4
studio_configure
8cebc4
}
8cebc4
8cebc4
all_make()
8cebc4
{
8cebc4
etl_make
8cebc4
core_make
8cebc4
studio_make
8cebc4
}
8cebc4
8cebc4
all_build()
8cebc4
{
7dbe2c
travis_fold_start ETL "Building ETL"
8cebc4
etl_build
7dbe2c
travis_fold_end ETL
7dbe2c
7dbe2c
travis_fold_start synfig-core "Building Synfig Core"
8cebc4
core_build
7dbe2c
travis_fold_end synfig-core
7dbe2c
7dbe2c
travis_fold_start synfig-studio "Building Synfig Studio"
8cebc4
studio_build
7dbe2c
travis_fold_end synfig-studio
8cebc4
}
8cebc4
8cebc4
all_full()
8cebc4
{
8cebc4
etl_full
8cebc4
core_full
8cebc4
studio_full
8cebc4
}
8cebc4
8cebc4
msg_done()
8cebc4
{
8cebc4
echo
8cebc4
echo
8cebc4
echo "Done. Please check your Synfig installation in"
8cebc4
echo " ${PREFIX}"
8cebc4
echo
8cebc4
echo "You can start Synfig by executing"
8cebc4
echo " ${PREFIX}/bin/synfigstudio"
8cebc4
echo
8cebc4
}
8cebc4
8cebc4
#============================== MAIN ===================================
8cebc4
8cebc4
if [ -z $1 ]; then
8cebc4
	ARG1='all'
8cebc4
else
8cebc4
	ARG1=$1
8cebc4
fi
8cebc4
8cebc4
if [ -z $2 ]; then
8cebc4
	ARG2='build'
8cebc4
else
8cebc4
	ARG2=$2
8cebc4
fi
8cebc4
8cebc4
# executing command
8cebc4
${ARG1}_${ARG2}