chiark / gitweb /
De-dupe choose_{next,prev}_clicked.
[disorder] / acinclude.m4
... / ...
CommitLineData
1# This file is part of DisOrder.
2# Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17# USA
18#
19
20AC_DEFUN([RJK_FIND_GC_H],[
21 AC_CACHE_CHECK([looking for <gc.h>],[rjk_cv_gc_h],[
22 AC_PREPROC_IFELSE([
23 #include <gc.h>
24 ],
25 [rjk_cv_gc_h="on default include path"],[
26 oldCPPFLAGS="${CPPFLAGS}"
27 for dir in /usr/include/gc /usr/local/include/gc; do
28 if test "x$GCC" = xyes; then
29 CPPFLAGS="${oldCPPFLAGS} -isystem $dir"
30 else
31 CPPFLAGS="${oldCPPFLAGS} -I$dir"
32 fi
33 AC_PREPROC_IFELSE([
34 #include <gc.h>
35 ],
36 [rjk_cv_gc_h=$dir;break],[rjk_cv_gc_h="not found"])
37 done
38 CPPFLAGS="${oldCPPFLAGS}"
39 ])
40 ])
41 case "$rjk_cv_gc_h" in
42 "not found" )
43 missing_headers="$missing_headers gc.h"
44 ;;
45 /* )
46 if test "x$GCC" = xyes; then
47 CPPFLAGS="${CPPFLAGS} -isystem $rjk_cv_gc_h"
48 else
49 CPPFLAGS="${CPPFLAGS} -I$rjk_cv_gc_h"
50 fi
51 ;;
52 esac
53])
54
55AC_DEFUN([RJK_CHECK_LIB],[
56 AC_CACHE_CHECK([for $2 in -l$1],[rjk_cv_lib_$1_$2],[
57 save_LIBS="$LIBS"
58 LIBS="${LIBS} -l$1"
59 AC_LINK_IFELSE([AC_LANG_PROGRAM([$3],[$2;])],
60 [rjk_cv_lib_$1_$2=yes],
61 [rjk_cv_lib_$1_$2=no])
62 LIBS="$save_LIBS"
63 ])
64 if test $rjk_cv_lib_$1_$2 = yes; then
65 $4
66 else
67 $5
68 fi
69])
70
71AC_DEFUN([RJK_REQUIRE_PCRE_UTF8],[
72 AC_CACHE_CHECK([whether libpcre was built with UTF-8 support],
73 [rjk_cv_pcre_utf8],[
74 save_LIBS="$LIBS"
75 LIBS="$LIBS $1"
76 AC_RUN_IFELSE([AC_LANG_PROGRAM([
77 #include <pcre.h>
78 #include <stdio.h>
79 ],
80 [
81 pcre *r;
82 const char *errptr;
83 int erroffset;
84
85 r = pcre_compile("\x80\x80", PCRE_UTF8,
86 &errptr, &erroffset, 0);
87 if(!r) {
88 fprintf(stderr, "pcre_compile: %s at %d",
89 errptr, erroffset);
90 exit(0);
91 } else {
92 fprintf(stderr, "accepted bogus UTF-8 string\n");
93 exit(1);
94 }
95 ])],
96 [rjk_cv_pcre_utf8=yes],
97 [rjk_cv_pcre_utf8=no],
98 [AC_MSG_WARN([cross-compiling, cannot check libpcre behaviour])])
99 LIBS="$save_LIBS"
100 ])
101 if test $rjk_cv_pcre_utf8 = no; then
102 AC_MSG_ERROR([please rebuild your pcre library with --enable-utf8])
103 fi
104])
105
106AC_DEFUN([RJK_GCOV],[
107 GCOV=${GCOV:-true}
108 AC_ARG_WITH([gcov],
109 [AS_HELP_STRING([--with-gcov],
110 [Enable coverage testing])],
111 [if test $withval = yes; then
112 CFLAGS="${CFLAGS} -O0 -fprofile-arcs -ftest-coverage"
113 GCOV=`echo $CC | sed s'/gcc/gcov/;s/ .*$//'`;
114 fi])
115 AC_SUBST([GCOV],[$GCOV])
116])