"Fossies" - the Fresh Open Source Software Archive

Member "alive-2.0.5/build-aux/snuggle.m4" (2 Jan 2022, 13572 Bytes) of package /linux/privat/alive-2.0.5.tar.lz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "snuggle.m4": 2.0.3_vs_2.0.4.

    1 ## snuggle.m4 --- like guile.m4, but more portable
    2 ## serial 19
    3 ##
    4 ## Copyright (C) 2011-2015, 2017, 2020 Thien-Thi Nguyen
    5 ##
    6 ## This program is free software; you can redistribute it and/or
    7 ## modify it under the terms of the GNU General Public License as
    8 ## published by the Free Software Foundation; either version 3, or
    9 ## (at your option) any later version.
   10 ##
   11 ## This program is distributed in the hope that it will be useful,
   12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 ## GNU General Public License for more details.
   15 ##
   16 ## You should have received a copy of the GNU General Public License
   17 ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
   18 
   19 ##: SNUGGLE_SET_SOFIXFLAGS([default-value])
   20 ##  SOFIXFLAGS
   21 ##
   22 ## Set shell var @code{SOFIXFLAGS} and mark it for
   23 ## substitution, as by @code{AC_SUBST}.
   24 ## Its value is based on the @code{host_os} shell variable:
   25 ##
   26 ## @table @code
   27 ## @item linux-gnu
   28 ## no-la,no-symlinks
   29 ## @end table
   30 ##
   31 ## If no matching @code{host_os} is found, use @code{default-value}.  For
   32 ## example, a conservative @code{default-value} would be @code{ln-s-lib},
   33 ## while a more optimistic one would be @code{no-la,no-symlinks}.  If
   34 ## @code{default-value} is not specified, it defaults to @code{ln-s-lib}.
   35 ##
   36 ## @xref{sofix}, and @xref{uninstall-sofixed}, for more info.
   37 ##
   38 AC_DEFUN([SNUGGLE_SET_SOFIXFLAGS],[
   39 AC_REQUIRE([AC_CANONICAL_HOST])
   40 AC_CACHE_CHECK([sofix flags],[host_cv_sofixflags],
   41 [AS_CASE([$host_os],
   42   [linux-gnu],[host_cv_sofixflags=no-la,no-symlinks],
   43   [host_cv_sofixflags=m4_default_nblank_quoted([$1],[ln-s-lib])])])
   44 SOFIXFLAGS="$host_cv_sofixflags"
   45 AC_SUBST([SOFIXFLAGS])
   46 ])
   47 
   48 ##: SNUGGLE_PROGS
   49 ##  GUILE GUILE_CONFIG GUILE_TOOLS
   50 ##
   51 ## Set paths to Guile interpreter, config and tool programs.
   52 ## Look for programs @shellcommand{guile}, @shellcommand{guile-config}
   53 ## and @shellcommand{guile-tools}, and set variables @code{GUILE},
   54 ## @code{GUILE_CONFIG} and @code{GUILE_TOOLS}, to their paths, respectively.
   55 ## However, if any of those vars are set on the command-line
   56 ## or in the environment, they take precedence.
   57 ## If either of the first two is not found, signal error.
   58 ##
   59 ## Mark the variables for substitution, as by @code{AC_SUBST}.
   60 ##
   61 AC_DEFUN([SNUGGLE_PROGS],[
   62 dnl
   63 AC_ARG_VAR([GUILE],[the Guile interpreter program])dnl
   64 AS_IF([test x = x"$GUILE"],[AC_PATH_PROG([GUILE],[guile])])
   65 AS_IF([test x = x"$GUILE"],
   66       [AC_MSG_ERROR([guile required but not found])])
   67 dnl
   68 AC_ARG_VAR([GUILE_CONFIG],[the Guile configuration information script])dnl
   69 AS_IF([test x = x"$GUILE_CONFIG"],[AC_PATH_PROG([GUILE_CONFIG],[guile-config])])
   70 AS_IF([test x = x"$GUILE_CONFIG"],
   71       [AC_MSG_ERROR([guile-config required but not found])])
   72 dnl
   73 AC_ARG_VAR([GUILE_TOOLS],[the Guile tools dispatcher program])dnl
   74 AS_IF([test x = x"$GUILE_TOOLS"],[AC_PATH_PROG([GUILE_TOOLS],[guile-tools])])
   75 dnl
   76 AC_SUBST([GUILE])
   77 AC_SUBST([GUILE_CONFIG])
   78 AC_SUBST([GUILE_TOOLS])
   79 ])
   80 
   81 ##: SNUGGLE_FLAGS
   82 ##  GUILE_CFLAGS GUILE_LDFLAGS
   83 ##
   84 ## Set flags for compiling and linking with Guile.
   85 ## This macro runs the program @shellcommand{guile-config}
   86 ## to find out where Guile's header files and libraries are installed.
   87 ## It sets two variables, @code{GUILE_CFLAGS} and @code{GUILE_LDFLAGS}.
   88 ##
   89 ## @table @code
   90 ## @item GUILE_CFLAGS
   91 ## Flags to pass to a C or C++ compiler to build code that
   92 ## uses Guile header files.  This is almost always just a @code{-I} flag.
   93 ##
   94 ## @item GUILE_LDFLAGS
   95 ## Flags to pass to the linker to link a program against Guile.
   96 ## This includes @code{-lguile} for the Guile library itself, any
   97 ## libraries that Guile itself requires (like -lqthreads), and so on.
   98 ## It may also include a @code{-L} flag to tell the compiler
   99 ## where to find the libraries.
  100 ## @end table
  101 ##
  102 ## The variables are marked for substitution, as by @code{AC_SUBST}.
  103 ##
  104 AC_DEFUN([SNUGGLE_FLAGS],[
  105 AC_REQUIRE([SNUGGLE_PROGS])dnl
  106 AC_CACHE_CHECK([libguile compile flags],[snuggle_cv_compile],
  107 [snuggle_cv_compile=`$GUILE_CONFIG compile`])
  108 AC_CACHE_CHECK([libguile link flags],[snuggle_cv_link],
  109 [snuggle_cv_link=`$GUILE_CONFIG link`])
  110 GUILE_CFLAGS="$snuggle_cv_compile"
  111 GUILE_LDFLAGS="$snuggle_cv_link"
  112 AC_SUBST([GUILE_CFLAGS])
  113 AC_SUBST([GUILE_LDFLAGS])
  114 ])
  115 
  116 ##: SNUGGLE_GUILE_LIBSITE_DIR(cache-var-prefix)
  117 ##  GUILE_LIBSITE
  118 ##
  119 ## Use Guile-BAUX program @shellcommand{re-prefixed-site-dirs}
  120 ## to set shell-variable @code{@var{cache-var-prefix}_cv_minstroot},
  121 ## which is subsequently also copied to var @code{GUILE_LIBSITE},
  122 ## marked for substitution, as by @code{AC_SUBST}.
  123 ##
  124 AC_DEFUN([SNUGGLE_GUILE_LIBSITE_DIR],[
  125 AC_REQUIRE([SNUGGLE_PROGS])
  126 AC_CACHE_CHECK([module installation root dir],[$1_cv_minstroot],[
  127 __snuggle_saved_GUILE_LOAD_PATH="$GUILE_LOAD_PATH"
  128 GUILE_LOAD_PATH=
  129 eval `GUILE="$GUILE" \
  130       $ac_aux_dir/guile-baux/gbaux-do \
  131       re-prefixed-site-dirs "$GUILE_CONFIG" $1`
  132 GUILE_LOAD_PATH="$__snuggle_saved_GUILE_LOAD_PATH"
  133 AS_UNSET([__snuggle_saved_GUILE_LOAD_PATH])
  134 ])
  135 GUILE_LIBSITE="$][$1_cv_minstroot"
  136 AC_SUBST([GUILE_LIBSITE])
  137 ])])
  138 
  139 ##: SNUGGLE_GUILE_SITE_CCACHE_DIR(cache-var-prefix)
  140 ##  GUILE_SITE_CCACHE
  141 ##
  142 ## Determine if Guile has @code{ccachedir} in its @code{%guile-build-info}
  143 ## alist.  If so, reprefix the value to start with @code{$libdir} and end
  144 ## with @code{site-ccache}, and copy to var @code{GUILE_SITE_CCACHE},
  145 ## marked for substitution, as by @code{AC_SUBST}.  If not available,
  146 ## the value is @code{no}.
  147 ##
  148 AC_DEFUN([SNUGGLE_GUILE_SITE_CCACHE_DIR],[
  149 AC_REQUIRE([SNUGGLE_PROGS])
  150 AC_CACHE_CHECK([Guile site ccache dir],[$1_cv_site_ccache_dir],[
  151 cat > conftest.scm <<EOF
  152 (use-modules (srfi srfi-13))
  153 (display
  154  (let ((libdir (assq-ref %guile-build-info 'libdir)))
  155    (cond ((assq-ref %guile-build-info 'ccachedir)
  156           => (lambda (ccachedir)
  157                (string-append
  158                 "$" "{libdir}"
  159                 (substring ccachedir
  160                            (string-length libdir)
  161                            (string-contains ccachedir "ccache"))
  162                 "site-ccache")))
  163          (else ""))))
  164 EOF
  165 $1_cv_site_ccache_dir=$($GUILE -s conftest.scm 2>/dev/null)
  166 AS_IF([test "$$1_cv_site_ccache_dir"],,[$1_cv_site_ccache_dir=no])
  167 ])
  168 AC_SUBST([GUILE_SITE_CCACHE],[$$1_cv_site_ccache_dir])
  169 ])
  170 
  171 ##: SNUGGLE_GUILE_TOOLS_EXISTSP(cache-var,program)
  172 ##
  173 ## Check if @shellcommand{guile-tools} lists @var{program}.  If so, set
  174 ## shell variable @var{cache-var} to @code{yes}, otherwise @code{no}.
  175 ##
  176 AC_DEFUN([SNUGGLE_GUILE_TOOLS_EXISTSP],[
  177 AC_REQUIRE([SNUGGLE_PROGS])
  178 AC_CACHE_CHECK([for "guile-tools $2"],[$1],
  179 [AS_IF([$GUILE_TOOLS | grep "^$2$" 1>/dev/null 2>&1],[$1=yes],[$1=no])])
  180 ])])
  181 
  182 ##: SNUGGLE_CHECK(var,check)
  183 ##
  184 ## Evaluate Guile Scheme code and set a variable.
  185 ## Set @var{var} to @code{yes} or @code{no} depending on the return
  186 ## value of having @shellcommand{$GUILE -c} evaluate @var{check}.
  187 ##
  188 ## @var{check} is one or more Guile Scheme expressions, the last of which
  189 ## should return either @code{0} (zero) or non-@code{#f} to indicate success.
  190 ## Non-zero number or @code{#f} indicates failure.
  191 ## This is conventionally achieved by wrapping the last expression in
  192 ## @code{exit}.  For example, @code{(foo) (bar) (exit (baz))}.
  193 ##
  194 ## Avoid using the character @samp{#} (hash) since that can confuse
  195 ## Autoconf.  You can use @samp{@@%:@@} (at-percent-colon-at), instead.
  196 ## @xref{Quadrigraphs,,,autoconf}.
  197 ##
  198 AC_DEFUN([SNUGGLE_CHECK],[
  199 AC_REQUIRE([SNUGGLE_PROGS])
  200 AS_IF([$GUILE -c "$2" > /dev/null 2>&1],
  201       [AS_VAR_SET([$1],[yes])],
  202       [AS_VAR_SET([$1],[no])])
  203 ])
  204 
  205 ##: SNUGGLE_MODULE_CHECK(var,module,featuretest,description)
  206 ##
  207 ## Check feature of a Guile Scheme module.
  208 ## Set @var{var} based on whether or not @var{module} supports @var{featuretest}.
  209 ## @var{var} is a shell variable name to be set to @code{yes} or @code{no}.
  210 ## Additionally, this value is cached in shell var @code{guile_cv_@var{var}}.
  211 ## @var{module} is a list of symbols sans parens, like: @code{ice-9 common-list}.
  212 ## @var{featuretest} is one or more Guile Scheme expressions,
  213 ## the last of which should evaluate to zero or non-@code{#f} for success,
  214 ## and non-zero or @code{#f} for failure.
  215 ## Unlike for @code{SNUGGLE_CHECK}, you do not need to use @code{exit}.
  216 ## @var{description} is a present-tense verb phrase to be passed to
  217 ## @code{AC_MSG_CHECKING}.
  218 ##
  219 AC_DEFUN([SNUGGLE_MODULE_CHECK],[
  220 AS_VAR_PUSHDEF([cv],[guile_cv_$1])dnl
  221 AC_CACHE_CHECK([if ($2) $4],[cv],
  222 [SNUGGLE_CHECK([cv],[(use-modules ($2)) (exit ((lambda () $3)))])])
  223 AS_VAR_SET([$1],[$cv])
  224 AS_VAR_POPDEF([cv])dnl
  225 ])
  226 
  227 ##: SNUGGLE_MODULE_AVAILABLE(module-name)
  228 ##
  229 ## Check availability of a Guile Scheme module.
  230 ## @var{module-name} is a list of symbols, without surrounding parens,
  231 ## like: @code{ice-9 common-list}.  This sets the shell variable
  232 ## @code{have_mod_@var{module-name}} to @code{yes} or @code{no}.
  233 ## Additionally, this value is cached in shell var
  234 ## @code{guile_cv_have_mod_@var{module-name}}.
  235 ## In the shell variable names, any ``strange characters'' (e.g., hyphen)
  236 ## in @var{module-name} are converted to underscore.
  237 ##
  238 AC_DEFUN([SNUGGLE_MODULE_AVAILABLE],[
  239 AS_VAR_PUSHDEF([var],[have_mod_$1])dnl
  240 SNUGGLE_MODULE_CHECK(var,[$1],[0],[is available])
  241 AS_VAR_POPDEF([var])dnl
  242 ])
  243 
  244 ##: SNUGGLE_CHECK_ICE9_OPTARGS(var)
  245 ##
  246 ## Check if module @code{(ice-9 optargs-kw)} is available.  If so, set
  247 ## shell var @var{var} to @code{no} (see why below).  Otherwise, check if
  248 ## module @code{(ice-9 optargs)} acts like @code{(ice-9 optargs-kw)}.
  249 ## If so, set @var{var} to @code{yes}, otherwise set it to @code{no}.
  250 ## Additionally, this value is cached in shell var @code{guile_cv_@var{var}}.
  251 ##
  252 ## Some versions of Guile provide a module @code{(ice-9 optargs)} that
  253 ## acts like @code{(ice-9 optargs-kw)} (and subsequently omit the latter,
  254 ## instead of providing both).  Code that uses @code{(ice-9 optargs-kw)}
  255 ## solely can be textually kludged to load @code{(ice-9 optargs)} in
  256 ## these situations if @var{var} has value @code{yes} (and you @code{AC_SUBST})
  257 ## it.  Here is a Makefile.am fragment that demonstrates the technique:
  258 ##
  259 ## @example
  260 ## install-data-hook:
  261 ##         if test "$(need_optargs_kludge)" = yes ; then \
  262 ##            sed s/optargs-kw/optargs/ foo.scm > TMP ; \
  263 ##            mv TMP foo.scm ; \
  264 ##         fi
  265 ## @end example
  266 ##
  267 ## In this example, @var{var} is @code{need_optargs_kludge}.  If it turns
  268 ## out @code{(ice-9 optargs-kw)} is available, @code{need_optargs_kludge}
  269 ## would have value @code{no}, and the kludge would neither be required nor
  270 ## applied.
  271 ##
  272 AC_DEFUN([SNUGGLE_CHECK_ICE9_OPTARGS],[
  273 SNUGGLE_MODULE_AVAILABLE([ice-9 optargs-kw])
  274 AS_IF([test xyes = x"$have_mod_ice_9_optargs_kw"],
  275 [$1=no],
  276 [SNUGGLE_MODULE_CHECK([$1],[ice-9 optargs],
  277   [(= 2 ((lambda* (a @%:@:optional b) b) 4 2))],
  278   [acts like (ice-9 optargs-kw)])])
  279 ])
  280 
  281 ##: SNUGGLE_CHECK_META_SWITCH_MINUS_E_STRING(cache-var)
  282 ##
  283 ## Check if meta-switch invocation can handle @code{-e STRING}.
  284 ## If so, set @var{cache-var} to @code{yes}, otherwise @code{no}.
  285 ##
  286 AC_DEFUN([SNUGGLE_CHECK_META_SWITCH_MINUS_E_STRING],[
  287 AC_REQUIRE([SNUGGLE_PROGS])
  288 AC_CACHE_CHECK([if meta-switch parsing handles -e STRING],[$1],[
  289 cat > conftest-dwms <<EOF
  290 @%:@! $GUILE \\
  291 -e "(a b c)" -s
  292 !@%:@
  293  (define-module (a b c) @%:@:export (main))
  294  (define (main args) (exit @%:@t))
  295 EOF
  296 chmod +x conftest-dwms
  297 AS_IF([./conftest-dwms 1>conftest-dwms.out 2>conftest-dwms.err],
  298       [$1=yes],
  299       [$1=no])
  300 ])])
  301 
  302 ##: SNUGGLE_GUILE_USER_PROVIDES(var,name)
  303 ##
  304 ## Check if module @code{(guile-user)} provides @var{name}.
  305 ## If so, set @var{var} to "yes", otherwise "no".
  306 ## Additionally, this value is cached in shell var @code{guile_cv_@var{var}}.
  307 ##
  308 AC_DEFUN([SNUGGLE_GUILE_USER_PROVIDES],
  309 [SNUGGLE_MODULE_CHECK([$1],[guile-user],[$2],[provides ‘$2’])])
  310 
  311 ##: SNUGGLE_CHECK_CLASSIC_HEADERS
  312 ##  HAVE_GUILE_GH_H HAVE_GUILE_MODSUP_H
  313 ##
  314 ## Check for @file{guile/gh.h} and @file{guile/modsup.h} via
  315 ## @code{AC_CHECK_HEADERS}, thus @code{#define}ing the
  316 ## C preprocessor symbols @code{HAVE_GUILE_GH_H} and
  317 ## @code{HAVE_GUILE_MODSUP_H}, respectively.
  318 ##
  319 ## The checks respect var @code{GUILE_CFLAGS}
  320 ## (from macro @code{SNUGGLE_FLAGS}).
  321 ##
  322 AC_DEFUN([SNUGGLE_CHECK_CLASSIC_HEADERS],[
  323 __snuggle_saved_CFLAGS="$CFLAGS"
  324 CFLAGS="$GUILE_CFLAGS $CFLAGS"
  325 AC_CHECK_HEADERS([guile/gh.h],,,[[
  326 #include <libguile.h>
  327 ]])
  328 AC_CHECK_HEADERS([guile/modsup.h],,,[[
  329 #include <libguile.h>
  330 #if HAVE_GUILE_GH_H
  331 #include <guile/gh.h>
  332 #endif
  333 ]])
  334 CFLAGS="$__snuggle_saved_CFLAGS"
  335 AS_UNSET([__snuggle_saved_CFLAGS])
  336 ])
  337 
  338 ##: SNUGGLE_MAINT_MODE_BASE(description)
  339 ##
  340 ## Add support for @file{configure} script option
  341 ## @code{--enable-maint-mode} via @code{AC_ARG_ENABLE}.
  342 ## This provides shell var @code{enable_maint_mode}
  343 ## with default value @code{no},
  344 ## and arranges to display @var{description} in the
  345 ## @shellcommand{--help} output.
  346 ##
  347 AC_DEFUN([SNUGGLE_MAINT_MODE_BASE],[
  348 AC_ARG_ENABLE([maint-mode],
  349 [AS_HELP_STRING([--enable-maint-mode],[$1])],,[enable_maint_mode=no])
  350 ])
  351 
  352 ##: SNUGGLE_MAINT_MODE
  353 ##  MAINT_MODE
  354 ##
  355 ## Add support for @file{configure} script option
  356 ## @code{--enable-maint-mode}, and provide the Automake
  357 ## conditional var @code{MAINT_MODE}.  Note that this is similar
  358 ## to the latter part of @code{AM_MAINTAINER_MODE}; the former part,
  359 ## which controls @file{Makefile}-rebuilding rules, is not included.
  360 ##
  361 AC_DEFUN([SNUGGLE_MAINT_MODE],[
  362 SNUGGLE_MAINT_MODE_BASE([enable makefile rules to build
  363  maintainer-specific bits unlikely to be interesting to casual users])
  364 AM_CONDITIONAL([MAINT_MODE],[test x"$enable_maint_mode" = xyes])
  365 ])
  366 
  367 ## snuggle.m4 ends here