remove superfluous autoreconnectonfail and fix SSL reconnect ...
[rofl0r-ixchat.git] / configure
blob09448f8867bdb55e9a42d10e3e98f108e1c55cc7
1 #!/bin/sh
3 prefix=/usr/local
5 libs=`cat << EOF
6 glib-2.0
7 gtk+-2.0
8 gtk+-x11-2.0
9 EOF
11 clear_config() {
12 rm -f config.mak 2>/dev/null
15 add_config() {
16 printf "%s\n" "$1" >> config.mak
19 add_cflags() {
20 add_config "CFLAGS += $1"
23 add_ldflags() {
24 add_config "LDFLAGS += $1"
27 get_pkgconf_cflags() {
28 pkg-config --cflags "$1" 2>/dev/null
31 get_pkgconf_ldflags() {
32 pkg-config --libs "$1" 2>/dev/null
35 add_pkgconf_cflags() {
36 fallback="$2"
37 flags=$(get_pkgconf_cflags "$1")
38 [ -z "$flags" ] && flags="$fallback"
39 add_cflags "$flags"
42 add_pkgconf_ldflags() {
43 fallback="$2"
44 flags=$(get_pkgconf_ldflags "$1")
45 [ -z "$flags" ] && flags="$fallback"
46 add_ldflags "$flags"
49 add_lib() {
50 add_pkgconf_cflags "$1" "$2"
51 add_pkgconf_ldflags "$1" "$3"
54 check_program() {
55 program="$1"
56 needed="$2"
57 result=$(which "$program" 2>/dev/null)
58 if [ "$needed" = "1" ] && [ -z "$result" ] ; then
59 echo "error: needed program $program not found" >&2
60 kill -9 $$
62 printf "%s\n" "$program"
65 usage() {
66 echo "supported arguments"
67 echo "--prefix=/path default: $prefix"
68 echo "--exec_prefix=/path default: $prefix/bin"
69 echo "--bindir=/path default: $prefix/bin"
70 echo "--libdir=/path default: $prefix/lib"
71 echo "--includedir=/path default: $prefix/include"
72 echo "--sysconfdir=/path default: $prefix/etc"
73 echo "--help : show this text"
74 exit 1
77 ismac() {
78 uname -s | grep Darwin >/dev/null
81 isbsd() {
82 uname -s | grep BSD >/dev/null
85 spliteq() {
86 arg=$1
87 echo "${arg#*=}"
88 #alternatives echo "$arg" | cut -d= -f2-
89 # or echo "$arg" | sed 's/[^=]*=//'
92 parsearg() {
93 case "$1" in
94 --prefix=*) prefix=`spliteq $1`;;
95 --exec_prefix=*) exec_prefix=`spliteq $1`;;
96 --bindir=*) bindir=`spliteq $1`;;
97 --libdir=*) libdir=`spliteq $1`;;
98 --includedir=*) includedir=`spliteq $1`;;
99 --sysconfdir=*) sysconfdir=`spliteq $1`;;
100 --help) usage;;
101 esac
104 while true ; do
105 case $1 in
106 -*) parsearg "$1"; shift;;
107 *) break ;;
108 esac
109 done
111 [ -z "$exec_prefix" ] && exec_prefix=$prefix
112 [ -z "$libdir" ] && libdir=$prefix/lib
113 [ -z "$includedir" ] && includedir=$prefix/include
114 [ -z "$sysconfdir" ] && sysconfdir=$prefix/etc
115 [ -z "$bindir" ] && bindir=$exec_prefix/bin
116 [ -z "$CC" ] && CC=cc
118 clear_config
120 add_config "prefix = $prefix"
121 add_config "exec_prefix = $exec_prefix"
122 add_config "bindir = $bindir"
123 add_config "libdir = $libdir"
124 add_config "includedir = $includedir"
125 add_config "sysconfdir = $sysconfdir"
127 add_config "CC ?= $CC"
128 [ -z "$CPPFLAGS" ] || add_config "CPPFLAGS ?= $CPPFLAGS"
129 [ -z "$CFLAGS" ] || add_config "CFLAGS ?= $CFLAGS"
131 add_cflags "-DXCHATLIBDIR=\\\"$libdir/xchat\\\""
132 add_cflags "-DXCHATSHAREDIR=\\\"$prefix/share/xchat\\\""
133 add_cflags "-DUSE_OPENSSL"
135 for lib in $libs ; do add_lib "$lib" ; done
136 add_lib openssl "" "-lssl -lcrypto"
138 prog1=$(check_program "gdk-pixbuf-csource" 1)
139 add_config "PIXMAPCONVERT = $prog1"
141 # plugin stuff ...
143 use_plugin=
145 perl=$(check_program "perl" 0)
146 if [ -n "$perl" ] ; then
147 printf "perl detected, plugin activated\n"
148 PERL_CFLAGS=`$perl -MExtUtils::Embed -e ccopts 2>/dev/null`
149 PERL_LDFLAGS=`$perl -MExtUtils::Embed -e ldopts 2>/dev/null | sed 's/-lgdbm //'`
150 add_config "PERL_CFLAGS = $PERL_CFLAGS"
151 add_config "PERL_LDFLAGS = $PERL_LDFLAGS"
152 add_config "PLUGINS += perl.so"
153 if [ -z "$use_plugin" ] ; then
154 add_cflags "-DUSE_PLUGIN"
155 use_plugin=1
157 # there are actually 2 plugins, "old" and new, but all scripts i've seen only use old
158 add_cflags "-DOLD_PERL"
161 python=$(check_program "python" 0)
162 if [ -n "$python" ] ; then
163 printf "python detected, plugin activated\n"
164 printf "WARNING: python plugin needs environment variable PYTHONHOME\n"
165 printf " set to python's prefix.\n"
166 printf " lack of that environment variable will cause xchat exitting\n"
167 printf " when the plugin is loaded.\n"
168 printf " on sabotage linux, use \"PYTHONHOME=/ ixchat\"\n"
169 printf " to launch the program.\n"
171 PY_CFLAGS=$(get_pkgconf_cflags python)
172 [ -z "$PY_CFLAGS" ] && PY_CFLAGS=$(get_pkgconf_cflags python-2.7)
173 if [ -z "$PY_CFLAGS" ] ; then
174 for i in "$prefix" /usr /usr/local/ ; do
175 printf "searching Python.h in $i/include/python2.7 ... "
176 if [ -e "$i"/include/python2.7/Python.h ] ; then
177 PY_CFLAGS=-I"$i"/include/python2.7
178 printf "SUCCESS\n"
179 break;
180 else
181 printf "FAIL\n"
183 done
185 PY_LDFLAGS=$(get_pkgconf_ldflags python)
186 [ -z "$PY_LDFLAGS" ] && PY_LDFLAGS=$(get_pkgconf_ldflags python-2.7)
187 [ -z "$PY_LDFLAGS" ] && PY_LDFLAGS=-lpython2.7
188 if [ ! -z "$PY_CFLAGS" ] ; then
189 add_config "PY_CFLAGS = $PY_CFLAGS"
190 add_config "PY_LDFLAGS = $PY_LDFLAGS"
191 add_config "PLUGINS += python.so"
192 if [ -z "$use_plugin" ] ; then
193 add_cflags "-DUSE_PLUGIN"
194 use_plugin=1
196 else
197 printf "python not found, skipping plugin\n"
201 tcl=$(check_program "tclsh" 0)
202 if [ -n "$tcl" ] ; then
203 printf "tcl detected, plugin activated\n"
204 TCL_CFLAGS=$(get_pkgconf_cflags tcl)
205 TCL_LDFLAGS=$(get_pkgconf_ldflags tcl)
206 tcl_error=
207 # tcl 8.5 does not come with a pkgconfig file
208 # tcl 8.6. comes with a buggy one that fails to include its own library
209 # https://sourceforge.net/tracker/?func=detail&aid=3598298&group_id=10894&atid=110894
210 # hopefully tcl 8.7 will come with a *working* pkgconfig file ...
211 # until that happens, we need to fall back to its proprietary tclConfig system.
212 if [ -z "$TCL_LDFLAGS" ] || ! echo "$TCL_LDFLAGS" | grep "[-]ltcl" > /dev/null ; then
213 tcl_found=
214 for i in "$libdir" "$prefix"/lib/ "$prefix"/lib64/ /lib /lib64 /usr/lib /usr/lib64 ; do
215 printf "searching tclConfig.sh in $i ... "
216 if [ -e "$i"/tclConfig.sh ] ; then
217 . "$i"/tclConfig.sh
218 TCL_LDFLAGS="$TCL_LIB_SPEC $TCL_LIBS"
219 tcl_found=1
220 printf "SUCCESS\n"
221 break
222 else
223 printf "FAIL\n"
225 done
226 if [ -z "$tcl_found" ] ; then
227 echo "warning: tclConfig.sh not found and no pkgconfig entry available"
228 echo "disabling tcl plugin"
229 tcl_error=1
232 if [ -z "$tcl_error" ] ; then
233 add_config "TCL_CFLAGS = $TCL_CFLAGS"
234 add_config "TCL_LDFLAGS = $TCL_LDFLAGS"
235 add_config "PLUGINS += tcl.so"
236 if [ -z "$use_plugin" ] ; then
237 add_cflags "-DUSE_PLUGIN"
238 use_plugin=1
243 for i in libsexy gtkspell-2.0 ; do
244 spell_flags=$(get_pkgconf_cflags $i)
245 if [ ! -z "$spell_flags" ] ; then
246 add_cflags "$spell_flags"
247 spell_flags=$(get_pkgconf_ldflags $i)
248 add_ldflags "$spell_flags"
249 if [ "$i" = "libsexy" ] ; then
250 add_cflags "-DUSE_LIBSEXY"
251 else
252 add_cflags "-DUSE_GTKSPELL"
254 break
256 done
258 if isbsd || ismac ; then
259 add_config "INSTALL_FLAGS=-m"
263 echo done, now run make \&\& make install