1 dnl the FC_* macros were copied from the freeciv program. The use here
2 dnl is to figure out if we need -DNARROWPROTO and the correct setting
3 dnl for FUNCPROTO. Without these set right, it has been observed that
4 dnl the sliders don't work right on some systems.
8 dnl FC_CHECK_X_PROTO_DEFINE(DEFINED-VARIABLE)
10 dnl This macro determines the value of the given defined
11 dnl variable needed by Xfuncproto.h in order to compile correctly.
13 dnl Typical DEFINED-VARIABLEs are:
17 dnl The following variables are output:
18 dnl fc_x_proto_value -- contains the value to which
19 dnl the DEFINED-VARIABLE is set,
20 dnl or "" if it has no known value.
23 dnl FC_CHECK_X_PROTO_DEFINE(FUNCPROTO)
24 dnl if test -n "$fc_x_proto_value"; then
25 dnl AC_DEFINE_UNQUOTED(FUNCPROTO, $fc_x_proto_value)
28 AC_DEFUN([FC_CHECK_X_PROTO_DEFINE],
29 [AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])dnl
30 AC_MSG_CHECKING(for Xfuncproto control definition $1)
31 # Search for the requested defined variable; return it's value:
33 for fc_x_define in $fc_x_proto_defines; do
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
41 if test -n "$fc_x_proto_value"; then
42 AC_MSG_RESULT([yes: $fc_x_proto_value])
48 dnl FC_CHECK_X_PROTO_FETCH
50 dnl This macro fetches the Xfuncproto control definitions.
51 dnl (Intended to be called once from FC_CHECK_X_PROTO_DEFINE.)
53 dnl The following variables are output:
54 dnl fc_x_proto_defines -- contains the list of defines of
55 dnl Xfuncproto control definitions
56 dnl (defines may or may not include
57 dnl the -D prefix, or an =VAL part).
60 dnl AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])
62 AC_DEFUN([FC_CHECK_X_PROTO_FETCH],
63 [AC_REQUIRE([AC_PATH_X])dnl
64 AC_MSG_CHECKING(whether Xfuncproto was supplied)
65 dnl May override determined defines with explicit argument:
66 AC_ARG_WITH(x-funcproto,
67 [ --with-x-funcproto=DEFS Xfuncproto control definitions are DEFS
68 (e.g.: --with-x-funcproto='FUNCPROTO=15 NARROWPROTO']dnl
70 if test "x$with_x_funcproto" = "x"; then
73 if mkdir conftestdir; then
75 # Make sure to not put "make" in the Imakefile rules, since we grep it out.
76 cat > Imakefile <<'EOF'
78 @echo 'fc_x_proto_defines=" ${PROTO_DEFINES}"'
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])
87 dnl Oops -- no/bad xmkmf... Time to go a-guessing...
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
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])
104 AC_MSG_RESULT([no, cannot determine])
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
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])
119 AC_MSG_RESULT([no, cannot determine])
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])
129 AC_MSG_RESULT([no, examination failed])
132 fc_x_proto_defines=$with_x_funcproto
133 AC_MSG_RESULT([yes, given: $fc_x_proto_defines])
137 dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE(FUNCPROTO-VALUE)
139 dnl This macro determines whether or not Xfuncproto.h will
140 dnl compile given a value to use for the FUNCPROTO definition.
142 dnl Typical FUNCPROTO-VALUEs are:
145 dnl The following variables are output:
146 dnl fc_x_proto_FUNCPROTO -- contains the passed-in
147 dnl FUNCPROTO-VALUE if Xfuncproto.h
148 dnl compiled, or "no" if it did not.
151 dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value)
152 dnl if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
153 dnl echo Compile using FUNCPROTO=$fc_x_proto_FUNCPROTO
156 AC_DEFUN([FC_CHECK_X_PROTO_FUNCPROTO_COMPILE],
157 [AC_REQUIRE([AC_PATH_XTRA])dnl
160 fc_x_proto_FUNCPROTO=no
161 if test "x$1" = "x"; then
162 fc_x_compile="#undef FUNCPROTO"
164 fc_x_compile="#define FUNCPROTO $1"
166 fc_x_save_CFLAGS="$CFLAGS"
167 CFLAGS="$CFLAGS $X_CFLAGS"
170 #include <X11/Xfuncproto.h>
174 [fc_x_proto_FUNCPROTO=$1])
175 CFLAGS="$fc_x_save_CFLAGS"
179 dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS(NARROWPROTO-VALUE)
181 dnl This macro determines whether or not NARROWPROTO is required
182 dnl to get a typical X function (XawScrollbarSetThumb) to work.
184 dnl Typical NARROWPROTO-VALUEs are:
187 dnl The following variables are required for input:
188 dnl fc_x_proto_FUNCPROTO -- the value to use for FUNCPROTO.
190 dnl The following variables are output:
191 dnl fc_x_proto_NARROWPROTO -- contains the passed-in
192 dnl NARROWPROTO-VALUE if the test
193 dnl worked, or "no" if it did not.
196 dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value)
197 dnl if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
198 dnl echo Compile using NARROWPROTO=$fc_x_proto_NARROWPROTO
201 AC_DEFUN([FC_CHECK_X_PROTO_NARROWPROTO_WORKS],
202 [AC_REQUIRE([AC_PATH_XTRA])dnl
205 fc_x_proto_NARROWPROTO=no
206 if test "x$1" = "x"; then
207 fc_x_works="#undef NARROWPROTO"
209 fc_x_works="#define NARROWPROTO $1"
211 if test "x$fc_x_proto_FUNCPROTO" = "x"; then
212 fc_x_compile="#define FUNCPROTO 1"
214 fc_x_compile="#define FUNCPROTO $fc_x_proto_FUNCPROTO"
216 fc_x_save_CFLAGS="$CFLAGS"
217 CFLAGS="$CFLAGS $X_CFLAGS $X_LIBS $X_PRE_LIBS -l$LIBXAW -lXt -lX11 $X_EXTRA_LIBS"
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
227 int main (int argc, char ** argv)
234 float * top = (float *)(&topbuf);
235 float * shown = (float *)(&shownbuf);
247 XtVaCreateManagedWidget
250 scrollbarWidgetClass,
254 XawScrollbarSetThumb (scrollbar, TOP_VAL, SHOWN_VAL);
262 if ((*top == TOP_VAL) && (*shown == SHOWN_VAL))
273 [fc_x_proto_NARROWPROTO=$1])
274 CFLAGS="$fc_x_save_CFLAGS"
279 dnl ----------------------------------------------------------------
280 dnl From gcc's libiberty aclocal.m4
282 dnl See whether we need a declaration for a function.
283 AC_DEFUN([libiberty_NEED_DECLARATION],
284 [AC_MSG_CHECKING([whether $1 must be declared])
285 AC_CACHE_VAL(libiberty_cv_decl_needed_$1,
287 #include "confdefs.h"
292 #ifdef HAVE_STRINGS_H
302 [char *(*pfn) = (char *(*)) $1],
303 libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)])
304 AC_MSG_RESULT($libiberty_cv_decl_needed_$1)
305 if 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.])
312 dnl ----------------------------------------------------------------
313 dnl From http://autoconf-archive.cryp.to/adl_compute_relative_paths.html
314 dnl and http://autoconf-archive.cryp.to/adl_normalize_path.html
316 dnl the adl_* functions which follow have the following copyright:
318 dnl Copyright © 2006 Alexandre Duret-Lutz <adl@gnu.org>
320 dnl 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.
322 dnl 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.
324 dnl 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.
326 dnl 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.
328 dnl 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.
330 AC_DEFUN([adl_NORMALIZE_PATH],
332 # change empty paths to '.'
334 # strip trailing slashes
335 :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
338 # squeze repeated slashes
339 case 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'` ;;
347 AC_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'
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.
369 dnl adl_COMPUTE_RELATIVE_PATH(FROM, TO, RESULT)
370 dnl ===========================================
371 dnl Compute the relative path to go from $FROM to $TO and set the value
372 dnl of $RESULT to that value. This function work on raw filenames
373 dnl (for instead it will considerate /usr//local and /usr/local as
374 dnl two distinct paths), you should really use adl_COMPUTE_REALTIVE_PATHS
375 dnl instead to have the paths sanitized automatically.
378 dnl first_dir=/somewhere/on/my/disk/bin
379 dnl second_dir=/somewhere/on/another/disk/share
380 dnl adl_COMPUTE_RELATIVE_PATH(first_dir, second_dir, first_to_second)
381 dnl will set $first_to_second to '../../../another/disk/share'.
382 AC_DEFUN([adl_COMPUTE_RELATIVE_PATH],
383 [adl_COMPUTE_COMMON_PATH([$1], [$2], [_lcl_common_prefix])
384 adl_COMPUTE_BACK_PATH([$1], [_lcl_common_prefix], [_lcl_first_rel])
385 adl_COMPUTE_SUFFIX_PATH([$2], [_lcl_common_prefix], [_lcl_second_suffix])
386 $3="[$]_lcl_first_rel[$]_lcl_second_suffix"])
389 dnl adl_COMPUTE_COMMON_PATH(LEFT, RIGHT, RESULT)
390 dnl ============================================
391 dnl Compute the common path to $LEFT and $RIGHT and set the result to $RESULT.
394 dnl first_path=/somewhere/on/my/disk/bin
395 dnl second_path=/somewhere/on/another/disk/share
396 dnl adl_COMPUTE_COMMON_PATH(first_path, second_path, common_path)
397 dnl will set $common_path to '/somewhere/on'.
398 AC_DEFUN([adl_COMPUTE_COMMON_PATH],
400 _lcl_second_prefix_match=''
401 while 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"
408 _lcl_second_prefix_match=0
413 dnl adl_COMPUTE_SUFFIX_PATH(PATH, SUBPATH, RESULT)
414 dnl ==============================================
415 dnl Substrack $SUBPATH from $PATH, and set the resulting suffix
416 dnl (or the empty string if $SUBPATH is not a subpath of $PATH)
420 dnl first_path=/somewhere/on/my/disk/bin
421 dnl second_path=/somewhere/on
422 dnl adl_COMPUTE_SUFFIX_PATH(first_path, second_path, common_path)
423 dnl will set $common_path to '/my/disk/bin'.
424 AC_DEFUN([adl_COMPUTE_SUFFIX_PATH],
425 [$3=`expr "x[$]$1" : "x[$]$2/*\(.*\)"`])
427 dnl adl_COMPUTE_BACK_PATH(PATH, SUBPATH, RESULT)
428 dnl ============================================
429 dnl Compute the relative path to go from $PATH to $SUBPATH, knowing that
430 dnl $SUBPATH is a subpath of $PATH (any other words, only repeated '../'
431 dnl should be needed to move from $PATH to $SUBPATH) and set the value
432 dnl of $RESULT to that value. If $SUBPATH is not a subpath of PATH,
433 dnl set $RESULT to the empty string.
436 dnl first_path=/somewhere/on/my/disk/bin
437 dnl second_path=/somewhere/on
438 dnl adl_COMPUTE_BACK_PATH(first_path, second_path, back_path)
439 dnl will set $back_path to '../../../'.
440 AC_DEFUN([adl_COMPUTE_BACK_PATH],
441 [adl_COMPUTE_SUFFIX_PATH([$1], [$2], [_lcl_first_suffix])
444 while 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"
453 dnl adl_RECURSIVE_EVAL(VALUE, RESULT)
454 dnl =================================
455 dnl Interpolate the VALUE in loop until it doesn't change,
456 dnl and set the result to $RESULT.
457 dnl WARNING: It's easy to get an infinite loop with some unsane input.
458 AC_DEFUN([adl_RECURSIVE_EVAL],
460 $2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix"
461 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
463 while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
464 _lcl_receval_old="[$]_lcl_receval"
465 eval _lcl_receval="\"[$]_lcl_receval\""
467 echo "[$]_lcl_receval")`])