source: scripts/patch/gcc-specs-patch.sh

systemd
Last change on this file was 129802d, checked in by Joe Ciccone <jciccone@…>, 11 years ago

Remove changes to the gcc-specs-patch script.

  • Property mode set to 100755
File size: 7.3 KB
Line 
1#!/bin/bash
2# Create a GCC Specs Patch
3
4# Get Version #
5#
6VERSION=$1
7
8# Check Input
9#
10if [ "${VERSION}" = "" ]; then
11  echo "$0 - GCC_Version"
12  echo "This will Create a Patch for GCC Specs GCC_Version"
13  exit 255
14fi
15
16# Download GCC Source
17#
18cd ~/tmp
19if ! [ -e gcc-${VERSION}.tar.bz2  ]; then
20  wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-${VERSION}/gcc-${VERSION}.tar.bz2
21fi
22
23# Cleanup Directory
24#
25cd ~/tmp
26rm -rf gcc-${VERSION} gcc-${VERSION}.orig
27tar xvf gcc-${VERSION}.tar.bz2
28cp -ar gcc-${VERSION} gcc-${VERSION}.orig
29
30# Modify the Data
31#
32cd ~/tmp/gcc-${VERSION}
33for file in $(find gcc/config -name "*.h"); do
34  if [ "$(echo ${file} | grep -c bsd)" = "0" ]; then
35    if [ "$(cat ${file} | grep -c DYNAMIC_LINKER)" != "0" ]; then
36      echo "Modifying ${file}..."
37      sed -i '/DYNAMIC_LINKER/s@"/lib@"/tools/lib@' ${file}
38    fi
39    if [ "$(cat ${file} | grep -c DYNAMIC_LINKER)" != "0" ]; then
40      echo "Modifying ${file}..."
41      sed -i '/-dynamic-linker/s@ /lib@ /tools/lib@' ${file}
42    fi
43    if [ "$(cat ${file} | grep -c LINK_SPEC)" != "0" ]; then
44      echo "Modifying ${file}..."
45      sed -i -e '/elf64_sparc -Y P,/s@/usr/lib64@/tools/lib64@' \
46        -e '/elf32_sparc -Y P,/s@/usr/lib@/tools/lib@' \
47        -e '/-dynamic-linker/s@ /lib@ /tools/lib@' ${file}
48    fi
49  fi
50done
51
52
53# Create Patch
54#
55cd ~/tmp
56install -d ~/patches
57echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-specs-x.patch
58echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-specs-x.patch
59echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-specs-x.patch
60echo "Origin: Idea originally developed by Ryan Oliver and Greg Schafer for" >> ~/patches/gcc-${VERSION}-specs-x.patch
61echo "        the Pure LFS project." >> ~/patches/gcc-${VERSION}-specs-x.patch
62echo "Upstream Status: Not Applied" >> ~/patches/gcc-${VERSION}-specs-x.patch
63echo "Description: This patch modifies the location of the dynamic linker for gcc-${VERSION}." >> ~/patches/gcc-${VERSION}-specs-x.patch
64echo "" >> ~/patches/gcc-${VERSION}-specs-x.patch
65diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-specs-x.patch
66
67# Cleanup Directory
68#
69cd ~/tmp
70rm -rf gcc-${VERSION} gcc-${VERSION}.orig
71tar xvf gcc-${VERSION}.tar.bz2
72cp -ar gcc-${VERSION} gcc-${VERSION}.orig
73
74# Modify the Data
75#
76cd ~/tmp/gcc-${VERSION}
77for file in $(find gcc/config -name "*.h"); do
78  if [ "$(echo ${file} | grep -c bsd)" = "0" ]; then
79    if [ "$(cat ${file} | grep -c DYNAMIC_LINKER)" != "0" ]; then
80      echo "Modifying ${file}..."
81      sed -i -e '/DYNAMIC_LINKER32/s@"/lib@"/tools/lib32@' \
82       -e '/DYNAMIC_LINKERN32/s@"/lib32@"/tools/lib64@' \
83       -e '/DYNAMIC_LINKER64/s@"/lib64@"/tools/lib@' \
84       -e '/DYNAMIC_LINKER/s@"/lib@"/tools/lib@' ${file}
85    fi
86    if [ "$(cat ${file} | grep -c DYNAMIC_LINKER)" != "0" ]; then
87      echo "Modifying ${file}..."
88      sed -i '/-dynamic-linker/s@ /lib@ /tools/lib@' ${file}
89    fi
90    if [ "$(cat ${file} | grep -c LINK_SPEC)" != "0" ]; then
91      echo "Modifying ${file}..."
92      sed -i -e '/elf64_sparc -Y P,/s@/usr/lib64@/tools/lib@' \
93        -e '/elf32_sparc -Y P,/s@/usr/lib@/tools/lib32@' \
94        -e '/-dynamic-linker/s@ /lib@ /tools/lib@' ${file}
95    fi
96  fi
97done
98
99for file in $(find gcc/config -name "t-linux*"); do
100  if [ "$(cat ${file} | grep -c MULTILIB_OSDIRNAMES)" != "0" ]; then
101    echo "Modifying ${file}..."
102    if [ "$(echo ${file} | grep -c mips)" != "0" ]; then
103      sed -i -e 's@MULTILIB_OSDIRNAMES = ../lib32 ../lib ../lib64@MULTILIB_OSDIRNAMES = ../lib64 ../lib32 ../lib@' \
104        -e 's@MULTILIB_OSDIRNAMES = ../lib32 ../lib ../lib64@MULTILIB_OSDIRNAMES = ../lib64 ../lib32 ../lib@' ${file}
105    else
106      sed -i -e 's@MULTILIB_OSDIRNAMES = ../lib64 ../lib@MULTILIB_OSDIRNAMES = ../lib ../lib32@' \
107        -e 's@MULTILIB_OSDIRNAMES.= ../lib64 .@MULTILIB_OSDIRNAMES\t= ../lib $@' ${file}
108    fi
109  fi
110done
111
112# Create Patch
113#
114cd ~/tmp
115install -d ~/patches
116echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-pure64_specs-x.patch
117echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
118echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
119echo "Origin: Idea originally developed by Ryan Oliver and Greg Schafer for" >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
120echo "        the Pure LFS project." >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
121echo "Upstream Status: Not Applied" >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
122echo "Description: This patch modifies the location of the dynamic linker for gcc-${VERSION}." >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
123echo "" >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
124diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-pure64_specs-x.patch
125
126# Cleanup Directory
127#
128cd ~/tmp
129rm -rf gcc-${VERSION} gcc-${VERSION}.orig
130tar xvf gcc-${VERSION}.tar.bz2
131cp -ar gcc-${VERSION} gcc-${VERSION}.orig
132CURRENTDIR=$(pwd -P)
133
134# Modify the Data
135#
136cd ~/tmp/gcc-${VERSION}
137for file in $(find gcc/config -name "*.h"); do
138  if [ "$(echo ${file} | grep -c bsd)" = "0" ]; then
139    if [ "$(cat ${file} | grep -c DYNAMIC_LINKER)" != "0" ]; then
140      echo "Modifying ${file}..."
141      sed -i -e '/DYNAMIC_LINKER32/s@"/lib@"/lib32@' \
142       -e '/DYNAMIC_LINKERN32/s@"/lib32@"/lib64@' \
143       -e '/DYNAMIC_LINKER64/s@"/lib64@"/lib@' \
144       -e '/DYNAMIC_LINKER/s@"/lib@"/lib@' ${file}
145    fi
146    if [ "$(cat ${file} | grep -c LINK_SPEC)" != "0" ]; then
147      echo "Modifying ${file}..."
148      sed -i -e '/elf64_sparc -Y P,/s@/usr/lib64@/usr/lib@' \
149        -e '/elf32_sparc -Y P,/s@/usr/lib@/usr/lib32@' ${file}
150    fi
151  fi
152done
153
154for file in $(find gcc/config -name "t-linux*"); do
155  if [ "$(cat ${file} | grep -c MULTILIB_OSDIRNAMES)" != "0" ]; then
156    echo "Modifying ${file}..."
157    if [ "$(echo ${file} | grep -c mips)" != "0" ]; then
158      sed -i -e 's@MULTILIB_OSDIRNAMES = ../lib32 ../lib ../lib64@MULTILIB_OSDIRNAMES = ../lib64 ../lib32 ../lib@' \
159        -e 's@MULTILIB_OSDIRNAMES = ../lib32 ../lib ../lib64@MULTILIB_OSDIRNAMES = ../lib64 ../lib32 ../lib@' ${file}
160    else
161      sed -i -e 's@MULTILIB_OSDIRNAMES = ../lib64 ../lib@MULTILIB_OSDIRNAMES = ../lib ../lib32@' \
162        -e 's@MULTILIB_OSDIRNAMES.= ../lib64 .@MULTILIB_OSDIRNAMES\t= ../lib $@' ${file}
163    fi
164  fi
165done
166
167# Create Patch
168#
169cd ~/tmp
170install -d ~/patches
171echo "Submitted By: Jim Gifford (jim at cross-lfs dot org)" > ~/patches/gcc-${VERSION}-pure64-x.patch
172echo "Date: `date +%m-%d-%Y`" >> ~/patches/gcc-${VERSION}-pure64-x.patch
173echo "Initial Package Version: ${VERSION}" >> ~/patches/gcc-${VERSION}-pure64-x.patch
174echo "Origin: Idea originally developed by Ryan Oliver and Greg Schafer for" >> ~/patches/gcc-${VERSION}-pure64-x.patch
175echo "        the Pure LFS project." >> ~/patches/gcc-${VERSION}-pure64-x.patch
176echo "Upstream Status: Not Applied" >> ~/patches/gcc-${VERSION}-pure64-x.patch
177echo "Description: This patch modifies the location of the dynamic linker for gcc-${VERSION}." >> ~/patches/gcc-${VERSION}-pure64-x.patch
178echo "" >> ~/patches/gcc-${VERSION}-pure64-x.patch
179diff -Naur gcc-${VERSION}.orig gcc-${VERSION} >> ~/patches/gcc-${VERSION}-pure64-x.patch
180
181echo "Created ~/patches/gcc-${VERSION}-specs-x.patch."
182echo "Created ~/patches/gcc-${VERSION}-pure64_specs-x.patch."
183echo "Created ~/patches/gcc-${VERSION}-pure64-x.patch."
184
185# Cleanup Directory
186#
187cd ~/tmp
188rm -rf gcc-${VERSION} gcc-${VERSION}.orig
Note: See TracBrowser for help on using the repository browser.