nsf / bmpanel

bmpanel - lightweight, netwm compliant, x11 panel with desktop switcher, taskbar, systray and clock

This URL has Read+Write access

nsf (author)
Wed Jul 23 23:55:40 -0700 2008
commit  22c2d63f03f9df0d9dd83bfa7fe8b16e3f5d55d5
tree    105bba1f119f0823977e056f79bdfc012c1c7a8a
parent  c25742d4b9948364a51020466cb3655128cde394
bmpanel / configure
100755 229 lines (202 sloc) 5.654 kb
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/bin/bash
 
# bmpanel configuration script
 
#----------------------------------------------------------------------------
# help message
#----------------------------------------------------------------------------
help() {
echo "Options:"
echo -e " --help print this help and exit"
echo -e " --prefix=PREFIX specify install path [default=/usr]"
echo -e " --debug enable debug mode"
echo -e " --mem-debug become a memleak hunter"
echo -e " --optimize extra optimizations"
echo -e " --ugly enable ugly verbose mode"
echo -e " --with-ev implement event loop with libev"
echo -e " --with-event implement event loop with libevent"
}
 
TIMERFDMSG="\n***************************************************************************\nWARNING! Probably you have an old glibc library and/or an old linux kernel,\nyou need glibc >= 2.8 and the linux kernel >= 2.6.22 to compile this panel.\n***************************************************************************\n"
LIBEVMSG="\n***************************************************************************\nWARNING! You selected --with-ev options, but it looks like you have no\nlibev, please make sure that libev was installed in compiler-known place.\n***************************************************************************\n"
LIBEVENTMSG="\n***************************************************************************\nWARNING! You selected --with-event options, but it looks like you have no\nlibevent, please make sure that libevent was installed in compiler-known\nplace.\n***************************************************************************\n"
 
#----------------------------------------------------------------------------
# globals
#----------------------------------------------------------------------------
CFLAGS="-Wall"
LIBS=""
PACKAGES=""
 
#----------------------------------------------------------------------------
# helper functions
#----------------------------------------------------------------------------
append_libs_and_cflags() {
CFLAGS="${CFLAGS} `pkg-config --cflags ${PACKAGES}`"
LIBS="${LIBS} `pkg-config --libs ${PACKAGES}`"
}
 
check_header() {
local HEADER=$1
local MSG=$2
echo -n "checking for $HEADER... "
 
cat <<EOF > tmp.c && gcc tmp.c 2> /dev/null
#include <$1>
int main() { return 0; }
EOF
 
RESULT=$?
rm -rf tmp.c
rm -rf a.out
 
if [ $RESULT -ne 0 ]; then
echo "no"
if [[ -n $MSG ]]; then
echo -e $MSG
fi
return
fi
echo "yes"
}
 
check_event_header() {
local MSG=$1
echo -n "checking for event.h... "
 
cat <<EOF > tmp.c && gcc tmp.c 2> /dev/null
#include <sys/types.h>
#include <event.h>
int main() { return 0; }
EOF
 
RESULT=$?
rm -rf tmp.c
rm -rf a.out
 
if [ $RESULT -ne 0 ]; then
echo "no"
if [[ -n $MSG ]]; then
echo -e $MSG
fi
return
fi
echo "yes"
}
 
check_pkg_version() {
local PACKAGE=$1
local VERSION=$2
echo -n "checking for $PACKAGE >= $VERSION... "
if ! (pkg-config --exists --atleast-version=${VERSION} ${PACKAGE}); then
echo "no"
exit 1
fi
echo "yes"
PACKAGES="${PACKAGES} ${PACKAGE}"
}
 
check_pkg() {
local PACKAGE=$1
echo -n "checking for $PACKAGE... "
if ! (pkg-config --exists ${PACKAGE}); then
echo "no"
exit 1
fi
echo "yes"
PACKAGES="${PACKAGES} ${PACKAGE}"
}
 
yes_no() {
local VAR=$1
if [ $VAR -eq 1 ]; then
echo "yes"
else
echo "no"
fi
}
 
#----------------------------------------------------------------------------
# parse command line options
#----------------------------------------------------------------------------
PREFIX="/usr"
DEBUG=0
MEMDEBUG=0
OPTIMIZE=0
UGLY=0
WITH_EV=0
WITH_EVENT=0
 
while [ $# -gt 0 ]; do
case $1 in
--help)
help
exit 0
;;
--prefix=*)
PREFIX=`echo $1 | sed 's/--prefix=//'`
;;
--debug)
DEBUG=1
;;
--mem-debug)
MEMDEBUG=1
;;
--optimize)
OPTIMIZE=1
;;
--ugly)
UGLY=1
;;
--with-ev)
WITH_EV=1
;;
--with-event)
WITH_EVENT=1
;;
*)
echo "unknown option $1"
help
exit 1
;;
esac
shift
done
 
#----------------------------------------------------------------------------
# general flow
#----------------------------------------------------------------------------
echo "checking for installed devel packages"
if [ $WITH_EV -eq 1 ]; then
check_header ev.h "$LIBEVMSG"
elif [ $WITH_EVENT -eq 1 ]; then
check_event_header "$LIBEVENTMSG"
else
check_header sys/timerfd.h "$TIMERFDMSG"
fi
check_pkg_version imlib2 1.4.0
check_pkg x11
check_pkg xrender
check_pkg xcomposite
check_pkg fontconfig
append_libs_and_cflags
 
if [ $MEMDEBUG -eq 1 ]; then
CFLAGS="$CFLAGS -DMEMDEBUG"
fi
 
if [ $WITH_EV -eq 1 ]; then
CFLAGS="$CFLAGS -DWITH_EV"
LIBS="$LIBS -lev"
elif [ $WITH_EVENT -eq 1 ]; then
CFLAGS="$CFLAGS -DWITH_EVENT"
LIBS="$LIBS -levent"
fi
 
if [ $DEBUG -eq 1 ]; then
CFLAGS="$CFLAGS -g -O0 -DLOG_ASSERT_ENABLED -DDEBUG"
else
if [ $OPTIMIZE -eq 1 ]; then
CFLAGS="$CFLAGS -O2 -march=native"
fi
fi
 
CFLAGS="$CFLAGS -DPREFIX=\\\\\\\"$PREFIX\\\\\\\""
 
CFLAGS=`echo $CFLAGS | xargs`
LIBS=`echo $LIBS | xargs`
 
echo ""
echo "---------- summary ----------"
echo " CFLAGS : $CFLAGS"
echo " LIBS : $LIBS"
echo " PREFIX : $PREFIX"
echo -n " DEBUG : "; yes_no $DEBUG
echo -n "MEMDEBUG : "; yes_no $MEMDEBUG
echo -n "OPTIMIZE : "; yes_no $OPTIMIZE
echo -n " UGLY : "; yes_no $UGLY
echo "-----------------------------"
echo ""
 
echo "writing .mk/config.mk..."
mkdir -p .mk
echo "PREFIX:=$PREFIX" > .mk/config.mk
echo "UGLY:=$UGLY" >> .mk/config.mk
echo "DEBUG:=$DEBUG" >> .mk/config.mk
echo "CFLAGS+=$CFLAGS" >> .mk/config.mk
echo "LIBS+=$LIBS" >> .mk/config.mk
echo "configure done"