-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
znc-buildmod
executable file
·84 lines (64 loc) · 1.73 KB
/
znc-buildmod
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
#!/bin/sh
# These vars hold some color escape sequences.
# Inspired by /sbin/functions.sh from gentoo
BOLD='\033[1;m'
UNBOLD='\033[22;m'
RED='\033[31;01m'
GREEN='\033[32;01m'
YELLOW='\033[33;01m'
BLUE='\033[34;01m'
NORMAL='\033[39;m'
RESTART='\r'
# These are used when we display our messages
ERROR="${BOLD}${BLUE}[${RED} !! ${BLUE}]${NORMAL}${UNBOLD}"
WARNING="${BOLD}${BLUE}[${YELLOW} ** ${BLUE}]${NORMAL}${UNBOLD}"
OK="${BOLD}${BLUE}[${GREEN} ok ${BLUE}]${NORMAL}${UNBOLD}"
PROGRESS="${BOLD}${BLUE}[ ]${NORMAL}${UNBOLD}"
# Check if we got everything we need
SED=sed
ZNC_CONFIG=znc-config
if test "x$CXX" = "x" ; then
CXX=g++
fi
check_binary()
{
which $1 > /dev/null 2>&1
if test $? = 1 ; then
echo -e "${ERROR} Could not find $1. $2"
exit 1
fi
}
check_binary ${SED}
check_binary ${ZNC_CONFIG} "Please (re)install ZNC."
check_binary ${CXX} "What happened to your compiler?"
if test -z "$1"; then
echo -e "${WARNING} USAGE: $0 <file.cpp> [file.cpp ... ]"
exit 1
fi
CXXFLAGS=`${ZNC_CONFIG} --cflags`
INCLUDES=`${ZNC_CONFIG} --include`
LIBS=`${ZNC_CONFIG} --libs`
# Get the first word and strip away the first two chars (which is -I)
INC_PATH=`echo ${INCLUDES} | ${SED} 's: .*::' | ${SED} 's:^..::'`
if test ! -d ${INC_PATH}; then
echo -e "${ERROR} Unable to find znc include dir [${INC_PATH}]. Please (re)install ZNC."
exit 1
fi
while test ! -z "$1"
do
FILE=$1
shift
MOD="${FILE%.cpp}"
MOD="${MOD%.cc}"
if test ! -f ${FILE}; then
echo -e "${ERROR} Building ${MOD}.so... File not found"
else
echo -ne "${PROGRESS} Building ${MOD}.so... "
if ${CXX} ${CXXFLAGS} ${INCLUDES} ${LIBS} -shared -o ${MOD}.so ${FILE} ; then
echo -e "${RESTART}${OK}"
else
echo -e "${ERROR} Error while building ${MOD}.so"
fi
fi
done
exit 0