diff --git a/binding.gyp b/binding.gyp index 1c25248..66f0115 100755 --- a/binding.gyp +++ b/binding.gyp @@ -12,9 +12,8 @@ 'variables': { 'with_jpeg%': ' /dev/null - -if test $? -eq 0; then - echo true -else - echo false -fi diff --git a/util/has_lib.sh b/util/has_lib.sh index 6419e24..31ef129 100755 --- a/util/has_lib.sh +++ b/util/has_lib.sh @@ -1,5 +1,10 @@ -#!/usr/bin/env sh -has_lib() { +#!/bin/bash + +has_ldconfig() { + hash ldconfig 2>/dev/null +} + +has_system_lib() { local regex="lib$1.+(so|dylib)" # Add /sbin to path as ldconfig is located there on some systems - e.g. Debian @@ -7,21 +12,52 @@ has_lib() { PATH="$PATH:/sbin" export PATH # Try using ldconfig on linux systems - for LINE in `which ldconfig > /dev/null && ldconfig -p 2>/dev/null | grep -E $regex`; do - return 0 - done + if $(has_ldconfig); then + for _ in $(ldconfig -p 2>/dev/null | grep -E "$regex"); do + return 0 + done + fi # Try just checking common library locations for dir in /lib /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu; do - test -d $dir && ls $dir | grep -E $regex && return 0 + test -d $dir && ls $dir | grep -E "$regex" && return 0 done return 1 } -has_lib $1 > /dev/null -if test $? -eq 0; then - echo true +has_freetype() { + pkg-config cairo --cflags-only-I | grep freetype2 +} + +has_pkgconfig_lib() { + pkg-config --exists "$1" +} + +case "$1" in + gif) + has_system_lib "gif" > /dev/null + result=$? + ;; + jpeg) + has_system_lib "jpeg" > /dev/null + result=$? + ;; + pango) + has_pkgconfig_lib "pango" > /dev/null + result=$? + ;; + freetype) + has_freetype > /dev/null + result=$? + ;; + *) + >&2 echo "Unknown library: $1" + exit 1 +esac + +if test $result -eq 0; then + echo "true" else - echo false + echo "false" fi diff --git a/util/lib_lookup.sh b/util/lib_lookup.sh deleted file mode 100755 index 13c4f9c..0000000 --- a/util/lib_lookup.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -# Make pkg-config lookup include files from the build directory. -export PKG_CONFIG_PATH=$(cd "$(dirname "$0")"; pwd)/../build_cairo/lib/pkgconfig; - -pkg-config $1 --libs \ No newline at end of file