2 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Try to find the pkg-config '.m4' files and make them easily accessed
18 # to the test cases requiring them.
22 echo "# Automatically generated by $me." > get.sh
25 if ver=$(pkg-config --version) && test -n "$ver"; then
26 echo "printf 'pkg-config version: %s\\n' '$ver'" >> get.sh
28 echo "skip_all_ \"'pkg-config' not available\"" >> get.sh
31 cat > configure.ac <<'END'
33 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
36 have_pkg_config_macros ()
38 $AUTOCONF && ! $FGREP PKG_CHECK_MODULES configure
41 if have_pkg_config_macros; then
42 # The pkg-config macros are already available, nothing to do.
46 # Usual locations where pkg.m4 *might* be installed.
47 XT_ACLOCAL_PATH=/usr/local/share/aclocal:/usr/share/aclocal
49 # Find the location of the pkg-config executable.
54 if test -f $d/pkg-config || test -f $d/pkg-config.exe; then
61 # Now try to use the location of the pkg-config executable to guess
62 # where the corresponding pkg.m4 might be installed.
63 if test -n "$dir"; then
64 # Only support standard installation layouts.
65 XT_ACLOCAL_PATH=${dir%/bin}/share/aclocal:$XT_ACLOCAL_PATH
68 XT_ACLOCAL_PATH=$XT_ACLOCAL_PATH${ACLOCAL_PATH+":$ACLOCAL_PATH"}
70 # Try once again to fetch the pkg-config macros.
72 ACLOCAL_PATH=$XT_ACLOCAL_PATH $ACLOCAL -Wno-syntax --install -I m4
73 if test -f m4/pkg.m4 && have_pkg_config_macros; then
74 echo "ACLOCAL_PATH='$(pwd)/m4':\$ACLOCAL_PATH" >> get.sh
75 echo "export ACLOCAL_PATH" >> get.sh
76 echo "sed 20q '$(pwd)/m4/pkg.m4' # For debugging." >> get.sh
78 echo "skip_all_ \"pkg-config m4 macros not found\"" >> get.sh
84 $ACLOCAL --force -I m4 || cat >> get.sh <<'END'
85 # We need to use '-Wno-syntax', since we do not want our test suite
86 # to fail merely because some third-party '.m4' file is underquoted.
87 ACLOCAL="$ACLOCAL -Wno-syntax"
90 # The pkg-config m4 file(s) we might fetched will be copied in the
91 # 'm4' subdirectory of the test directory are going to be needed by
92 # other tests, so we must not remove the test directory.