1# configure-functions.at -- shared shell functions. -*- Autotest -*-
2#
3#   Copyright (C) 2015 Free Software Foundation, Inc.
4#
5#   This file is part of GNU Libtool.
6#
7# GNU Libtool is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2 of
10# the License, or (at your option) any later version.
11#
12# GNU Libtool is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GNU Libtool; see the file COPYING.  If not, a copy
19# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
20# or obtained by writing to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22####
23
24AT_BANNER([Functions shared with configure and libtool.])
25
26m4_define([_AT_FUNC_SETUP], [dnl
27AT_SETUP([$1 works])dnl
28_lt_bin=$abs_top_builddir/libtool
29re_begincf='^# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE'
30re_endcf='^# ### END FUNCTIONS SHARED WITH CONFIGURE'
31
32$ECHO '#!/bin/sh'       > "$1"
33$ECHO '#: ${SED=sed}'   >> "$1"
34$ECHO '#: ${ECHO=echo}' >> "$1"
35
36sed "1,/$re_begincf/d;/$re_endcf/,\$d" < "$_lt_bin" >> "$1"
37])
38
39_AT_FUNC_SETUP([func_munge_path_list])
40
41cat <<\EOF >> func_munge_path_list
42for orig in "/usr/lib" " /lib /usr/lib "; do
43  $ECHO "'$orig':"
44  for path in "/p1:" "/p3:/p2:" ":/a1" ":/a2:/a3" "/p4::/a4" "/p6:/p5::/a5:/a6"; do
45    old=$orig
46    func_munge_path_list orig "$path" || exit 1
47    $ECHO "munge ($path) = $orig"
48  done
49done
50EOF
51chmod +x func_munge_path_list
52
53AT_CHECK([ECHO="$ECHO" SED="$SED" ./func_munge_path_list], [0],
54['/usr/lib':
55munge (/p1:) = /p1 /usr/lib
56munge (/p3:/p2:) = /p3 /p2 /p1 /usr/lib
57munge (:/a1) = /p3 /p2 /p1 /usr/lib /a1
58munge (:/a2:/a3) = /p3 /p2 /p1 /usr/lib /a1 /a2 /a3
59munge (/p4::/a4) = /p4 /p3 /p2 /p1 /usr/lib /a1 /a2 /a3 /a4
60munge (/p6:/p5::/a5:/a6) = /p6 /p5 /p4 /p3 /p2 /p1 /usr/lib /a1 /a2 /a3 /a4 /a5 /a6
61' /lib /usr/lib ':
62munge (/p1:) = /p1  /lib /usr/lib @&t@
63munge (/p3:/p2:) = /p3 /p2 /p1  /lib /usr/lib @&t@
64munge (:/a1) = /p3 /p2 /p1  /lib /usr/lib  /a1
65munge (:/a2:/a3) = /p3 /p2 /p1  /lib /usr/lib  /a1 /a2 /a3
66munge (/p4::/a4) = /p4 /p3 /p2 /p1  /lib /usr/lib  /a1 /a2 /a3 /a4
67munge (/p6:/p5::/a5:/a6) = /p6 /p5 /p4 /p3 /p2 /p1  /lib /usr/lib  /a1 /a2 /a3 /a4 /a5 /a6
68], [])
69
70AT_CLEANUP
71