aboutsummaryrefslogtreecommitdiff
path: root/projects/ghostscript/build.sh
blob: b6f9a827fcd20504322ce1ce76f7aaaa6922e78e (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
60
61
62
63
64
#!/bin/bash -eu
# Copyright 2019 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

# Build CUPS
pushd cups
# Fix bad line
sed -i '2110s/\(\s\)f->value/\1(int)f->value/' cups/ppd-cache.c

LSB_BUILD=y ./configure --prefix="$WORK" --libdir="$OUT" --disable-gnutls \
   --disable-libusb --with-components=core

make clean
make install-headers install-libs
make -C filter libs install-libs
install -m755 cups-config "$WORK"/cups-config
popd

cd ghostpdl
rm -rf cups/libs || die
rm -rf freetype || die
rm -rf libpng || die
rm -rf tiff || die
rm -rf zlib || die

export CUPSCONFIG="$WORK/cups-config"
CUPS_CFLAGS=$($CUPSCONFIG --cflags)
CUPS_LDFLAGS=$($CUPSCONFIG --ldflags)
CUPS_LIBS=$($CUPSCONFIG --image --libs)
export CXXFLAGS="$CXXFLAGS $CUPS_CFLAGS"

./autogen.sh
CPPFLAGS="${CPPFLAGS:-} $CUPS_CFLAGS" ./configure \
  --enable-freetype --enable-fontconfig \
  --enable-cups --with-ijs --with-jbig2dec \
  --with-drivers=cups,ljet4,laserjet,pxlmono,pxlcolor,pcl3,uniprint
make -j$(nproc) libgs

$CXX $CXXFLAGS $CUPS_LDFLAGS -std=c++11 -I. \
    fuzz/gstoraster_fuzzer.cc \
    -o "$OUT/gstoraster_fuzzer" \
    -Wl,-rpath='$ORIGIN' \
    $CUPS_LIBS \
    $LIB_FUZZING_ENGINE bin/gs.a

mkdir -p "$WORK/seeds"
for f in examples/*.{ps,pdf}; do
  s=$(sha1sum "$f" | awk '{print $1}')
  cp "$f" "$WORK/seeds/$s"
done
zip -j "$OUT/gstoraster_fuzzer_seed_corpus.zip" "$WORK"/seeds/*