1dnl the FC_* macros were copied from the freeciv program. The use here 2dnl is to figure out if we need -DNARROWPROTO and the correct setting 3dnl for FUNCPROTO. Without these set right, it has been observed that 4dnl the sliders don't work right on some systems. 5 6 7dnl 8dnl FC_CHECK_X_PROTO_DEFINE(DEFINED-VARIABLE) 9dnl 10dnl This macro determines the value of the given defined 11dnl variable needed by Xfuncproto.h in order to compile correctly. 12dnl 13dnl Typical DEFINED-VARIABLEs are: 14dnl FUNCPROTO 15dnl NARROWPROTO 16dnl 17dnl The following variables are output: 18dnl fc_x_proto_value -- contains the value to which 19dnl the DEFINED-VARIABLE is set, 20dnl or "" if it has no known value. 21dnl 22dnl Example use: 23dnl FC_CHECK_X_PROTO_DEFINE(FUNCPROTO) 24dnl if test -n "$fc_x_proto_value"; then 25dnl AC_DEFINE_UNQUOTED(FUNCPROTO, $fc_x_proto_value) 26dnl fi 27dnl 28AC_DEFUN([FC_CHECK_X_PROTO_DEFINE], 29[AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])dnl 30AC_MSG_CHECKING(for Xfuncproto control definition $1) 31# Search for the requested defined variable; return it's value: 32fc_x_proto_value= 33for fc_x_define in $fc_x_proto_defines; do 34 fc_x_val=1 35 eval `echo $fc_x_define | sed -e 's/=/ ; fc_x_val=/' | sed -e 's/^/fc_x_var=/'` 36 if test "x$fc_x_var" = "x$1"; then 37 fc_x_proto_value=$fc_x_val 38 break 39 fi 40done 41if test -n "$fc_x_proto_value"; then 42 AC_MSG_RESULT([yes: $fc_x_proto_value]) 43else 44 AC_MSG_RESULT([no]) 45fi 46]) 47 48dnl FC_CHECK_X_PROTO_FETCH 49dnl 50dnl This macro fetches the Xfuncproto control definitions. 51dnl (Intended to be called once from FC_CHECK_X_PROTO_DEFINE.) 52dnl 53dnl The following variables are output: 54dnl fc_x_proto_defines -- contains the list of defines of 55dnl Xfuncproto control definitions 56dnl (defines may or may not include 57dnl the -D prefix, or an =VAL part). 58dnl 59dnl Example use: 60dnl AC_REQUIRE([FC_CHECK_X_PROTO_FETCH]) 61dnl 62AC_DEFUN([FC_CHECK_X_PROTO_FETCH], 63[AC_REQUIRE([AC_PATH_X])dnl 64AC_MSG_CHECKING(whether Xfuncproto was supplied) 65dnl May override determined defines with explicit argument: 66AC_ARG_WITH(x-funcproto, 67 [ --with-x-funcproto=DEFS Xfuncproto control definitions are DEFS 68 (e.g.: --with-x-funcproto='FUNCPROTO=15 NARROWPROTO']dnl 69) 70if test "x$with_x_funcproto" = "x"; then 71 fc_x_proto_defines= 72 rm -fr conftestdir 73 if mkdir conftestdir; then 74 cd conftestdir 75 # Make sure to not put "make" in the Imakefile rules, since we grep it out. 76 cat > Imakefile <<'EOF' 77fcfindpd: 78 @echo 'fc_x_proto_defines=" ${PROTO_DEFINES}"' 79EOF 80 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then 81 # GNU make sometimes prints "make[1]: Entering...", which would confuse us. 82 eval `${MAKE-make} fcfindpd 2>/dev/null | grep -v make | sed -e 's/ -D/ /g'` 83 AC_MSG_RESULT([no, found: $fc_x_proto_defines]) 84 cd .. 85 rm -fr conftestdir 86 else 87 dnl Oops -- no/bad xmkmf... Time to go a-guessing... 88 AC_MSG_RESULT([no]) 89 cd .. 90 rm -fr conftestdir 91 dnl First, guess something for FUNCPROTO: 92 AC_MSG_CHECKING([for compilable FUNCPROTO definition]) 93 dnl Try in order of preference... 94 for fc_x_value in 15 11 3 1 ""; do 95 FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value) 96 if test "x$fc_x_proto_FUNCPROTO" != "xno"; then 97 break 98 fi 99 done 100 if test "x$fc_x_proto_FUNCPROTO" != "xno"; then 101 fc_x_proto_defines="$fc_x_proto_defines FUNCPROTO=$fc_x_proto_FUNCPROTO" 102 AC_MSG_RESULT([yes, determined: $fc_x_proto_FUNCPROTO]) 103 else 104 AC_MSG_RESULT([no, cannot determine]) 105 fi 106 dnl Second, guess something for NARROWPROTO: 107 AC_MSG_CHECKING([for workable NARROWPROTO definition]) 108 dnl Try in order of preference... 109 for fc_x_value in 1 ""; do 110 FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value) 111 if test "x$fc_x_proto_NARROWPROTO" != "xno"; then 112 break 113 fi 114 done 115 if test "x$fc_x_proto_NARROWPROTO" != "xno"; then 116 fc_x_proto_defines="$fc_x_proto_defines NARROWPROTO=$fc_x_proto_NARROWPROTO" 117 AC_MSG_RESULT([yes, determined: $fc_x_proto_NARROWPROTO]) 118 else 119 AC_MSG_RESULT([no, cannot determine]) 120 fi 121 AC_MSG_CHECKING(whether Xfuncproto was determined) 122 if test -n "$fc_x_proto_defines"; then 123 AC_MSG_RESULT([yes: $fc_x_proto_defines]) 124 else 125 AC_MSG_RESULT([no]) 126 fi 127 fi 128 else 129 AC_MSG_RESULT([no, examination failed]) 130 fi 131else 132 fc_x_proto_defines=$with_x_funcproto 133 AC_MSG_RESULT([yes, given: $fc_x_proto_defines]) 134fi 135]) 136 137dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE(FUNCPROTO-VALUE) 138dnl 139dnl This macro determines whether or not Xfuncproto.h will 140dnl compile given a value to use for the FUNCPROTO definition. 141dnl 142dnl Typical FUNCPROTO-VALUEs are: 143dnl 15, 11, 3, 1, "" 144dnl 145dnl The following variables are output: 146dnl fc_x_proto_FUNCPROTO -- contains the passed-in 147dnl FUNCPROTO-VALUE if Xfuncproto.h 148dnl compiled, or "no" if it did not. 149dnl 150dnl Example use: 151dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value) 152dnl if test "x$fc_x_proto_FUNCPROTO" != "xno"; then 153dnl echo Compile using FUNCPROTO=$fc_x_proto_FUNCPROTO 154dnl fi 155dnl 156AC_DEFUN([FC_CHECK_X_PROTO_FUNCPROTO_COMPILE], 157[AC_REQUIRE([AC_PATH_XTRA])dnl 158AC_LANG_SAVE 159AC_LANG_C 160fc_x_proto_FUNCPROTO=no 161if test "x$1" = "x"; then 162 fc_x_compile="#undef FUNCPROTO" 163else 164 fc_x_compile="#define FUNCPROTO $1" 165fi 166fc_x_save_CFLAGS="$CFLAGS" 167CFLAGS="$CFLAGS $X_CFLAGS" 168AC_TRY_COMPILE([ 169$fc_x_compile 170#include <X11/Xfuncproto.h> 171 ],[ 172exit (0) 173 ], 174 [fc_x_proto_FUNCPROTO=$1]) 175CFLAGS="$fc_x_save_CFLAGS" 176AC_LANG_RESTORE 177]) 178 179dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS(NARROWPROTO-VALUE) 180dnl 181dnl This macro determines whether or not NARROWPROTO is required 182dnl to get a typical X function (XawScrollbarSetThumb) to work. 183dnl 184dnl Typical NARROWPROTO-VALUEs are: 185dnl 1, "" 186dnl 187dnl The following variables are required for input: 188dnl fc_x_proto_FUNCPROTO -- the value to use for FUNCPROTO. 189dnl 190dnl The following variables are output: 191dnl fc_x_proto_NARROWPROTO -- contains the passed-in 192dnl NARROWPROTO-VALUE if the test 193dnl worked, or "no" if it did not. 194dnl 195dnl Example use: 196dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value) 197dnl if test "x$fc_x_proto_NARROWPROTO" != "xno"; then 198dnl echo Compile using NARROWPROTO=$fc_x_proto_NARROWPROTO 199dnl fi 200dnl 201AC_DEFUN([FC_CHECK_X_PROTO_NARROWPROTO_WORKS], 202[AC_REQUIRE([AC_PATH_XTRA])dnl 203AC_LANG_SAVE 204AC_LANG_C 205fc_x_proto_NARROWPROTO=no 206if test "x$1" = "x"; then 207 fc_x_works="#undef NARROWPROTO" 208else 209 fc_x_works="#define NARROWPROTO $1" 210fi 211if test "x$fc_x_proto_FUNCPROTO" = "x"; then 212 fc_x_compile="#define FUNCPROTO 1" 213else 214 fc_x_compile="#define FUNCPROTO $fc_x_proto_FUNCPROTO" 215fi 216fc_x_save_CFLAGS="$CFLAGS" 217CFLAGS="$CFLAGS $X_CFLAGS $X_LIBS $X_PRE_LIBS -l$LIBXAW -lXt -lX11 $X_EXTRA_LIBS" 218AC_TRY_RUN([ 219$fc_x_works 220$fc_x_compile 221#include <X11/Xfuncproto.h> 222#include <X11/Intrinsic.h> 223#include <X11/StringDefs.h> 224#include <X11/$XAWINC/Scrollbar.h> 225#define TOP_VAL 0.125 226#define SHOWN_VAL 0.25 227int main (int argc, char ** argv) 228{ 229 Widget toplevel; 230 XtAppContext appcon; 231 Widget scrollbar; 232 double topbuf; 233 double shownbuf; 234 float * top = (float *)(&topbuf); 235 float * shown = (float *)(&shownbuf); 236 toplevel = 237 XtAppInitialize 238 ( 239 &appcon, 240 "FcXTest", 241 NULL, 0, 242 &argc, argv, 243 NULL, 244 NULL, 0 245 ); 246 scrollbar = 247 XtVaCreateManagedWidget 248 ( 249 "my_scrollbar", 250 scrollbarWidgetClass, 251 toplevel, 252 NULL 253 ); 254 XawScrollbarSetThumb (scrollbar, TOP_VAL, SHOWN_VAL); 255 XtVaGetValues 256 ( 257 scrollbar, 258 XtNtopOfThumb, top, 259 XtNshown, shown, 260 NULL 261 ); 262 if ((*top == TOP_VAL) && (*shown == SHOWN_VAL)) 263 { 264 exit (0); 265 } 266 else 267 { 268 exit (1); 269 } 270 return (0); 271} 272 ], 273 [fc_x_proto_NARROWPROTO=$1]) 274CFLAGS="$fc_x_save_CFLAGS" 275AC_LANG_RESTORE 276]) 277 278 279dnl ---------------------------------------------------------------- 280dnl From gcc's libiberty aclocal.m4 281 282dnl See whether we need a declaration for a function. 283AC_DEFUN([libiberty_NEED_DECLARATION], 284[AC_MSG_CHECKING([whether $1 must be declared]) 285AC_CACHE_VAL(libiberty_cv_decl_needed_$1, 286[AC_TRY_COMPILE([ 287#include "confdefs.h" 288#include <stdio.h> 289#ifdef HAVE_STRING_H 290#include <string.h> 291#else 292#ifdef HAVE_STRINGS_H 293#include <strings.h> 294#endif 295#endif 296#ifdef HAVE_STDLIB_H 297#include <stdlib.h> 298#endif 299#ifdef HAVE_UNISTD_H 300#include <unistd.h> 301#endif], 302[char *(*pfn) = (char *(*)) $1], 303libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)]) 304AC_MSG_RESULT($libiberty_cv_decl_needed_$1) 305if test $libiberty_cv_decl_needed_$1 = yes; then 306 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1, 307 [Define if $1 is not declared in system header files.]) 308fi 309])dnl 310 311 312dnl ---------------------------------------------------------------- 313dnl From http://autoconf-archive.cryp.to/adl_compute_relative_paths.html 314dnl and http://autoconf-archive.cryp.to/adl_normalize_path.html 315dnl 316dnl the adl_* functions which follow have the following copyright: 317dnl 318dnl Copyright � 2006 Alexandre Duret-Lutz <adl@gnu.org> 319 320dnl This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 321 322dnl This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 323 324dnl You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 325 326dnl As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts, even though portions of the text of the Macro appear in them. The GNU General Public License (GPL) does govern all other use of the material that constitutes the Autoconf Macro. 327 328dnl This special exception to the GPL applies to versions of the Autoconf Macro released by the Autoconf Macro Archive. When you make and distribute a modified version of the Autoconf Macro, you may extend this special exception to the GPL to apply to your modified version as well. 329 330AC_DEFUN([adl_NORMALIZE_PATH], 331[case ":[$]$1:" in 332# change empty paths to '.' 333 ::) $1='.' ;; 334# strip trailing slashes 335 :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;; 336 :*:) ;; 337esac 338# squeze repeated slashes 339case ifelse($2,,"[$]$1",$2) in 340# if the path contains any backslashes, turn slashes into backslashes 341 *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\\\\\,g'` ;; 342# if the path contains slashes, also turn backslashes into slashes 343 *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;; 344esac]) 345 346 347AC_DEFUN([adl_COMPUTE_RELATIVE_PATHS], 348[for _lcl_i in $1; do 349 _lcl_from=\[$]`echo "[$]_lcl_i" | sed 's,:.*$,,'` 350 _lcl_to=\[$]`echo "[$]_lcl_i" | sed 's,^[[^:]]*:,,' | sed 's,:[[^:]]*$,,'` 351 _lcl_result_var=`echo "[$]_lcl_i" | sed 's,^.*:,,'` 352 adl_RECURSIVE_EVAL([[$]_lcl_from], [_lcl_from]) 353 adl_RECURSIVE_EVAL([[$]_lcl_to], [_lcl_to]) 354 _lcl_notation="$_lcl_from$_lcl_to" 355 adl_NORMALIZE_PATH([_lcl_from],['/']) 356 adl_NORMALIZE_PATH([_lcl_to],['/']) 357 adl_COMPUTE_RELATIVE_PATH([_lcl_from], [_lcl_to], [_lcl_result_tmp]) 358 adl_NORMALIZE_PATH([_lcl_result_tmp],["[$]_lcl_notation"]) 359 eval $_lcl_result_var='[$]_lcl_result_tmp' 360done]) 361 362## Note: 363## ***** 364## The following helper macros are too fragile to be used out 365## of adl_COMPUTE_RELATIVE_PATHS (mainly because they assume that 366## paths are normalized), that's why I'm keeping them in the same file. 367## Still, some of them maybe worth to reuse. 368 369dnl adl_COMPUTE_RELATIVE_PATH(FROM, TO, RESULT) 370dnl =========================================== 371dnl Compute the relative path to go from $FROM to $TO and set the value 372dnl of $RESULT to that value. This function work on raw filenames 373dnl (for instead it will considerate /usr//local and /usr/local as 374dnl two distinct paths), you should really use adl_COMPUTE_REALTIVE_PATHS 375dnl instead to have the paths sanitized automatically. 376dnl 377dnl For instance: 378dnl first_dir=/somewhere/on/my/disk/bin 379dnl second_dir=/somewhere/on/another/disk/share 380dnl adl_COMPUTE_RELATIVE_PATH(first_dir, second_dir, first_to_second) 381dnl will set $first_to_second to '../../../another/disk/share'. 382AC_DEFUN([adl_COMPUTE_RELATIVE_PATH], 383[adl_COMPUTE_COMMON_PATH([$1], [$2], [_lcl_common_prefix]) 384adl_COMPUTE_BACK_PATH([$1], [_lcl_common_prefix], [_lcl_first_rel]) 385adl_COMPUTE_SUFFIX_PATH([$2], [_lcl_common_prefix], [_lcl_second_suffix]) 386$3="[$]_lcl_first_rel[$]_lcl_second_suffix"]) 387 388 389dnl adl_COMPUTE_COMMON_PATH(LEFT, RIGHT, RESULT) 390dnl ============================================ 391dnl Compute the common path to $LEFT and $RIGHT and set the result to $RESULT. 392dnl 393dnl For instance: 394dnl first_path=/somewhere/on/my/disk/bin 395dnl second_path=/somewhere/on/another/disk/share 396dnl adl_COMPUTE_COMMON_PATH(first_path, second_path, common_path) 397dnl will set $common_path to '/somewhere/on'. 398AC_DEFUN([adl_COMPUTE_COMMON_PATH], 399[$3='' 400_lcl_second_prefix_match='' 401while test "[$]_lcl_second_prefix_match" != 0; do 402 _lcl_first_prefix=`expr "x[$]$1" : "x\([$]$3/*[[^/]]*\)"` 403 _lcl_second_prefix_match=`expr "x[$]$2" : "x[$]_lcl_first_prefix"` 404 if test "[$]_lcl_second_prefix_match" != 0; then 405 if test "[$]_lcl_first_prefix" != "[$]$3"; then 406 $3="[$]_lcl_first_prefix" 407 else 408 _lcl_second_prefix_match=0 409 fi 410 fi 411done]) 412 413dnl adl_COMPUTE_SUFFIX_PATH(PATH, SUBPATH, RESULT) 414dnl ============================================== 415dnl Substrack $SUBPATH from $PATH, and set the resulting suffix 416dnl (or the empty string if $SUBPATH is not a subpath of $PATH) 417dnl to $RESULT. 418dnl 419dnl For instace: 420dnl first_path=/somewhere/on/my/disk/bin 421dnl second_path=/somewhere/on 422dnl adl_COMPUTE_SUFFIX_PATH(first_path, second_path, common_path) 423dnl will set $common_path to '/my/disk/bin'. 424AC_DEFUN([adl_COMPUTE_SUFFIX_PATH], 425[$3=`expr "x[$]$1" : "x[$]$2/*\(.*\)"`]) 426 427dnl adl_COMPUTE_BACK_PATH(PATH, SUBPATH, RESULT) 428dnl ============================================ 429dnl Compute the relative path to go from $PATH to $SUBPATH, knowing that 430dnl $SUBPATH is a subpath of $PATH (any other words, only repeated '../' 431dnl should be needed to move from $PATH to $SUBPATH) and set the value 432dnl of $RESULT to that value. If $SUBPATH is not a subpath of PATH, 433dnl set $RESULT to the empty string. 434dnl 435dnl For instance: 436dnl first_path=/somewhere/on/my/disk/bin 437dnl second_path=/somewhere/on 438dnl adl_COMPUTE_BACK_PATH(first_path, second_path, back_path) 439dnl will set $back_path to '../../../'. 440AC_DEFUN([adl_COMPUTE_BACK_PATH], 441[adl_COMPUTE_SUFFIX_PATH([$1], [$2], [_lcl_first_suffix]) 442$3='' 443_lcl_tmp='xxx' 444while test "[$]_lcl_tmp" != ''; do 445 _lcl_tmp=`expr "x[$]_lcl_first_suffix" : "x[[^/]]*/*\(.*\)"` 446 if test "[$]_lcl_first_suffix" != ''; then 447 _lcl_first_suffix="[$]_lcl_tmp" 448 $3="../[$]$3" 449 fi 450done]) 451 452 453dnl adl_RECURSIVE_EVAL(VALUE, RESULT) 454dnl ================================= 455dnl Interpolate the VALUE in loop until it doesn't change, 456dnl and set the result to $RESULT. 457dnl WARNING: It's easy to get an infinite loop with some unsane input. 458AC_DEFUN([adl_RECURSIVE_EVAL], 459[_lcl_receval="$1" 460$2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" 461 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" 462 _lcl_receval_old='' 463 while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do 464 _lcl_receval_old="[$]_lcl_receval" 465 eval _lcl_receval="\"[$]_lcl_receval\"" 466 done 467 echo "[$]_lcl_receval")`]) 468 469 470