]> git.sesse.net Git - vlc/blob - contrib/src/change_prefix.sh
vlc_bits: use vlc_common and guards against failed realloc
[vlc] / contrib / src / change_prefix.sh
1 #!/bin/sh
2 # ***************************************************************************
3 # change_prefix.sh : allow to transfer a contrib dir
4 # ***************************************************************************
5 # Copyright © 2012 VideoLAN and its authors
6 #
7 # Authors: Rafaël Carré
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 # ***************************************************************************
23
24 set -e
25
26 LANG=C
27 export LANG
28
29 if test "$1" = "-h" -o "$1" = "--help" -o $# -gt 2; then
30   echo "Usage: $0 [old prefix] [new prefix]
31
32 Without arguments, this script assumes old prefix = @@CONTRIB_PREFIX@@,
33 and new prefix = current directory.
34 "
35 fi
36
37 if [ $# != 2 ]
38 then
39     old_prefix=@@CONTRIB_PREFIX@@
40     new_prefix=`pwd`
41 else
42     old_prefix=$1
43     new_prefix=$2
44 fi
45
46 # process [dir] [filemask] [text only]
47 process() {
48     for file in `find $1 -maxdepth 1 -type f -name "$2"`
49     do
50         if [ -n "$3" ]
51         then
52             file $file | sed "s/^.*: //" | grep -q 'text\|shell' || continue
53         fi
54         echo "Fixing up $file"
55         sed -i.orig -e "s,$old_prefix,$new_prefix,g" $file
56         rm -f $file.orig
57     done
58 }
59
60 process bin/ "*" check
61 process lib/ "*.la"
62 process lib/pkgconfig/ "*.pc"