13 rm -f config.mak
2>/dev
/null
17 printf "%s\n" "$1" >> config.mak
21 add_config
"CFLAGS += $1"
25 add_config
"LDFLAGS += $1"
28 get_pkgconf_cflags
() {
29 pkg-config
--cflags "$1" 2>/dev
/null
32 get_pkgconf_ldflags
() {
33 pkg-config
--libs "$1" 2>/dev
/null
36 add_pkgconf_cflags
() {
38 flags
=$
(get_pkgconf_cflags
"$1")
39 [ -z "$flags" ] && flags
="$fallback"
43 add_pkgconf_ldflags
() {
45 flags
=$
(get_pkgconf_ldflags
"$1")
46 [ -z "$flags" ] && flags
="$fallback"
51 add_pkgconf_cflags
"$1" "$2"
52 ADD_LIB_CFLAGS
="$flags"
53 add_pkgconf_ldflags
"$1" "$3"
54 ADD_LIB_LDFLAGS
="$flags"
60 result
=$
(which "$program" 2>/dev
/null
)
61 if [ "$needed" = "1" ] && [ -z "$result" ] ; then
62 echo "error: needed program $program not found" >&2
65 printf "%s\n" "$program"
70 printf "--enable-%s[=yes/no/auto]\tenable %s %s [default: auto]\n" "$a" "$a" "$2"
74 echo "supported arguments"
75 echo "--help show this text"
76 echo "--prefix=/path default: $prefix"
77 echo "--exec_prefix=/path default: $prefix/bin"
78 echo "--bindir=/path default: $prefix/bin"
79 echo "--libdir=/path default: $prefix/lib"
80 echo "--includedir=/path default: $prefix/include"
81 echo "--sysconfdir=/path default: $prefix/etc"
83 for i
in libsexy gtkspell
; do pdisable
$i "library usage" ; done
85 for i
in python tcl perl
; do pdisable
$i plugin
; done
87 echo "NOTE: the auto detection of the scripting language plugins"
88 echo "works only for non-crosscompile scenarios because the authors of those languages"
89 echo "stubbornly require you to execute the interpreter in a specific way to query"
90 echo "the necessary flags rather than relying on standardtools like pkgconfig."
91 echo "because of that, if set to yes, the required C/LDFLAGS for the plugins need to be passed"
92 echo "manually to configure using PERL_CFLAGS=... PY_LDFLAGS=... TCL_CFLAGS=... /configure ..."
98 uname
-s |
grep Darwin
>/dev
/null
102 uname
-s |
grep BSD
>/dev
/null
108 #alternatives echo "$arg" | cut -d= -f2-
109 # or echo "$arg" | sed 's/[^=]*=//'
116 --enable-$f) res
=yes;;
117 --disable-$f) res
=no
;;
118 --enable-$f=*) res
=`spliteq $2`;;
120 [ -n "$res" ] && eval $3=$res
124 for i
in python perl tcl libsexy gtkspell
; do check_feature
$i "$1" feature_
$i ; done
126 --prefix=*) prefix
=`spliteq $1`;;
127 --exec_prefix=*) exec_prefix
=`spliteq $1`;;
128 --bindir=*) bindir
=`spliteq $1`;;
129 --libdir=*) libdir
=`spliteq $1`;;
130 --includedir=*) includedir
=`spliteq $1`;;
131 --sysconfdir=*) sysconfdir
=`spliteq $1`;;
136 fail
() { printf "%s\n" "$1" >&2 ; exit 1 ; }
138 # Get a temporary filename
141 while : ; do i
=$
(($i+1))
142 tmpc
="./conf$$-$PPID-$i.c"
143 2>|
/dev
/null
> "$tmpc" && break
144 test "$i" -gt 50 && fail
"$0: cannot create temporary file $tmpc"
147 trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP
150 printf "checking %s ... " "$1"
151 printf "$3" > "$tmpc"
153 $CC $TMP_FLAGS $OUR_CPPFLAGS $CPPFLAGS $2 $CFLAGS "$tmpc" $OUR_LDFLAGS -o /dev
/null
>/dev
/null
2>&1 \
156 { printf "yes\n" ; test x
"$2" = x || OUR_CPPFLAGS
="$OUR_CPPFLAGS $2" ; } \
162 printf "checking whether \$CC defines %s ... " "$1"
164 $CC $TMP_FLAGS $OUR_CPPFLAGS $CPPFLAGS $CFLAGS -dM -E - </dev
/null |
grep "$1" >/dev
/null
&& res
=0
165 test x
$res = x0
&& printf "yes\n" ||
printf "no\n"
169 check_compile_run
() {
170 printf "checking %s ... " "$1"
171 printf "$2" > "$tmpc"
173 $CC $OUR_CPPFLAGS $CPPFLAGS $CFLAGS "$tmpc" -o "$tmpc".out
>/dev
/null
2>&1 \
175 test x
$res = x0
&& { "$tmpc".out || res
=1 ; }
177 test x
$res = x0
&& printf "yes\n" ||
printf "no\n"
181 check_link_silent
() {
182 printf "$2" > "$tmpc"
183 $CC $TMP_FLAGS $OUR_CPPFLAGS $CPPFLAGS $1 $CFLAGS "$tmpc" -o /dev
/null
>/dev
/null
2>&1
187 printf "checking %s ... " "$1"
189 check_link_silent
"$2" "$3" || res
=1
190 test x
$res = x0
&& printf "yes\n" ||
printf "no\n"
194 [ -z "$CC" ] && CC
=cc
195 [ -z "$exec_prefix" ] && exec_prefix
=$prefix
196 [ -z "$libdir" ] && libdir
=$prefix/lib
197 [ -z "$includedir" ] && includedir
=$prefix/include
198 [ -z "$sysconfdir" ] && sysconfdir
=$prefix/etc
199 [ -z "$bindir" ] && bindir
=$exec_prefix/bin
203 add_config
"prefix = $prefix"
204 add_config
"exec_prefix = $exec_prefix"
205 add_config
"bindir = $bindir"
206 add_config
"libdir = $libdir"
207 add_config
"includedir = $includedir"
208 add_config
"sysconfdir = $sysconfdir"
210 add_config
"CC ?= $CC"
212 [ -z "$CPPFLAGS" ] || add_config
"USER_CPPFLAGS = $CPPFLAGS"
213 [ -z "$CFLAGS" ] || add_config
"USER_CFLAGS = $CFLAGS"
214 [ -z "$LDFLAGS" ] || add_config
"USER_LDFLAGS = $LDFLAGS"
217 check_compile
'whether C compiler works' '' 'int main() {return 0;}' || fail
'error: install a C compiler and library'
218 check_compile
'whether we have memrchr()' "-DGNU_SOURCE -DHAVE_MEMRCHR" \
219 '#define _GNU_SOURCE\n#include <string.h>\nint main() {\nvoid *p = memrchr("foo", 0, 3);\nreturn 0;}'
221 add_lib openssl
"" "-lssl -lcrypto"
223 TMP_FLAGS
="$ADD_LIB_CFLAGS"
224 check_link
'whether we have ssl lib and headers' "$ADD_LIB_LDFLAGS" \
225 "#include <openssl/ssl.h>\nint main() { return 0; }" || \
226 fail
'ssl library not found'
227 OUR_LDFLAGS
="$ADD_LIB_LDFLAGS"
229 check_compile
'whether we have SSL_CTX_get_ssl_method()' \
230 '-DHAVE_SSL_CTX_get_ssl_method' \
231 "#include <openssl/ssl.h>\nint main() { SSL_CTX *c = 0; (void)SSL_CTX_get_ssl_method(c); return 0;}"
233 check_compile
'whether we have DH_set0_pqg()' \
234 '-DHAVE_DH_set0_pqg' \
235 "#include <openssl/ssl.h>\nint main() { DH *c = 0; (void)DH_set0_pqg(c,0,0,0); return 0;}"
237 check_compile
'whether we have DH_get0_pub_key()' \
238 '-DHAVE_DH_get0_pub_key' \
239 "#include <openssl/ssl.h>\nint main() { DH *c = 0; (void)DH_get0_pub_key(c); return 0;}"
242 for i
in python perl tcl libsexy gtkspell
; do eval feature_
$i=auto
; done
245 -*) parsearg
"$1"; shift;;
250 [ -z "$OUR_CPPFLAGS" ] || add_config
"USER_CPPFLAGS += $OUR_CPPFLAGS"
253 add_cflags
"-DXCHATLIBDIR=\\\"$libdir/xchat\\\""
254 add_cflags
"-DXCHATSHAREDIR=\\\"$prefix/share/xchat\\\""
255 add_cflags
"-DUSE_OPENSSL"
257 for lib
in $libs ; do add_lib
"$lib" ; done
259 check_link
'whether we have libdl' '-ldl' \
260 "int main() { return 0; }" && add_ldflags
'-ldl'
262 prog1
=$
(check_program
"gdk-pixbuf-csource" 1)
263 add_config
"PIXMAPCONVERT = $prog1"
265 for i
in libsexy gtkspell
; do
266 eval enabled
=\
${feature_$i}
267 printf "checking whether to use library $i..."
268 if [ "$enabled" = yes ] ||
[ "$enabled" = auto
] ; then
270 [ $l = gtkspell
] && l
=gtkspell-2.0
271 spell_flags
=$
(get_pkgconf_cflags
$l)
272 if [ ! -z "$spell_flags" ] ; then
273 add_cflags
"$spell_flags"
274 spell_flags
=$
(get_pkgconf_ldflags
$i)
275 add_ldflags
"$spell_flags"
276 if [ "$i" = "libsexy" ] ; then
277 add_cflags
"-DUSE_LIBSEXY"
279 add_cflags
"-DUSE_GTKSPELL"
283 if [ "$enabled" = yes ] ; then
284 printf "error: $i requested but not found!"
296 printf "checking whether to use perl plugin..."
297 if [ "$feature_perl" = auto
] ; then
298 perl
=$
(check_program
"perl" 0)
299 if [ -n "$perl" ] ; then
300 PERL_CFLAGS
=`$perl -MExtUtils::Embed -e ccopts 2>/dev/null`
301 PERL_LDFLAGS
=`$perl -MExtUtils::Embed -e ldopts 2>/dev/null | sed 's/-lgdbm //'`
305 if [ "$feature_perl" = yes ] ; then
307 add_config
"PERL_CFLAGS = $PERL_CFLAGS"
308 add_config
"PERL_LDFLAGS = $PERL_LDFLAGS"
309 add_config
"PLUGINS += perl.so"
310 # there are actually 2 plugins, "old" and new, but all scripts i've seen only use old
311 add_cflags
"-DOLD_PERL"
316 printf "checking whether to use tcl plugin..."
317 if [ "$feature_tcl" = auto
] ; then
318 tcl
=$
(check_program
"tclsh" 0)
319 if [ -n "$tcl" ] ; then
320 TCL_CFLAGS
=$
(get_pkgconf_cflags tcl
)
321 TCL_LDFLAGS
=$
(get_pkgconf_ldflags tcl
)
323 # tcl 8.5 does not come with a pkgconfig file
324 # tcl 8.6. comes with a buggy one that fails to include its own library
325 # https://sourceforge.net/tracker/?func=detail&aid=3598298&group_id=10894&atid=110894
326 # hopefully tcl 8.7 will come with a *working* pkgconfig file ...
327 # until that happens, we need to fall back to its proprietary tclConfig system.
328 if [ -z "$TCL_LDFLAGS" ] ||
! echo "$TCL_LDFLAGS" |
grep "[-]ltcl" > /dev
/null
; then
330 for i
in "$libdir" "$prefix"/lib
/ "$prefix"/lib64
/ /lib
/lib64
/usr
/lib
/usr
/lib64
; do
331 printf "searching tclConfig.sh in $i ... "
332 if [ -e "$i"/tclConfig.sh
] ; then
334 TCL_LDFLAGS
="$TCL_LIB_SPEC $TCL_LIBS"
339 if [ -z "$tcl_found" ] ; then
343 [ -z "$tcl_error" ] && feature_tcl
=yes
346 if [ "$feature_tcl" = yes ] ; then
348 add_config
"TCL_CFLAGS = $TCL_CFLAGS"
349 add_config
"TCL_LDFLAGS = $TCL_LDFLAGS"
350 add_config
"PLUGINS += tcl.so"
355 printf "checking whether to use python plugin..."
356 if [ "$feature_python" = auto
] ; then
357 python
=$
(check_program
"python" 0)
358 if [ -n "$python" ] ; then
359 PY_CFLAGS
=$
(get_pkgconf_cflags python
)
360 [ -z "$PY_CFLAGS" ] && PY_CFLAGS
=$
(get_pkgconf_cflags python-2.7
)
361 if [ -z "$PY_CFLAGS" ] ; then
362 for i
in "$prefix" /usr
/usr
/local
/ ; do
363 printf "searching Python.h in $i/include/python2.7 ... "
364 if [ -e "$i"/include
/python2.7
/Python.h
] ; then
365 PY_CFLAGS
=-I"$i"/include
/python2.7
373 PY_LDFLAGS
=$
(get_pkgconf_ldflags python
)
374 [ -z "$PY_LDFLAGS" ] && PY_LDFLAGS
=$
(get_pkgconf_ldflags python-2.7
)
375 [ -z "$PY_LDFLAGS" ] && PY_LDFLAGS
=-lpython2.7
376 [ ! -z "$PY_CFLAGS" ] && feature_python
=yes
379 if [ "$feature_python" = yes ] ; then
381 printf "WARNING: python plugin needs environment variable PYTHONHOME\n"
382 printf " set to python's prefix.\n"
383 printf " lack of that environment variable will cause ixchat exitting\n"
384 printf " when the plugin is loaded.\n"
385 printf " on sabotage linux, use \"PYTHONHOME=/ ixchat\"\n"
386 printf " to launch the program.\n"
387 add_config
"PY_CFLAGS = $PY_CFLAGS"
388 add_config
"PY_LDFLAGS = $PY_LDFLAGS"
389 add_config
"PLUGINS += python.so"
395 if [ "$use_plugin" = 1 ] ; then
396 add_cflags
"-DUSE_PLUGIN"
399 if isbsd || ismac
; then
400 add_config
"INSTALL_FLAGS=-m"
403 add_cflags
"\$(USER_CPPFLAGS) \$(USER_CFLAGS)"
404 add_ldflags
"\$(USER_LDFLAGS)"
405 echo done, now run
make \
&\
& make install