From 1cca6143f530f261227f65b0ddbc1255a810f950 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 20 Jan 2019 16:04:32 -0500 Subject: [PATCH] Add new module to check if a library is installed. This is very suboptimal compared to using pkg-config, but there are still some libraries which don't install pkg-config files. --- chocpkg/modules.sh | 4 ++++ chocpkg/modules/check_library.sh | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 chocpkg/modules/check_library.sh diff --git a/chocpkg/modules.sh b/chocpkg/modules.sh index acb0ad5..1283c05 100644 --- a/chocpkg/modules.sh +++ b/chocpkg/modules.sh @@ -21,6 +21,10 @@ check_pkgconfig() { install_module check_pkgconfig "$@" } +check_library() { + install_module check_library "$@" +} + check_tool() { install_module check_tool "$@" } diff --git a/chocpkg/modules/check_library.sh b/chocpkg/modules/check_library.sh new file mode 100644 index 0000000..91b8338 --- /dev/null +++ b/chocpkg/modules/check_library.sh @@ -0,0 +1,14 @@ + +check_library::init() { + PACKAGE_INSTALLED_LIB=$1 +} + +# Function that returns true if a specified C library is installed. +do_check() { + # TODO: A better way to choose compiler command? + ${CC:-gcc} \ + -l$PACKAGE_INSTALLED_LIB $LDFLAGS \ + -o/dev/null \ + -x c <( echo "int main() {}") +} +