configure: activate old perl plugin as well
[rofl0r-ixchat.git] / configure
blob87266a75f009b990b3818c39c9b31cd9adde3240
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 openssl
10 EOF
14 clear_config() {
15 rm config.mak
18 add_config() {
19 printf "%s\n" "$1" >> config.mak
22 add_cflags() {
23 add_config "CFLAGS += $1"
26 add_ldflags() {
27 add_config "LDFLAGS += $1"
30 get_pkgconf_cflags() {
31 pkg-config --cflags "$1" 2>/dev/null
34 get_pkgconf_ldflags() {
35 pkg-config --libs "$1" 2>/dev/null
38 add_pkgconf_cflags() {
39 flags=$(get_pkgconf_cflags "$1")
40 add_cflags "$flags"
43 add_pkgconf_ldflags() {
44 flags=$(get_pkgconf_ldflags "$1")
45 add_ldflags "$flags"
48 add_lib() {
49 add_pkgconf_cflags "$1"
50 add_pkgconf_ldflags "$1"
53 check_program() {
54 program="$1"
55 needed="$2"
56 result=$(which "$program" 2>/dev/null)
57 if [ "$needed" = "1" ] && [ -z "$result" ] ; then
58 echo "error: needed program $program not found" >&2
59 kill -9 $$
61 printf "%s\n" "$program"
64 usage() {
65 echo "supported arguments"
66 echo "--prefix=/path default: $prefix"
67 echo "--exec_prefix=/path default: $prefix/bin"
68 echo "--bindir=/path default: $prefix/bin"
69 echo "--libdir=/path default: $prefix/lib"
70 echo "--includedir=/path default: $prefix/include"
71 echo "--sysconfdir=/path default: $prefix/etc"
72 echo "--help : show this text"
73 exit 1
76 spliteq() {
77 arg=$1
78 echo "${arg#*=}"
79 #alternatives echo "$arg" | cut -d= -f2-
80 # or echo "$arg" | sed 's/[^=]*=//'
83 parsearg() {
84 case "$1" in
85 --prefix=*) prefix=`spliteq $1`;;
86 --exec_prefix=*) exec_prefix=`spliteq $1`;;
87 --bindir=*) bindir=`spliteq $1`;;
88 --libdir=*) libdir=`spliteq $1`;;
89 --includedir=*) includedir=`spliteq $1`;;
90 --sysconfdir=*) sysconfdir=`spliteq $1`;;
91 --help) usage;;
92 esac
95 while true ; do
96 case $1 in
97 -*) parsearg "$1"; shift;;
98 *) break ;;
99 esac
100 done
102 [ -z "$exec_prefix" ] && exec_prefix=$prefix
103 [ -z "$libdir" ] && libdir=$prefix/lib
104 [ -z "$includedir" ] && includedir=$prefix/include
105 [ -z "$sysconfdir" ] && sysconfdir=$prefix/etc
106 [ -z "$bindir" ] && bindir=$exec_prefix/bin
107 [ -z "$CC" ] && CC=cc
109 clear_config
111 add_config "prefix = $prefix"
112 add_config "exec_prefix = $exec_prefix"
113 add_config "bindir = $bindir"
114 add_config "libdir = $libdir"
115 add_config "includedir = $includedir"
116 add_config "sysconfdir = $sysconfdir"
118 add_config "CC ?= $CC"
119 [ -z "$CPPFLAGS" ] || add_config "CPPFLAGS ?= $CPPFLAGS"
120 [ -z "$CFLAGS" ] || add_config "CFLAGS ?= $CFLAGS"
122 add_cflags "-DXCHATLIBDIR=\\\"$libdir/xchat\\\""
123 add_cflags "-DXCHATSHAREDIR=\\\"$prefix/share/xchat\\\""
124 add_cflags "-DUSE_OPENSSL"
126 for lib in $libs ; do add_lib "$lib" ; done
128 prog1=$(check_program "gdk-pixbuf-csource" 1)
129 add_config "PIXMAPCONVERT = $prog1"
131 # plugin stuff ...
133 use_plugin=
135 perl=$(check_program "perl" 0)
136 if [ -n "$perl" ] ; then
137 PERL_CFLAGS=`$perl -MExtUtils::Embed -e ccopts 2>/dev/null`
138 PERL_LDFLAGS=`$perl -MExtUtils::Embed -e ldopts 2>/dev/null | sed 's/-lgdbm //'`
139 add_config "PERL_CFLAGS = $PERL_CFLAGS"
140 add_config "PERL_LDFLAGS = $PERL_LDFLAGS"
141 add_config "PLUGINS += perl.so"
142 if [ -z "$use_plugin" ] ; then
143 add_cflags "-DUSE_PLUGIN"
144 use_plugin=1
146 # there are actually 2 plugins, "old" and new, but all scripts i've seen only use old
147 add_cflags "-DOLD_PERL"
150 python=$(check_program "python" 0)
151 if [ -n "$python" ] ; then
152 PY_CFLAGS=$(get_pkgconf_cflags python)
153 PY_LDFLAGS=$(get_pkgconf_ldflags python)
154 add_config "PY_CFLAGS = $PY_CFLAGS"
155 add_config "PY_LDFLAGS = $PY_LDFLAGS"
156 add_config "PLUGINS += python.so"
157 if [ -z "$use_plugin" ] ; then
158 add_cflags "-DUSE_PLUGIN"
159 use_plugin=1
163 tcl=$(check_program "tclsh" 0)
164 if [ -n "$tcl" ] ; then
165 TCL_CFLAGS=$(get_pkgconf_cflags tcl)
166 TCL_LDFLAGS=$(get_pkgconf_ldflags tcl)
167 tcl_error=
168 if [ -z "$TCL_LDFLAGS" ] ; then
169 tcl_found=
170 for i in "$libdir"/tclConfig.sh "$prefix"/lib/tclConfig.sh "$prefix"/lib64/tclConfig.sh ; do
171 if [ -e "$i" ] ; then
172 . "$i"
173 TCL_LDFLAGS="$TCL_LIB_SPEC $TCL_LIBS"
174 tcl_found=1
176 done
177 if [ -z "$tcl_found" ] ; then
178 echo "warning: tclConfig.sh not found and no pkgconfig entry available"
179 echo "disabling tcl plugin"
180 tcl_error=1
183 if [ -z "$tcl_error" ] ; then
184 add_config "TCL_CFLAGS = $TCL_CFLAGS"
185 add_config "TCL_LDFLAGS = $TCL_LDFLAGS"
186 add_config "PLUGINS += tcl.so"
187 if [ -z "$use_plugin" ] ; then
188 add_cflags "-DUSE_PLUGIN"
189 use_plugin=1
195 echo done, now run make \&\& make install