build.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash -eu
  2. # Copyright 2017-2018 Glenn Randers-Pehrson
  3. # Copyright 2016 Google Inc.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Last changed in libpng 1.6.35 [July 15, 2018]
  18. #
  19. # Revisions by Glenn Randers-Pehrson, 2017:
  20. # 1. Build only the library, not the tools (changed "make -j$(nproc) all" to
  21. # "make -j$(nproc) libpng16.la").
  22. # 2. Disabled WARNING and WRITE options in pnglibconf.dfa.
  23. # 3. Build zlib alongside libpng
  24. ################################################################################
  25. # Disable logging via library build configuration control.
  26. cat scripts/pnglibconf.dfa | \
  27. sed -e "s/option STDIO/option STDIO disabled/" \
  28. -e "s/option WARNING /option WARNING disabled/" \
  29. -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \
  30. > scripts/pnglibconf.dfa.temp
  31. mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa
  32. # build the libpng library.
  33. autoreconf -f -i
  34. ./configure --with-libpng-prefix=OSS_FUZZ_
  35. make -j$(nproc) clean
  36. make -j$(nproc) libpng16.la
  37. # build libpng_read_fuzzer.
  38. $CXX $CXXFLAGS -std=c++11 -I. \
  39. $SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \
  40. -o $OUT/libpng_read_fuzzer \
  41. -lFuzzingEngine .libs/libpng16.a -lz
  42. # add seed corpus.
  43. find $SRC/libpng -name "*.png" | grep -v crashers | \
  44. xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip
  45. cp $SRC/libpng/contrib/oss-fuzz/*.dict \
  46. $SRC/libpng/contrib/oss-fuzz/*.options $OUT/