forked from newsboat/newsboat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
executable file
·116 lines (106 loc) · 3.04 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
FAILSTATUS=""
PKG_CONFIG=${PKG_CONFIG:-pkg-config}
check_pkg() {
pkgname=$1
add_define=$2
atleast_version=$3
printf "Checking for package ${pkgname}... "
if $PKG_CONFIG --silence-errors "${pkgname}" ; then
echo "found"
if [ -n "$atleast_version" ] ; then
if ! $PKG_CONFIG --atleast-version=$atleast_version ${pkgname} ; then
echo "at least ${pkgname} $atleast_version required."
return 1
fi
fi
echo "# configuration for package ${pkgname}" >> config.mk
result=`$PKG_CONFIG --cflags ${pkgname}`
if [ -n "$result" ] ; then
echo "DEFINES+=$result" >> config.mk
fi
if [ -n "$add_define" ] ; then
echo "DEFINES+=${add_define}" >> config.mk
fi
echo "LDFLAGS+=`$PKG_CONFIG --libs ${pkgname}`" >> config.mk
echo "" >> config.mk
else
echo "not found"
return 1
fi
return 0
}
check_custom() {
pkgname=$1
customconfig=$2
add_define=$3
printf "Checking for package ${pkgname} using ${customconfig}... "
if ${customconfig} --cflags > /dev/null 2>&1 ; then
echo "found"
echo "# configuration for package ${pkgname}" >> config.mk
result=`${customconfig} --cflags`
if [ -n "$result" ] ; then
echo "DEFINES+=${result}" >> config.mk
fi
if [ -n "$add_define" ] ; then
echo "DEFINES+=${add_define}" >> config.mk
fi
echo "LDFLAGS+=`${customconfig} --libs`" >> config.mk
echo "" >> config.mk
else
echo "not found"
return 1
fi
return 0
}
fail() {
pkgname=$1
rm -f config.mk
dlurl=`grep -i "$pkgname" README.md | awk '{ print $NF }'`
echo ""
echo "You need package ${pkgname} in order to compile this program."
echo "Please make sure it is installed."
echo ""
echo "You can download ${pkgname} from here: ${dlurl}"
FAILSTATUS="1"
}
fail_custom() {
err=$1
echo ""
echo "ERROR: ${err}"
FAILSTATUS="1"
}
all_aboard_the_fail_boat() {
if [ "x$FAILSTATUS" != "x" ] ; then
rm -f config.mk
echo ""
echo "One or more dependencies couldn't be found. Please install"
echo "these packages and retry compilation."
exit 1
fi
}
check_ssl_implementation() {
if curl-config --static-libs | egrep -- "-lssl( |^)" > /dev/null 2>&1 ; then
check_pkg "libcrypto" || fail "libcrypto"
echo "DEFINES+=-DHAVE_OPENSSL=1" >> config.mk
elif curl-config --static-libs | grep -- -lgcrypt > /dev/null 2>&1 ; then
check_pkg "gnutls" || fail "gnutls"
check_custom "libgcrypt" "libgcrypt-config" || fail "libgcrypt"
echo "DEFINES+=-DHAVE_GCRYPT=1" >> config.mk
fi
}
echo "" > config.mk
check_pkg "sqlite3" || fail "sqlite3"
check_pkg "libcurl" || check_custom "libcurl" "curl-config" || fail "libcurl"
check_pkg "libxml-2.0" || check_custom "libxml2" "xml2-config" || fail "libxml2"
check_pkg "stfl" || fail "stfl"
( check_pkg "json" "" 0.11 || check_pkg "json-c" "" 0.11 ) || fail "json-c"
if [ `uname -s` = "Darwin" ]; then
check_custom "ncurses5.4" "ncurses5.4-config" || fail "ncurses5.4"
elif [ `uname -s` != "OpenBSD" ]; then
check_pkg "ncursesw" || \
check_custom "ncursesw5" "ncursesw5-config" || \
check_custom "ncursesw6" "ncursesw6-config" || fail "ncursesw"
fi
check_ssl_implementation
all_aboard_the_fail_boat