1 # non-recursive-gnulib-prefix-hack.m4
3 dnl Copyright (C) 2012-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl gl_NON_RECURSIVE_GNULIB_PREFIX_HACK LIB_DIR
9 dnl Adjust configure-set $gl_LIBOBJS and each AC_SUBST'd *_H variable
10 dnl with a value ending in ".h" to reflect that these files are located
11 dnl in the directory specified by LIB_DIR.
12 AC_DEFUN([gl_NON_RECURSIVE_GNULIB_PREFIX_HACK],
14 # This hack originated in bison. It is required when using non-recursive
15 # automake rules to build from gnulib-provided lib/ sources. Hence, LIB_DIR
16 # is usually simply "lib". Those rules use the list of names like "fchdir.o"
17 # and "strstr.o" in gl_LIBOBJS. With non-recursive make, we must prefix each
18 # such file name with the "lib/" prefix. See also build-aux/prefix-gnulib-mk.
19 gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, , $1/,g'`
21 # Listing the names of the variables to prefix is error-prone.
22 # Rather, adjust each AC_SUBST'd variable whose name ends in '_H'
23 # and whose value ends in '.h'.
24 for ac_var in $ac_subst_vars
26 eval "ac_val=\$$ac_var"
27 case $ac_var:$ac_val in
28 *_H:*.h) eval "$ac_var=$1/\$$ac_var";;