pjproject_bundled: Make build single threaded
[asterisk/asterisk.git] / third-party / pjproject / apply_patches
1 #!/bin/sh
2
3 if [ "$1" = "-q" ] ; then
4         quiet=1
5         shift
6 fi
7
8 PATCH=${PATCH:-patch}
9
10 patchdir=${1:?You must supply a patches directory}
11 sourcedir=${2?:You must supply a source directory}
12
13 patchdir=`readlink -f $patchdir`
14 sourcedir=`readlink -f $sourcedir`
15
16 if [ ! -d "$patchdir" ] ; then
17         echo "$patchdir is not a directory" >&2
18         exit 1
19 fi
20
21 if [ ! -d "$sourcedir" ] ; then
22         echo "$sourcedir is not a directory"  >&2
23         exit 1
24 fi
25
26 if [ ! "$(ls -A $patchdir/*.patch 2>/dev/null)" ] ; then
27         echo "No patches in $patchdir"  >&2
28         exit 0
29 fi
30
31 for patchfile in "$patchdir"/*.patch ; do
32         [ -z $quiet ] && echo "Applying patch $(basename $patchfile)"
33         ${PATCH} -d "$sourcedir" -p1 -s -i "$patchfile" || exit 1
34 done
35
36 exit 0
37