summaryrefslogtreecommitdiffstats
path: root/scripts/mkbinutilspec.in
blob: 3f7111d24f9ad791630b5de9eb33fae071d476a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh 
#
#  Usage: mkbinutilspec CPU
#

RTEMS_DIR=`dirname $0`/@top_srcdir@

CFG=setup.cache
dst=@RPM_SPECSdir@
exe_ext=@EXEEXT@

usage()
{
  echo "$0 [options] <target_alias>"
  echo "  options:"
  echo "    -cfg <setup.cache>"
  echo "    -o <rpm-spec-dir>"
  exit 1 ;
}

while test $# -ge 2; do
case $1 in
-cfg) 
  shift
  CFG=$1
  shift
  ;;
-o)
  shift
  dst=$1
  shift
  ;;
-*)
  echo "invalid option $1";
  usage
  ;;
esac
done

if test ! $# -eq 1;
then
  echo "Invalid number of arguments"
  usage
fi

# target to build for
target_alias=$1

. ./$CFG

specfile=${dst}/$target_alias-binutils-${binutils_version}.spec

if test -n "${binutils_patch_version}"; then
PATCH1="Patch0: binutils-${binutils_version}-rtems-${binutils_patch_version}.diff"
PATCH2="%patch0 -p0"
fi

sed -e "s%@Release\@%${binutils_rpm_release}%g" \
    -e "s,@rpm_build_root\@,${rpm_build_root},g" \
    -e "s%@target_alias\@%${target_alias}%g" \
    -e "s%@prefix\@%@prefix@%g" \
    -e "s%@binutils_version\@%${binutils_version}%g" \
    -e "s%@binutils_patch_version\@%${binutils_patch_version}%g" \
    -e "s%@exe_ext\@%${exe_ext}%g" \
    -e "s,@PATCH1\@,${PATCH1}," \
    -e "s,@PATCH2\@,${PATCH2}," \
< ${RTEMS_DIR}/binutils/binutils.spec.in \
> ${specfile}

echo Generated ${specfile}