3 dnl the FC_* macros were copied from the freeciv program. The use here
4 dnl is to figure out if we need -DNARROWPROTO and the correct setting
5 dnl for FUNCPROTO. Without these set right, it has been observed that
6 dnl the sliders don't work right on some systems.
10 dnl FC_CHECK_X_PROTO_DEFINE(DEFINED-VARIABLE)
12 dnl This macro determines the value of the given defined
13 dnl variable needed by Xfuncproto.h in order to compile correctly.
15 dnl Typical DEFINED-VARIABLEs are:
19 dnl The following variables are output:
20 dnl fc_x_proto_value -- contains the value to which
21 dnl the DEFINED-VARIABLE is set,
22 dnl or "" if it has no known value.
25 dnl FC_CHECK_X_PROTO_DEFINE(FUNCPROTO)
26 dnl if test -n "$fc_x_proto_value"; then
27 dnl AC_DEFINE_UNQUOTED(FUNCPROTO, $fc_x_proto_value)
30 AC_DEFUN([FC_CHECK_X_PROTO_DEFINE],
31 [AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])dnl
32 AC_MSG_CHECKING(for Xfuncproto control definition $1)
33 # Search for the requested defined variable; return it's value:
35 for fc_x_define in $fc_x_proto_defines; do
37 eval `echo $fc_x_define | sed -e 's/=/ ; fc_x_val=/' | sed -e 's/^/fc_x_var=/'`
38 if test "x$fc_x_var" = "x$1"; then
39 fc_x_proto_value=$fc_x_val
43 if test -n "$fc_x_proto_value"; then
44 AC_MSG_RESULT([yes: $fc_x_proto_value])
50 dnl FC_CHECK_X_PROTO_FETCH
52 dnl This macro fetches the Xfuncproto control definitions.
53 dnl (Intended to be called once from FC_CHECK_X_PROTO_DEFINE.)
55 dnl The following variables are output:
56 dnl fc_x_proto_defines -- contains the list of defines of
57 dnl Xfuncproto control definitions
58 dnl (defines may or may not include
59 dnl the -D prefix, or an =VAL part).
62 dnl AC_REQUIRE([FC_CHECK_X_PROTO_FETCH])
64 AC_DEFUN([FC_CHECK_X_PROTO_FETCH],
65 [AC_REQUIRE([AC_PATH_X])dnl
66 AC_MSG_CHECKING(whether Xfuncproto was supplied)
67 dnl May override determined defines with explicit argument:
68 AC_ARG_WITH(x-funcproto,
69 [ --with-x-funcproto=DEFS Xfuncproto control definitions are DEFS
70 (e.g.: --with-x-funcproto='FUNCPROTO=15 NARROWPROTO']dnl
72 if test "x$with_x_funcproto" = "x"; then
75 if mkdir conftestdir; then
77 # Make sure to not put "make" in the Imakefile rules, since we grep it out.
78 cat > Imakefile <<'EOF'
80 @echo 'fc_x_proto_defines=" ${PROTO_DEFINES}"'
82 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
83 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
84 eval `${MAKE-make} fcfindpd 2>/dev/null | grep -v make | sed -e 's/ -D/ /g'`
85 AC_MSG_RESULT([no, found: $fc_x_proto_defines])
89 dnl Oops -- no/bad xmkmf... Time to go a-guessing...
93 dnl First, guess something for FUNCPROTO:
94 AC_MSG_CHECKING([for compilable FUNCPROTO definition])
95 dnl Try in order of preference...
96 for fc_x_value in 15 11 3 1 ""; do
97 FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value)
98 if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
102 if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
103 fc_x_proto_defines="$fc_x_proto_defines FUNCPROTO=$fc_x_proto_FUNCPROTO"
104 AC_MSG_RESULT([yes, determined: $fc_x_proto_FUNCPROTO])
106 AC_MSG_RESULT([no, cannot determine])
108 dnl Second, guess something for NARROWPROTO:
109 AC_MSG_CHECKING([for workable NARROWPROTO definition])
110 dnl Try in order of preference...
111 for fc_x_value in 1 ""; do
112 FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value)
113 if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
117 if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
118 fc_x_proto_defines="$fc_x_proto_defines NARROWPROTO=$fc_x_proto_NARROWPROTO"
119 AC_MSG_RESULT([yes, determined: $fc_x_proto_NARROWPROTO])
121 AC_MSG_RESULT([no, cannot determine])
123 AC_MSG_CHECKING(whether Xfuncproto was determined)
124 if test -n "$fc_x_proto_defines"; then
125 AC_MSG_RESULT([yes: $fc_x_proto_defines])
131 AC_MSG_RESULT([no, examination failed])
134 fc_x_proto_defines=$with_x_funcproto
135 AC_MSG_RESULT([yes, given: $fc_x_proto_defines])
139 dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE(FUNCPROTO-VALUE)
141 dnl This macro determines whether or not Xfuncproto.h will
142 dnl compile given a value to use for the FUNCPROTO definition.
144 dnl Typical FUNCPROTO-VALUEs are:
147 dnl The following variables are output:
148 dnl fc_x_proto_FUNCPROTO -- contains the passed-in
149 dnl FUNCPROTO-VALUE if Xfuncproto.h
150 dnl compiled, or "no" if it did not.
153 dnl FC_CHECK_X_PROTO_FUNCPROTO_COMPILE($fc_x_value)
154 dnl if test "x$fc_x_proto_FUNCPROTO" != "xno"; then
155 dnl echo Compile using FUNCPROTO=$fc_x_proto_FUNCPROTO
158 AC_DEFUN([FC_CHECK_X_PROTO_FUNCPROTO_COMPILE],
159 [AC_REQUIRE([AC_PATH_XTRA])dnl
162 fc_x_proto_FUNCPROTO=no
163 if test "x$1" = "x"; then
164 fc_x_compile="#undef FUNCPROTO"
166 fc_x_compile="#define FUNCPROTO $1"
168 fc_x_save_CFLAGS="$CFLAGS"
169 CFLAGS="$CFLAGS $X_CFLAGS"
172 #include <X11/Xfuncproto.h>
176 [fc_x_proto_FUNCPROTO=$1])
177 CFLAGS="$fc_x_save_CFLAGS"
181 dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS(NARROWPROTO-VALUE)
183 dnl This macro determines whether or not NARROWPROTO is required
184 dnl to get a typical X function (XawScrollbarSetThumb) to work.
186 dnl Typical NARROWPROTO-VALUEs are:
189 dnl The following variables are required for input:
190 dnl fc_x_proto_FUNCPROTO -- the value to use for FUNCPROTO.
192 dnl The following variables are output:
193 dnl fc_x_proto_NARROWPROTO -- contains the passed-in
194 dnl NARROWPROTO-VALUE if the test
195 dnl worked, or "no" if it did not.
198 dnl FC_CHECK_X_PROTO_NARROWPROTO_WORKS($fc_x_value)
199 dnl if test "x$fc_x_proto_NARROWPROTO" != "xno"; then
200 dnl echo Compile using NARROWPROTO=$fc_x_proto_NARROWPROTO
203 AC_DEFUN([FC_CHECK_X_PROTO_NARROWPROTO_WORKS],
204 [AC_REQUIRE([AC_PATH_XTRA])dnl
207 fc_x_proto_NARROWPROTO=no
208 if test "x$1" = "x"; then
209 fc_x_works="#undef NARROWPROTO"
211 fc_x_works="#define NARROWPROTO $1"
213 if test "x$fc_x_proto_FUNCPROTO" = "x"; then
214 fc_x_compile="#define FUNCPROTO 1"
216 fc_x_compile="#define FUNCPROTO $fc_x_proto_FUNCPROTO"
218 fc_x_save_CFLAGS="$CFLAGS"
219 CFLAGS="$CFLAGS $X_CFLAGS $X_LIBS $X_PRE_LIBS -l$LIBXAW -lXt -lX11 $X_EXTRA_LIBS"
223 #include <X11/Xfuncproto.h>
224 #include <X11/Intrinsic.h>
225 #include <X11/StringDefs.h>
226 #include <X11/$XAWINC/Scrollbar.h>
227 #define TOP_VAL 0.125
228 #define SHOWN_VAL 0.25
229 int main (int argc, char ** argv)
236 float * top = (float *)(&topbuf);
237 float * shown = (float *)(&shownbuf);
249 XtVaCreateManagedWidget
252 scrollbarWidgetClass,
256 XawScrollbarSetThumb (scrollbar, TOP_VAL, SHOWN_VAL);
264 if ((*top == TOP_VAL) && (*shown == SHOWN_VAL))
275 [fc_x_proto_NARROWPROTO=$1])
276 CFLAGS="$fc_x_save_CFLAGS"
281 dnl ----------------------------------------------------------------
282 dnl From gcc's libiberty aclocal.m4
284 dnl See whether we need a declaration for a function.
285 AC_DEFUN([libiberty_NEED_DECLARATION],
286 [AC_MSG_CHECKING([whether $1 must be declared])
287 AC_CACHE_VAL(libiberty_cv_decl_needed_$1,
289 #include "confdefs.h"
294 #ifdef HAVE_STRINGS_H
304 [char *(*pfn) = (char *(*)) $1],
305 libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)])
306 AC_MSG_RESULT($libiberty_cv_decl_needed_$1)
307 if test $libiberty_cv_decl_needed_$1 = yes; then
308 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
309 [Define if $1 is not declared in system header files.])
314 dnl ----------------------------------------------------------------
315 dnl From http://autoconf-archive.cryp.to/adl_compute_relative_paths.html
316 dnl and http://autoconf-archive.cryp.to/adl_normalize_path.html
318 dnl the adl_* functions which follow have the following copyright:
320 dnl Copyright © 2006 Alexandre Duret-Lutz <adl@gnu.org>
322 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.
324 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.
326 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.
328 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.
330 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.
332 AC_DEFUN([adl_NORMALIZE_PATH],
334 # change empty paths to '.'
336 # strip trailing slashes
337 :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
340 # squeze repeated slashes
341 case ifelse($2,,"[$]$1",$2) in
342 # if the path contains any backslashes, turn slashes into backslashes
343 *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\\\\\,g'` ;;
344 # if the path contains slashes, also turn backslashes into slashes
345 *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;;
349 AC_DEFUN([adl_COMPUTE_RELATIVE_PATHS],
350 [for _lcl_i in $1; do
351 _lcl_from=\[$]`echo "[$]_lcl_i" | sed 's,:.*$,,'`
352 _lcl_to=\[$]`echo "[$]_lcl_i" | sed 's,^[[^:]]*:,,' | sed 's,:[[^:]]*$,,'`
353 _lcl_result_var=`echo "[$]_lcl_i" | sed 's,^.*:,,'`
354 adl_RECURSIVE_EVAL([[$]_lcl_from], [_lcl_from])
355 adl_RECURSIVE_EVAL([[$]_lcl_to], [_lcl_to])
356 _lcl_notation="$_lcl_from$_lcl_to"
357 adl_NORMALIZE_PATH([_lcl_from],['/'])
358 adl_NORMALIZE_PATH([_lcl_to],['/'])
359 adl_COMPUTE_RELATIVE_PATH([_lcl_from], [_lcl_to], [_lcl_result_tmp])
360 adl_NORMALIZE_PATH([_lcl_result_tmp],["[$]_lcl_notation"])
361 eval $_lcl_result_var='[$]_lcl_result_tmp'
366 ## The following helper macros are too fragile to be used out
367 ## of adl_COMPUTE_RELATIVE_PATHS (mainly because they assume that
368 ## paths are normalized), that's why I'm keeping them in the same file.
369 ## Still, some of them maybe worth to reuse.
371 dnl adl_COMPUTE_RELATIVE_PATH(FROM, TO, RESULT)
372 dnl ===========================================
373 dnl Compute the relative path to go from $FROM to $TO and set the value
374 dnl of $RESULT to that value. This function work on raw filenames
375 dnl (for instead it will considerate /usr//local and /usr/local as
376 dnl two distinct paths), you should really use adl_COMPUTE_REALTIVE_PATHS
377 dnl instead to have the paths sanitized automatically.
380 dnl first_dir=/somewhere/on/my/disk/bin
381 dnl second_dir=/somewhere/on/another/disk/share
382 dnl adl_COMPUTE_RELATIVE_PATH(first_dir, second_dir, first_to_second)
383 dnl will set $first_to_second to '../../../another/disk/share'.
384 AC_DEFUN([adl_COMPUTE_RELATIVE_PATH],
385 [adl_COMPUTE_COMMON_PATH([$1], [$2], [_lcl_common_prefix])
386 adl_COMPUTE_BACK_PATH([$1], [_lcl_common_prefix], [_lcl_first_rel])
387 adl_COMPUTE_SUFFIX_PATH([$2], [_lcl_common_prefix], [_lcl_second_suffix])
388 $3="[$]_lcl_first_rel[$]_lcl_second_suffix"])
391 dnl adl_COMPUTE_COMMON_PATH(LEFT, RIGHT, RESULT)
392 dnl ============================================
393 dnl Compute the common path to $LEFT and $RIGHT and set the result to $RESULT.
396 dnl first_path=/somewhere/on/my/disk/bin
397 dnl second_path=/somewhere/on/another/disk/share
398 dnl adl_COMPUTE_COMMON_PATH(first_path, second_path, common_path)
399 dnl will set $common_path to '/somewhere/on'.
400 AC_DEFUN([adl_COMPUTE_COMMON_PATH],
402 _lcl_second_prefix_match=''
403 while test "[$]_lcl_second_prefix_match" != 0; do
404 _lcl_first_prefix=`expr "x[$]$1" : "x\([$]$3/*[[^/]]*\)"`
405 _lcl_second_prefix_match=`expr "x[$]$2" : "x[$]_lcl_first_prefix"`
406 if test "[$]_lcl_second_prefix_match" != 0; then
407 if test "[$]_lcl_first_prefix" != "[$]$3"; then
408 $3="[$]_lcl_first_prefix"
410 _lcl_second_prefix_match=0
415 dnl adl_COMPUTE_SUFFIX_PATH(PATH, SUBPATH, RESULT)
416 dnl ==============================================
417 dnl Substrack $SUBPATH from $PATH, and set the resulting suffix
418 dnl (or the empty string if $SUBPATH is not a subpath of $PATH)
422 dnl first_path=/somewhere/on/my/disk/bin
423 dnl second_path=/somewhere/on
424 dnl adl_COMPUTE_SUFFIX_PATH(first_path, second_path, common_path)
425 dnl will set $common_path to '/my/disk/bin'.
426 AC_DEFUN([adl_COMPUTE_SUFFIX_PATH],
427 [$3=`expr "x[$]$1" : "x[$]$2/*\(.*\)"`])
429 dnl adl_COMPUTE_BACK_PATH(PATH, SUBPATH, RESULT)
430 dnl ============================================
431 dnl Compute the relative path to go from $PATH to $SUBPATH, knowing that
432 dnl $SUBPATH is a subpath of $PATH (any other words, only repeated '../'
433 dnl should be needed to move from $PATH to $SUBPATH) and set the value
434 dnl of $RESULT to that value. If $SUBPATH is not a subpath of PATH,
435 dnl set $RESULT to the empty string.
438 dnl first_path=/somewhere/on/my/disk/bin
439 dnl second_path=/somewhere/on
440 dnl adl_COMPUTE_BACK_PATH(first_path, second_path, back_path)
441 dnl will set $back_path to '../../../'.
442 AC_DEFUN([adl_COMPUTE_BACK_PATH],
443 [adl_COMPUTE_SUFFIX_PATH([$1], [$2], [_lcl_first_suffix])
446 while test "[$]_lcl_tmp" != ''; do
447 _lcl_tmp=`expr "x[$]_lcl_first_suffix" : "x[[^/]]*/*\(.*\)"`
448 if test "[$]_lcl_first_suffix" != ''; then
449 _lcl_first_suffix="[$]_lcl_tmp"
455 dnl adl_RECURSIVE_EVAL(VALUE, RESULT)
456 dnl =================================
457 dnl Interpolate the VALUE in loop until it doesn't change,
458 dnl and set the result to $RESULT.
459 dnl WARNING: It's easy to get an infinite loop with some unsane input.
460 AC_DEFUN([adl_RECURSIVE_EVAL],
462 $2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix"
463 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
465 while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
466 _lcl_receval_old="[$]_lcl_receval"
467 eval _lcl_receval="\"[$]_lcl_receval\""
469 echo "[$]_lcl_receval")`])