chiark / gitweb /
cgi/cgimain.c: Make the CGI program be (a little) locale-aware.
[disorder] / acinclude.m4
CommitLineData
460b9539 1# This file is part of DisOrder.
5aff007d 2# Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
460b9539 3#
e7eb3a27 4# This program is free software: you can redistribute it and/or modify
460b9539 5# it under the terms of the GNU General Public License as published by
e7eb3a27 6# the Free Software Foundation, either version 3 of the License, or
460b9539 7# (at your option) any later version.
e7eb3a27
RK
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
460b9539 14# You should have received a copy of the GNU General Public License
e7eb3a27 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 16#
17
18AC_DEFUN([RJK_FIND_GC_H],[
19 AC_CACHE_CHECK([looking for <gc.h>],[rjk_cv_gc_h],[
b8ca4525 20 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
460b9539 21 #include <gc.h>
b8ca4525 22 ],[])],
460b9539 23 [rjk_cv_gc_h="on default include path"],[
24 oldCPPFLAGS="${CPPFLAGS}"
25 for dir in /usr/include/gc /usr/local/include/gc; do
26 if test "x$GCC" = xyes; then
27 CPPFLAGS="${oldCPPFLAGS} -isystem $dir"
28 else
29 CPPFLAGS="${oldCPPFLAGS} -I$dir"
30 fi
b8ca4525 31 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
460b9539 32 #include <gc.h>
b8ca4525 33 ],[])],
460b9539 34 [rjk_cv_gc_h=$dir;break],[rjk_cv_gc_h="not found"])
35 done
36 CPPFLAGS="${oldCPPFLAGS}"
37 ])
38 ])
39 case "$rjk_cv_gc_h" in
40 "not found" )
41 missing_headers="$missing_headers gc.h"
42 ;;
43 /* )
44 if test "x$GCC" = xyes; then
45 CPPFLAGS="${CPPFLAGS} -isystem $rjk_cv_gc_h"
46 else
47 CPPFLAGS="${CPPFLAGS} -I$rjk_cv_gc_h"
48 fi
49 ;;
50 esac
51])
52
53AC_DEFUN([RJK_CHECK_LIB],[
54 AC_CACHE_CHECK([for $2 in -l$1],[rjk_cv_lib_$1_$2],[
55 save_LIBS="$LIBS"
56 LIBS="${LIBS} -l$1"
57 AC_LINK_IFELSE([AC_LANG_PROGRAM([$3],[$2;])],
58 [rjk_cv_lib_$1_$2=yes],
59 [rjk_cv_lib_$1_$2=no])
60 LIBS="$save_LIBS"
61 ])
62 if test $rjk_cv_lib_$1_$2 = yes; then
63 $4
64 else
65 $5
66 fi
67])
68
69AC_DEFUN([RJK_REQUIRE_PCRE_UTF8],[
70 AC_CACHE_CHECK([whether libpcre was built with UTF-8 support],
71 [rjk_cv_pcre_utf8],[
72 save_LIBS="$LIBS"
73 LIBS="$LIBS $1"
74 AC_RUN_IFELSE([AC_LANG_PROGRAM([
75 #include <pcre.h>
76 #include <stdio.h>
77 ],
78 [
79 pcre *r;
80 const char *errptr;
81 int erroffset;
82
83 r = pcre_compile("\x80\x80", PCRE_UTF8,
84 &errptr, &erroffset, 0);
85 if(!r) {
86 fprintf(stderr, "pcre_compile: %s at %d",
87 errptr, erroffset);
88 exit(0);
89 } else {
90 fprintf(stderr, "accepted bogus UTF-8 string\n");
91 exit(1);
92 }
93 ])],
94 [rjk_cv_pcre_utf8=yes],
95 [rjk_cv_pcre_utf8=no],
e3426f7b 96 [AC_MSG_WARN([cross-compiling, cannot check libpcre behaviour])])
460b9539 97 LIBS="$save_LIBS"
98 ])
99 if test $rjk_cv_pcre_utf8 = no; then
100 AC_MSG_ERROR([please rebuild your pcre library with --enable-utf8])
101 fi
102])
1a00f590 103
16e4a580
MW
104AC_DEFUN([RJK_REQUIRE_PCRE2_UTF8],[
105 AC_CACHE_CHECK([whether libpcre2 was built with UTF-8 support],
106 [rjk_cv_pcre_utf8],[
107 save_CFLAGS="$CFLAGS" save_LIBS="$LIBS"
108 CFLAGS="$CFLAGS $1" LIBS="$LIBS $2"
109 AC_RUN_IFELSE([AC_LANG_PROGRAM([
110 #define PCRE2_CODE_UNIT_WIDTH 8
111 #include <pcre2.h>
112 #include <stdio.h>
113 ],
114 [
115 pcre2_code *r;
116 int errcode;
117 int erroffset;
118 char errbuf[[128]];
119
120 r = pcre2_compile("\x80\x80", 2, PCRE2_UTF,
121 &errcode, &erroffset, 0);
122 if(!r) {
123 pcre2_get_error_message(errcode, errbuf, sizeof(errbuf));
124 fprintf(stderr, "pcre2_compile: %s at %d",
125 errbuf, erroffset);
126 exit(0);
127 } else {
128 fprintf(stderr, "accepted bogus UTF-8 string\n");
129 exit(1);
130 }
131 ])],
132 [rjk_cv_pcre_utf8=yes],
133 [rjk_cv_pcre_utf8=no],
134 [AC_MSG_WARN([cross-compiling, cannot check libpcre2 behaviour])])
135 CFLAGS="$save_CFLAGS" LIBS="$save_LIBS"
136 ])
137 if test $rjk_cv_pcre_utf8 = no; then
138 AC_MSG_ERROR([please rebuild your pcre library with --enable-utf8])
139 fi
140])
141
1a00f590
RK
142AC_DEFUN([RJK_GCOV],[
143 GCOV=${GCOV:-true}
144 AC_ARG_WITH([gcov],
145 [AS_HELP_STRING([--with-gcov],
146 [Enable coverage testing])],
147 [if test $withval = yes; then
148 CFLAGS="${CFLAGS} -O0 -fprofile-arcs -ftest-coverage"
149 GCOV=`echo $CC | sed s'/gcc/gcov/;s/ .*$//'`;
150 fi])
151 AC_SUBST([GCOV],[$GCOV])
152])