• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2018 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# libz
19pushd $SRC/zlib
20./configure --static --prefix="$WORK"
21make -j$(nproc) all
22make install
23popd
24
25# libzstd
26pushd $SRC/zstd
27make -j$(nproc) install PREFIX="$WORK"
28popd
29
30# libjbig
31pushd "$SRC/jbigkit"
32make clean
33make -j$(nproc) lib
34cp "$SRC"/jbigkit/libjbig/*.a "$WORK/lib/"
35cp "$SRC"/jbigkit/libjbig/*.h "$WORK/include/"
36popd
37
38# libjpeg-turbo
39pushd $SRC/libjpeg-turbo
40cmake . -DCMAKE_INSTALL_PREFIX="$WORK" -DENABLE_STATIC:bool=on
41make -j$(nproc)
42make install
43popd
44
45# libpng
46pushd $SRC/libpng
47cat scripts/pnglibconf.dfa | \
48  sed -e "s/option WARNING /option WARNING disabled/" \
49> scripts/pnglibconf.dfa.temp
50mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa
51autoreconf -f -i
52./configure \
53  --prefix="$WORK" \
54  --disable-shared \
55  --enable-static \
56  LDFLAGS="-L$WORK/lib" \
57  CPPFLAGS="-I$WORK/include"
58make -j$(nproc)
59make install
60popd
61
62# libwebp
63pushd $SRC/libwebp
64export WEBP_CFLAGS="$CFLAGS -DWEBP_MAX_IMAGE_SIZE=838860800" # 800MiB
65./autogen.sh
66./configure \
67  --enable-libwebpdemux \
68  --enable-libwebpmux \
69  --disable-shared \
70  --disable-jpeg \
71  --disable-tiff \
72  --disable-gif \
73  --disable-wic \
74  --disable-threading \
75  --prefix="$WORK" \
76  CFLAGS="$WEBP_CFLAGS"
77make clean
78make -j$(nproc)
79make install
80popd
81
82# libtiff
83pushd "$SRC/libtiff"
84cmake . -DCMAKE_INSTALL_PREFIX="$WORK" -DBUILD_SHARED_LIBS=off
85make clean
86make -j$(nproc)
87make install
88popd
89
90# leptonica
91export LEPTONICA_LIBS="$WORK/lib/libjbig.a $WORK/lib/libzstd.a $WORK/lib/libwebp.a $WORK/lib/libpng.a"
92./autogen.sh
93./configure \
94  --enable-static \
95  --disable-shared \
96  --with-libpng \
97  --with-zlib \
98  --with-jpeg \
99  --with-libwebp \
100  --with-libtiff \
101  --prefix="$WORK" \
102  LIBS="$LEPTONICA_LIBS" \
103  LDFLAGS="-L$WORK/lib" \
104  CPPFLAGS="-I$WORK/include"
105make -j$(nproc)
106make install
107
108$CXX $CXXFLAGS -std=c++11 -I"$WORK/include" \
109  "$SRC/pix_rotate_shear_fuzzer.cc" -o "$OUT/pix_rotate_shear_fuzzer" \
110  "$WORK/lib/liblept.a" \
111  "$WORK/lib/libtiff.a" \
112  "$WORK/lib/libwebp.a" \
113  "$WORK/lib/libpng.a" \
114  "$WORK/lib/libjpeg.a" \
115  "$WORK/lib/libjbig.a" \
116  "$WORK/lib/libzstd.a" \
117  "$WORK/lib/libz.a" \
118  $LIB_FUZZING_ENGINE
119
120