1# Local additions to Autoconf macros. 2# Copyright (C) 1992, 1994 Free Software Foundation, Inc. 3# Francois Pinard <pinard@iro.umontreal.ca>, 1992. 4 5# NLS configuration macros added. 6# Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. 7 8# @defmac AC_PROG_CC_STDC 9# @maindex PROG_CC_STDC 10# @ovindex CC 11# If the C compiler in not in ANSI C mode by default, try to add an option 12# to output variable @code{CC} to make it so. This macro tries various 13# options that select ANSI C on some system or another. It considers the 14# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and 15# handles function prototypes correctly. 16# 17# If you use this macro, you should check after calling it whether the C 18# compiler has been set to accept ANSI C; if not, the shell variable 19# @code{ac_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source 20# code in ANSI C, you can make an un-ANSIfied copy of it by using the 21# program @code{ansi2knr}, which comes with Ghostscript. 22# @end defmac 23 24define(fp_PROG_CC_STDC, 25[AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) 26AC_CACHE_VAL(ac_cv_prog_cc_stdc, 27[ac_cv_prog_cc_stdc=no 28ac_save_CFLAGS="$CFLAGS" 29# Don't try gcc -ansi; that turns off useful extensions and 30# breaks some systems' header files. 31# AIX -qlanglvl=ansi 32# Ultrix and OSF/1 -std1 33# HP-UX -Aa -D_HPUX_SOURCE 34# SVR4 -Xc 35for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc 36do 37 CFLAGS="$ac_save_CFLAGS $ac_arg" 38 AC_TRY_COMPILE( 39[#if !defined(__STDC__) || __STDC__ != 1 40choke me 41#endif 42], [int test (int i, double x); 43struct s1 {int (*f) (int a);}; 44struct s2 {int (*f) (double a);};], 45[ac_cv_prog_cc_stdc="$ac_arg"; break]) 46done 47CFLAGS="$ac_save_CFLAGS" 48]) 49AC_MSG_RESULT($ac_cv_prog_cc_stdc) 50case "x$ac_cv_prog_cc_stdc" in 51 x|xno) ;; 52 *) CC="$CC $ac_cv_prog_cc_stdc" ;; 53esac 54]) 55 56# Check for function prototypes. 57 58AC_DEFUN(fp_C_PROTOTYPES, 59[AC_REQUIRE([fp_PROG_CC_STDC]) 60AC_MSG_CHECKING([for function prototypes]) 61if test "$ac_cv_prog_cc_stdc" != no; then 62 AC_MSG_RESULT(yes) 63 AC_DEFINE(PROTOTYPES) 64 U= ANSI2KNR= 65else 66 AC_MSG_RESULT(no) 67 U=_ ANSI2KNR=ansi2knr 68fi 69AC_SUBST(U)dnl 70AC_SUBST(ANSI2KNR)dnl 71]) 72 73# Check if --with-dmalloc was given. 74 75AC_DEFUN(fp_WITH_DMALLOC, 76[AC_MSG_CHECKING(if malloc debugging is wanted) 77AC_ARG_WITH(dmalloc, 78[ --with-dmalloc use dmalloc, as in dmalloc.tar.gz from 79 @/ftp.antaire.com:antaire/src/dmalloc.], 80[if test "$withval" = yes; then 81 AC_MSG_RESULT(yes) 82 AC_DEFINE(WITH_DMALLOC) 83 LIBS="$LIBS -ldmalloc" 84 LDFLAGS="$LDFLAGS -g" 85else 86 AC_MSG_RESULT(no) 87fi], [AC_MSG_RESULT(no)])]) 88 89dnl --------------------------------------------------------- ## 90dnl Use AC_PROG_INSTALL, supplementing it with INSTALL_SCRIPT ## 91dnl substitution. ## 92dnl --------------------------------------------------------- ## 93 94AC_DEFUN(fp_PROG_INSTALL, 95[AC_PROG_INSTALL 96test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL} -m 755' 97AC_SUBST(INSTALL_SCRIPT)dnl 98]) 99 100AC_DEFUN(md_PATH_PROG, 101 [AC_PATH_PROG($1,$2,$3)dnl 102 if echo $$1 | grep openwin > /dev/null; then 103 echo "WARNING: Do not use OpenWin's $2. (Better remove it.) >&AC_FD_MSG" 104 ac_cv_path_$1=$2 105 $1=$2 106 fi 107]) 108 109dnl Check NLS options 110 111AC_DEFUN(ud_LC_MESSAGES, 112 [if test $ac_cv_header_locale_h = yes; then 113 AC_MSG_CHECKING([for LC_MESSAGES]) 114 AC_CACHE_VAL(ud_cv_val_LC_MESSAGES, 115 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], 116 ud_cv_val_LC_MESSAGES=yes, ud_cv_val_LC_MESSAGES=no)]) 117 AC_MSG_RESULT($ud_cv_val_LC_MESSAGES) 118 if test $ud_cv_val_LC_MESSAGES = yes; then 119 AC_DEFINE(HAVE_LC_MESSAGES) 120 fi 121 fi]) 122 123AC_DEFUN(ud_WITH_NLS, 124 [AC_MSG_CHECKING([whether NLS is requested]) 125 dnl Default is enabled NLS 126 AC_ARG_ENABLE(nls, 127 [ --disable-nls do not use Native Language Support], 128 nls_cv_use_nls=$enableval, nls_cv_use_nls=yes) 129 AC_MSG_RESULT($nls_cv_use_nls) 130 131 dnl If we use NLS figure out what method 132 if test "$nls_cv_use_nls" = "yes"; then 133 AC_DEFINE(ENABLE_NLS) 134 AC_MSG_CHECKING([for explicitly using GNU gettext]) 135 AC_ARG_WITH(gnu-gettext, 136 [ --with-gnu-gettext use the GNU gettext library], 137 nls_cv_force_use_gnu_gettext=$withval, 138 nls_cv_force_use_gnu_gettext=no) 139 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) 140 141 if test "$nls_cv_force_use_gnu_gettext" = "yes"; then 142 nls_cv_use_gnu_gettext=yes 143 else 144 dnl User does not insist on using GNU NLS library. Figure out what 145 dnl to use. If gettext or catgets are available (in this order) we 146 dnl use this. Else we have to fall back to GNU NLS library. 147 AC_CHECK_LIB(intl, main) 148 AC_CHECK_LIB(i, main) 149 CATOBJEXT=NONE 150 AC_CHECK_FUNC(gettext, 151 [AC_DEFINE(HAVE_GETTEXT) 152 AC_PATH_PROG(MSGFMT, msgfmt, no)dnl 153 if test "$MSGFMT" != "no"; then 154 AC_CHECK_FUNCS(dcgettext) 155 md_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)dnl 156 md_PATH_PROG(XGETTEXT, xgettext, xgettext)dnl 157 CATOBJEXT=.mo 158 INSTOBJEXT=.mo 159 DATADIRNAME=lib 160 fi]) 161 162 if test "$CATOBJEXT" = "NONE"; then 163 dnl No gettext in C library. Try catgets next. 164 AC_CHECK_FUNC(catgets, 165 [AC_DEFINE(HAVE_CATGETS) 166 INTLOBJS="\$(CATOBJS)" 167 AC_PATH_PROG(GENCAT, gencat, no)dnl 168 if test "$GENCAT" != "no"; then 169 AC_PATH_PROGS(GMSGFMT, [gmsgfmt msgfmt], msgfmt)dnl 170 md_PATH_PROG(XGETTEXT, xgettext, xgettext)dnl 171 CATOBJEXT=.cat 172 INSTOBJEXT=.cat 173 DATADIRNAME=lib 174 INTLDEPS="../intl/libintl.a" 175 INTLLIBS=$INTLDEPS 176 LIBS=`echo $LIBS | sed -e 's/-lintl//'` 177 nls_cv_header_intl=intl/libintl.h 178 nls_cv_header_libgt=intl/libgettext.h 179 180 # We need to process the intl/ and po/ directory. 181 INTLSUB=intl 182 fi]) 183 fi 184 185 if test "$CATOBJEXT" = "NONE"; then 186 dnl Neither gettext nor catgets in included in the C library. 187 dnl Fall back on GNU gettext library. 188 nls_cv_use_gnu_gettext=yes 189 fi 190 fi 191 192 if test "$nls_cv_use_gnu_gettext" = "yes"; then 193 dnl Mark actions used to generate GNU NLS library. 194 INTLOBJS="\$(GETTOBJS)" 195 md_PATH_PROG(MSGFMT, msgfmt, msgfmt)dnl 196 md_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)dnl 197 md_PATH_PROG(XGETTEXT, xgettext, xgettext)dnl 198 AC_SUBST(MSGFMT) 199 CATOBJEXT=.gmo 200 INSTOBJEXT=.mo 201 DATADIRNAME=share 202 INTLDEPS="../intl/libintl.a" 203 INTLLIBS=$INTLDEPS 204 LIBS=`echo $LIBS | sed -e 's/-lintl//'` 205 nls_cv_header_intl=intl/libintl.h 206 nls_cv_header_libgt=intl/libgettext.h 207 208 # We need to process the intl/ directory. 209 INTLSUB=intl 210 fi 211 212 # We need to process the po/ directory. 213 POSUB=po 214 else 215 DATADIRNAME=share 216 nls_cv_header_intl=intl/libintl.h 217 nls_cv_header_libgt=intl/libgettext.h 218 fi 219 220 dnl These rules are solely for the distribution goal. While doing this 221 dnl we only have to keep exactly one list of the available catalogs 222 dnl in configure.in. 223 for lang in $ALL_LINGUAS; do 224 GMOFILES="$GMOFILES $lang.gmo" 225 POFILES="$POFILES $lang.po" 226 done 227 228 dnl Make all variables we use known to autoconf. 229 AC_SUBST(CATALOGS) 230 AC_SUBST(CATOBJEXT) 231 AC_SUBST(DATADIRNAME) 232 AC_SUBST(GMOFILES) 233 AC_SUBST(INSTOBJEXT) 234 AC_SUBST(INTLDEPS) 235 AC_SUBST(INTLLIBS) 236 AC_SUBST(INTLOBJS) 237 AC_SUBST(INTLSUB) 238 AC_SUBST(POFILES) 239 AC_SUBST(POSUB) 240 ]) 241 242AC_DEFUN(ud_GNU_GETTEXT, 243 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl 244 AC_REQUIRE([AC_PROG_CC])dnl 245 AC_REQUIRE([AC_PROG_RANLIB])dnl 246 AC_REQUIRE([AC_HEADER_STDC])dnl 247 AC_REQUIRE([AC_C_CONST])dnl 248 AC_REQUIRE([AC_C_INLINE])dnl 249 AC_REQUIRE([AC_TYPE_OFF_T])dnl 250 AC_REQUIRE([AC_TYPE_SIZE_T])dnl 251 AC_REQUIRE([AC_FUNC_ALLOCA])dnl 252 AC_REQUIRE([AC_FUNC_MMAP])dnl 253 254 AC_CHECK_HEADERS([limits.h locale.h nl_types.h malloc.h string.h unistd.h values.h]) 255 AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp]) 256 257 if test "${ac_cv_func_stpcpy+set}" != "set"; then 258 AC_CHECK_FUNCS(stpcpy) 259 fi 260 if test "${ac_cv_func_stpcpy}" = "yes"; then 261 AC_DEFINE(HAVE_STPCPY) 262 fi 263 264 ud_LC_MESSAGES 265 ud_WITH_NLS 266 267 if test "x$CATOBJEXT" != "x"; then 268 if test "x$ALL_LINGUAS" = "x"; then 269 LINGUAS= 270 else 271 AC_MSG_CHECKING(for catalogs to be installed) 272 NEW_LINGUAS= 273 for lang in ${LINGUAS=$ALL_LINGUAS}; do 274 case "$ALL_LINGUAS" in 275 *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; 276 esac 277 done 278 LINGUAS=$NEW_LINGUAS 279 AC_MSG_RESULT($LINGUAS) 280 fi 281 282 dnl Construct list of names of catalog files to be constructed. 283 if test -n "$LINGUAS"; then 284 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done 285 fi 286 fi 287 288 dnl Determine which catalog format we have (if any is needed) 289 dnl For now we know about two different formats: 290 dnl Linux and the normal X/Open format 291 test -d intl || mkdir intl 292 if test "$CATOBJEXT" = ".cat"; then 293 AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) 294 295 dnl Transform the SED scripts while copying because some dumb SEDs 296 dnl cannot handle comments. 297 sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed 298 fi 299 dnl po2tbl.sed is always needed. 300 sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ 301 $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed 302 303 dnl Generate list of files to be processed by xgettext which will 304 dnl be included in po/Makefile. 305 test -d po || mkdir po 306 if test "x$srcdir" != "x."; then 307 if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then 308 posrcprefix="$srcdir/" 309 else 310 posrcprefix="../$srcdir/" 311 fi 312 else 313 posrcprefix="../" 314 fi 315 sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ 316 < $srcdir/po/POTFILES.in > po/POTFILES 317 ]) 318