Skip to content

Commit

Permalink
Merge pull request #47 from wally4000/master
Browse files Browse the repository at this point in the history
Rework Dependancy Script
  • Loading branch information
wally4000 committed Jul 24, 2023
2 parents da66727 + 0de0d42 commit b0ef1ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
run: |
dnf -y install @development-tools gcc gcc-c++ g++ wget git autoconf automake python3 python3-pip make cmake pkgconf \
libarchive-devel openssl-devel gpgme-devel libtool gettext texinfo bison flex gmp-devel mpfr-devel libmpc-devel ncurses-devel diffutils \
libusb-compat-0.1-devel readline-devel libcurl-devel
libusb-compat-0.1-devel readline-devel libcurl-devel which
- name: Runs full build in shell
run: |
Expand Down
90 changes: 28 additions & 62 deletions depends/check-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,84 +1,50 @@
#!/bin/bash

header_paths=(
"/usr/include" \
"/usr/local/include" \
"/usr/local/opt/" \
"/opt/include" \
"/opt/local/include" \
"/usr/include/$(uname -m)-linux-gnu" \
"/usr/local/include/$(uname -m)-linux-gnu" \
"/usr/include/i386-linux-gnu" \
"/usr/local/include/i386-linux-gnu" \
"/mingw32/include/"
# -- Add more locations here --
)

missing_depends=()

function check_header
{
for place in ${header_paths[@]}; do
for name in ${@:2}; do
[ -f "$place/$name" ] && return 0
done
done

missing_depends+=($1); return 1
}

function check_header_nosys
function check_library
{
for place in ${header_paths[@]}; do
if [ "${place:0:12}" != "/usr/include" ]; then
for name in ${@:2}; do
[ -f "$place/$name" ] && return 0
done
fi
done

missing_depends+=($1); return 1
pkg-config --exists "$1"
if [ $? -eq 0 ]; then
return 0
else
missing_depends+=($1); return 1
fi
}

function check_program
{
binary=${2:-$1}
for place in ${PATH//:/ }; do
[ -x "$place/$binary" ] || [ -x "$place/$binary.exe" ] && return 0
done

missing_depends+=($1); return 1
which "$1" >/dev/null 2>&1
if [ $? -eq 0 ]; then
return 0
else
missing_depends+=($1); return 1
fi
}

OSVER=$(uname)

# macOS catalina does not ship headers in default directory anymore
if [ "$(uname)" == "Darwin" ]; then
header_paths+=("`xcrun --show-sdk-path`/usr/include")
fi

check_program which
check_program git
check_program patch
check_program autoconf
check_program automake

# Disabled pacman for windows
if [ "${OSVER:0:5}" != MINGW ]; then
check_program python3
check_program pip3
check_program gpgme-config
check_header openssl openssl/crypto.h openssl/include/openssl/crypto.h
check_header libarchive archive.h libarchive/include/archive.h
fi

check_program make
check_program cmake
check_program gcc
check_program g++

check_program bison
check_program flex
check_program libtoolize
check_program python3
check_program pip3
check_program gpgme-tool

# macOS uses it's own fork of libtool
if [ "$(uname)" != "Darwin" ]; then
check_program libtoolize
else
check_program glibtoolize
fi

check_library libarchive
check_library openssl
check_library ncurses

if [ ${#missing_depends[@]} -ne 0 ]; then
echo "Couldn't find dependencies:"
Expand Down

0 comments on commit b0ef1ab

Please sign in to comment.