| 1 | #! /bin/sh |
| 2 | # Merge pkg-config macros into Emacs sources. |
| 3 | # Typical usage: |
| 4 | # |
| 5 | # admin/merge-pkg-config |
| 6 | |
| 7 | # Copyright 2014 Free Software Foundation, Inc. |
| 8 | |
| 9 | # This file is part of GNU Emacs. |
| 10 | |
| 11 | # GNU Emacs is free software: you can redistribute it and/or modify |
| 12 | # it under the terms of the GNU General Public License as published by |
| 13 | # the Free Software Foundation, either version 3 of the License, or |
| 14 | # (at your option) any later version. |
| 15 | |
| 16 | # GNU Emacs is distributed in the hope that it will be useful, |
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | # GNU General Public License for more details. |
| 20 | |
| 21 | # You should have received a copy of the GNU General Public License |
| 22 | # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 23 | |
| 24 | # written by Paul Eggert |
| 25 | |
| 26 | { |
| 27 | # Maybe ACLOCAL_PATH is already set-up. |
| 28 | oIFS=$IFS |
| 29 | IFS=: |
| 30 | for dir in $ACLOCAL_PATH ''; do |
| 31 | test -n "$dir" && test -r "$dir/pkg.m4" && break |
| 32 | done |
| 33 | IFS=$oIFS |
| 34 | |
| 35 | test -n "$dir" |
| 36 | } || { |
| 37 | # Use the pkg.m4 installed where aclocal knows about it. |
| 38 | # Maybe we are running our own aclocal, which doesn't know where |
| 39 | # the standard pkg.m4 is installed, so try running all the |
| 40 | # aclocal programs in our PATH. |
| 41 | oIFS=$IFS |
| 42 | IFS=: |
| 43 | for dir in $PATH ''; do |
| 44 | if test -n "$dir" && test -x "$dir/aclocal"; then |
| 45 | dir=$("$dir/aclocal" --print-ac-dir) && test -r "$dir/pkg.m4" && break |
| 46 | fi |
| 47 | done |
| 48 | IFS=$oIFS |
| 49 | |
| 50 | test -n "$dir" |
| 51 | } || { |
| 52 | echo >&2 "$0: cannot find pkg.m4" |
| 53 | exit 1 |
| 54 | } |
| 55 | |
| 56 | test -d m4 || { |
| 57 | echo >&2 "$0: please run this command in the main source directory" |
| 58 | exit 1 |
| 59 | } |
| 60 | |
| 61 | echo >&2 "$0: copying $dir/pkg.m4 to m4/pkg.m4" |
| 62 | |
| 63 | cp $dir/pkg.m4 m4 |