fix remapping behavior. Remapping is only necessary if we are rendering on the workbe...
[AROS-Contrib.git] / arospdf / aclocal.m4
blobb3aeea2fda6f539fe736fc9fed80730f6effac4e
1 # <<< smr.m4 from smr_macros 0.2.4 >>>
3 dnl ####################### -*- Mode: M4 -*- ###########################
4 dnl smr.m4 -- 
5 dnl 
6 dnl Copyright (C) 1999 Matthew D. Langston <langston@SLAC.Stanford.EDU>
7 dnl Copyright (C) 1998 Steve Robbins <stever@cs.mcgill.ca>
8 dnl
9 dnl This file is free software; you can redistribute it and/or modify it
10 dnl under the terms of the GNU General Public License as published by
11 dnl the Free Software Foundation; either version 2 of the License, or
12 dnl (at your option) any later version.
13 dnl
14 dnl This file is distributed in the hope that it will be useful, but
15 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 dnl General Public License for more details.
18 dnl
19 dnl You should have received a copy of the GNU General Public License
20 dnl along with this file; if not, write to:
21 dnl
22 dnl   Free Software Foundation, Inc.
23 dnl   Suite 330
24 dnl   59 Temple Place
25 dnl   Boston, MA 02111-1307, USA.
26 dnl ####################################################################
29 dnl NOTE: The macros in this file are extensively documented in the
30 dnl       accompanying `smr_macros.texi' Texinfo file.  Please see the
31 dnl       Texinfo documentation for the definitive specification of how
32 dnl       these macros are supposed to work.  If the macros work
33 dnl       differently than the Texinfo documentation says they should,
34 dnl       then the macros (and not the Texinfo documentation) has the
35 dnl       bug(s).
37 dnl This is a convenient macro which translates illegal characters for
38 dnl bourne shell variables into legal characters.  It has the same
39 dnl functionality as sed 'y%./+-:%__p__%'.
40 AC_DEFUN([smr_safe_translation], [patsubst(patsubst([$1], [+], [p]), [./-:], [_])])
42 AC_DEFUN(smr_SWITCH,
44   dnl Define convenient aliases for the arguments since there are so
45   dnl many of them and I keep confusing myself whenever I have to edit
46   dnl this macro.
47   pushdef([smr_name],        $1)
48   pushdef([smr_help_string], $2)
49   pushdef([smr_default],     $3)
50   pushdef([smr_yes_define],  $4)
51   pushdef([smr_no_define],   $5)
53   dnl Do some sanity checking of the arguments.
54   ifelse([regexp(smr_default, [^\(yes\|no\)$])], -1, [AC_MSG_ERROR($0: third arg must be either yes or no)])
56   dnl Create the help string
57   pushdef([smr_lhs], [--ifelse(smr_default, yes, disable, enable)-smr_name])dnl
58   pushdef([smr_rhs], [ifelse(smr_default, yes, disable, enable) smr_help_string (default is smr_default)])dnl
60   dnl Add the option to `configure --help'.  We don't need to supply the
61   dnl 4th argument to AC_ARG_ENABLE (i.e. the code to set the default
62   dnl value) because that is done below by AC_CACHE_CHECK.
63   AC_ARG_ENABLE([smr_name],
64                 AC_HELP_STRING([smr_lhs], [smr_rhs]),
65                 smr_cv_enable_[]smr_name=$enableval)
67   dnl We cache the result so that the user doesn't have to remember
68   dnl which flags they passed to `configure'.
69   AC_CACHE_CHECK([whether to enable smr_help_string],
70                  smr_cv_enable_[]smr_name,
71                  smr_cv_enable_[]smr_name=smr_default)
73     ifelse(smr_yes_define, , , test x"[$]smr_cv_enable_[]smr_name" = xyes && AC_DEFINE(smr_yes_define))
74     ifelse(smr_no_define, , ,  test x"[$]smr_cv_enable_[]smr_name" = xno  && AC_DEFINE(smr_no_define))
76   dnl Sanity check the value assigned to smr_cv_enable_$1 to force it to
77   dnl be either `yes' or `no'.
78   if test ! x"[$]smr_cv_enable_[]smr_name" = xyes; then
79     if test ! x"[$]smr_cv_enable_[]smr_name" = xno; then
80       AC_MSG_ERROR([smr_lhs must be either yes or no])
81     fi
82   fi
84   popdef([smr_name])
85   popdef([smr_help_string])
86   popdef([smr_default])
87   popdef([smr_yes_define])
88   popdef([smr_no_define])
89   popdef([smr_lhs])
90   popdef([smr_rhs])
94 AC_DEFUN(smr_ARG_WITHLIB,
96   dnl Define convenient aliases for the arguments since there are so
97   dnl many of them and I keep confusing myself whenever I have to edit
98   dnl this macro.
99   pushdef([smr_name],        $1)
100   pushdef([smr_libname],     ifelse($2, , smr_name, $2))
101   pushdef([smr_help_string], $3)
102   pushdef([smr_safe_name],   smr_safe_translation(smr_name))
104   dnl Add the option to `configure --help'.  We don't need to supply the
105   dnl 4th argument to AC_ARG_WITH (i.e. the code to set the default
106   dnl value) because that is done below by AC_CACHE_CHECK.
107   AC_ARG_WITH(smr_safe_name-library,
108               AC_HELP_STRING([--with-smr_safe_name-library[[=PATH]]],
109                              [use smr_name library ifelse(smr_help_string, , , (smr_help_string))]),
110               smr_cv_with_[]smr_safe_name[]_library=$withval)
112   dnl We cache the result so that the user doesn't have to remember
113   dnl which flags they passed to `configure'.
114   AC_CACHE_CHECK([whether to use smr_name library],
115                  smr_cv_with_[]smr_safe_name[]_library,
116                  smr_cv_with_[]smr_safe_name[]_library=maybe)
119   case x"[$]smr_cv_with_[]smr_safe_name[]_library" in
120       xyes | xmaybe)
121           smr_safe_name[]_LIBS="-l[]smr_libname"
122           with_[]smr_safe_name=[$]smr_cv_with_[]smr_safe_name[]_library
123           ;;
124       xno)
125           smr_safe_name[]_LIBS=
126           with_[]smr_safe_name=no
127           ;;
128       *)
129           if test -f "[$]smr_cv_with_[]smr_safe_name[]_library"; then
130             smr_safe_name[]_LIBS=[$]smr_cv_with_[]smr_safe_name[]_library
131           elif test -d "[$]smr_cv_with_[]smr_safe_name[]_library"; then
132             smr_safe_name[]_LIBS="-L[$]smr_cv_with_[]smr_safe_name[]_library -l[]smr_libname"
133           else
134             AC_MSG_ERROR([argument must be boolean, file, or directory])
135           fi
136           with_[]smr_safe_name=yes
137           ;;
138   esac
140   popdef([smr_name])
141   popdef([smr_libname])
142   popdef([smr_help_string])
143   popdef([smr_safe_name])
147 AC_DEFUN(smr_ARG_WITHINCLUDES,
149   dnl Define convenient aliases for the arguments since there are so
150   dnl many of them and I keep confusing myself whenever I have to edit
151   dnl this macro.
152   pushdef([smr_name],        $1)
153   pushdef([smr_header],      $2)
154   pushdef([smr_extra_flags], $3)
155   pushdef([smr_safe_name],   smr_safe_translation(smr_name))
157   dnl Add the option to `configure --help'.  We don't need to supply the
158   dnl 4th argument to AC_ARG_WITH (i.e. the code to set the default
159   dnl value) because that is done below by AC_CACHE_CHECK.
160   AC_ARG_WITH(smr_safe_name-includes,
161               AC_HELP_STRING([--with-smr_safe_name-includes[[=DIR]]],
162                              [set directory for smr_name headers]),
163               smr_cv_with_[]smr_safe_name[]_includes=$withval)
165   dnl We cache the result so that the user doesn't have to remember
166   dnl which flags they passed to `configure'.
167   AC_CACHE_CHECK([where to find the smr_name header files],
168                  smr_cv_with_[]smr_safe_name[]_includes,
169                  smr_cv_with_[]smr_safe_name[]_includes=)
171   if test ! x"[$]smr_cv_with_[]smr_safe_name[]_includes" = x; then
172     if test -d "[$]smr_cv_with_[]smr_safe_name[]_includes"; then
173       smr_safe_name[]_CFLAGS="-I[$]smr_cv_with_[]smr_safe_name[]_includes"
174     else
175       AC_MSG_ERROR([argument must be a directory])
176     fi
177   else
178     smr_safe_name[]_CFLAGS=
179   fi
181   dnl This bit of logic comes from the autoconf AC_PROG_CC macro.  We
182   dnl need to put the given include directory into CPPFLAGS temporarily,
183   dnl but then restore CPPFLAGS to its old value.
184   smr_test_CPPFLAGS="${CPPFLAGS+set}"
185   smr_save_CPPFLAGS="$CPPFLAGS"
186   CPPFLAGS="$CPPFLAGS [$]smr_safe_name[]_CFLAGS smr_extra_flags"
188   dnl If the header file smr_header exists, then define
189   dnl HAVE_[]smr_header (in all capitals).
190   AC_CHECK_HEADERS([smr_header],
191                    smr_have_[]smr_safe_name[]_header=yes,
192                    smr_have_[]smr_safe_name[]_header=no)
194   if test x"$smr_test_CPPFLAGS" = xset; then
195     CPPFLAGS=$smr_save_CPPFLAGS
196   else
197     unset CPPFLAGS
198   fi
200   popdef([smr_name])
201   popdef([smr_header])
202   popdef([smr_extra_flags])
203   popdef([smr_safe_name])
207 AC_DEFUN(smr_CHECK_LIB,
209   dnl Define convenient aliases for the arguments since there are so
210   dnl many of them and I keep confusing myself whenever I have to edit
211   dnl this macro.
212   pushdef([smr_name],        $1)
213   pushdef([smr_libname],     ifelse($2, , smr_name, $2))
214   pushdef([smr_help_string], $3)
215   pushdef([smr_function],    $4)
216   pushdef([smr_header],      $5)
217   pushdef([smr_extra_libs],  $6)
218   pushdef([smr_extra_flags], $7)
219   pushdef([smr_prototype],   $8)
220   pushdef([smr_safe_name],   smr_safe_translation(smr_name))
222   dnl Give the user (via "configure --help") an interface to specify
223   dnl whether we should use the library or not, and possibly where we
224   dnl should find it.
225   smr_ARG_WITHLIB([smr_name], [smr_libname], [smr_help_string])
227   if test ! x"$with_[]smr_safe_name" = xno; then
229     # If we got this far, then the user didn't explicitly ask not to use
230     # the library.
232     dnl If the caller of smr_CHECK_LIB specified a header file for this
233     dnl library, then give the user (via "configure --help") an
234     dnl interface to specify where this header file can be found (if it
235     dnl isn't found by the compiler by default).
236     ifelse(smr_header, , , [smr_ARG_WITHINCLUDES(smr_name, smr_header, smr_extra_flags)])
238     # We need only look for the library if the header has been found
239     # (or no header is needed).
240     if test [$]smr_have_[]smr_safe_name[]_header != no; then
242        AC_CHECK_LIB(smr_libname,
243                     smr_function,
244                     smr_have_[]smr_safe_name[]_library=yes,
245                     smr_have_[]smr_safe_name[]_library=no,
246                     [$]smr_safe_name[]_CFLAGS [smr_extra_flags] [$]smr_safe_name[]_LIBS [smr_extra_libs],
247                     [ifelse(smr_prototype, , , [[#]include <smr_header>])],
248                     smr_prototype)
249     fi
251     if test x"[$]smr_have_[]smr_safe_name[]_library" = xyes; then
252       AC_MSG_RESULT([using smr_name library])
253     else
254       smr_safe_name[]_LIBS=
255       smr_safe_name[]_CFLAGS=
257       if test x"$with_[]smr_safe_name" = xmaybe; then
258         AC_MSG_RESULT([not using smr_name library])
259       else
260         AC_MSG_WARN([requested smr_name library not found!])
261       fi
262     fi
263   fi
265   popdef([smr_name])
266   popdef([smr_libname])
267   popdef([smr_help_string])
268   popdef([smr_function])
269   popdef([smr_header])
270   popdef([smr_extra_libs])
271   popdef([smr_extra_flags])
272   popdef([smr_prototype])
273   popdef([smr_safe_name])