summaryrefslogtreecommitdiffstats
path: root/packaging/macos/210-inkscape-build.sh
blob: 5f6f61e47384c36f4e7824ae6b2263060290c391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This file is part of the build pipeline for Inkscape on macOS.
#
# ### 210-inkscape-build.sh ###
# Build Inscape.

### load settings and functions ################################################

SELF_DIR=$(F=$0; while [ ! -z $(readlink $F) ] && F=$(readlink $F); cd $(dirname $F); F=$(basename $F); [ -L $F ]; do :; done; echo $(pwd -P))
for script in $SELF_DIR/0??-*.sh; do source $script; done

set -e -o errtrace
trap 'catch_error "$SELF_NAME" "$LINENO" "$FUNCNAME" "${BASH_COMMAND}" "${?}"' ERR

### build Inkscape #############################################################

if [ -z $CI_JOB_ID ]; then   # running standalone
  git clone --recurse-submodules --depth 10 $URL_INKSCAPE $INK_DIR
fi

[ -d $INK_DIR.build ] && rm -rf $INK_DIR.build || true  # cleanup previous run

mkdir -p $INK_DIR.build
cd $INK_DIR.build

# about the '-DOpenMP_*' arguments:
# All the settings for OpenMP are to trigger the detection during 'cmake'.
# Experimenting with a "Hello World"-style example shows that linking with
# '-lomp' would suffice, no '-fopenmp' required.
# TODO further investigation into required flags

cmake \
  -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  -DCMAKE_PREFIX_PATH=$OPT_DIR \
  -DCMAKE_INSTALL_PREFIX=$OPT_DIR \
  -DOpenMP_CXX_FLAGS="-Xclang -fopenmp" \
  -DOpenMP_C_FLAGS="-Xclang -fopenmp" \
  -DOpenMP_CXX_LIB_NAMES="omp" \
  -DOpenMP_C_LIB_NAMES="omp" \
  -DOpenMP_omp_LIBRARY=$LIB_DIR/libomp.dylib \
  $INK_DIR

make
make install
make tests

### patch Poppler library locations ############################################

relocate_dependency $LIB_DIR/libpoppler.94.dylib $BIN_DIR/inkscape
relocate_dependency $LIB_DIR/libpoppler-glib.8.dylib $BIN_DIR/inkscape
relocate_dependency $LIB_DIR/libpoppler.94.dylib $LIB_DIR/inkscape/libinkscape_base.dylib
relocate_dependency $LIB_DIR/libpoppler-glib.8.dylib $LIB_DIR/inkscape/libinkscape_base.dylib

### patch OpenMP library locations #############################################

relocate_dependency $LIB_DIR/libomp.dylib $BIN_DIR/inkscape
relocate_dependency $LIB_DIR/libomp.dylib $LIB_DIR/inkscape/libinkscape_base.dylib