source: scripts/funcs/cross_gcc-funcs.sh@ 873009c

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 873009c was 617118d, checked in by Jim Gifford <clfs@…>, 19 years ago

r561@server (orig r559): root | 2005-06-05 02:38:49 -0700
Fixed Directory Structure

  • Property mode set to 100755
File size: 7.3 KB
Line 
1#!/bin/bash
2
3# functions for cross-lfs gcc builds
4# -----------------------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9
10gcc_specs_mod() {
11
12 # LFS style build
13 #----------------
14
15 # Set ARCH for header modifications.
16 # Set dl_hfiles to contain the list of header file(s) requiring modification
17 # of the location for the dynmamic linker.
18 # Set sf_hfiles to contain the list of header file(s) where we have to define
19 # startfile_prefix_spec.
20 case ${TGT_ARCH} in
21 i?86 | x86_64 )
22 ARCH=i386
23 dl_hfiles="${ARCH}/linux.h ${ARCH}/linux64.h"
24 sf_hfiles="linux.h"
25 ;;
26 ia64* )
27 ARCH=ia64
28 dl_hfiles="${ARCH}/linux.h"
29 sf_hfiles="linux.h"
30 ;;
31 powerpc* | ppc* )
32 ARCH=rs6000
33 dl_hfiles="${ARCH}/sysv4.h ${ARCH}/linux64.h"
34 sf_hfiles="${ARCH}/linux.h ${ARCH}/linux64.h"
35 ;;
36 sparc* )
37 ARCH=sparc
38 dl_hfiles="${ARCH}/linux.h ${ARCH}/linux64.h"
39 sf_hfiles="${ARCH}/linux.h ${ARCH}/linux64.h"
40 ;;
41 alpha )
42 ARCH=alpha
43 dl_hfiles="${ARCH}/linux-elf.h"
44 sf_hfiles="${ARCH}/linux.h"
45 ;;
46 arm* )
47 ARCH=arm
48 dl_hfiles="${ARCH}/linux-elf.h"
49 sf_hfiles="linux.h"
50 ;;
51 s390* )
52 ARCH=s390
53 dl_hfiles="${ARCH}/linux.h"
54 sf_hfiles="linux.h"
55 ;;
56 m68k )
57 ARCH=m68k
58 dl_hfiles="${ARCH}/linux.h"
59 sf_hfiles="linux.h"
60 ;;
61 m32r* )
62 ARCH=m32r
63 dl_hfiles="${ARCH}/linux.h"
64 sf_hfiles="linux.h"
65 ;;
66 mips* )
67 ARCH=mips
68 dl_hfiles="${ARCH}/linux.h ${ARCH}/linux64.h"
69 sf_hfiles="linux.h"
70 ;;
71 parisc* | hppa* )
72 ARCH=pa
73 dl_hfiles="${ARCH}/pa-linux.h"
74 sf_hfiles="linux.h"
75 ;;
76 xtensa )
77 ARCH=xtensa
78 dl_hfiles="${ARCH}/linux.h"
79 sf_hfiles="linux.h"
80 ;;
81 * )
82 # No support
83 echo "No support for ${TGT_ARCH}" 1>&2
84 barf
85 ;;
86 esac
87
88 specs_set_dynamic_linker
89 specs_set_startfile_prefix_spec
90}
91
92specs_set_dynamic_linker() {
93 # We want our new gcc to use our new dynamic linker
94 # ( ${TGT_TOOLS}/lib/ld-linux.so.2 ) so we will need to modify
95 # gcc/config/$ARCH/linux.h and or linux64.h
96 # also sysv4.h for ppc and linux-elf.h for alpha
97 # (where $ARCH is cpu-series type)
98 #
99 # LINK_SPEC needs to get defined so that
100 # -dynamic-linker is ${TGT_TOOLS}/lib/ld-linux.so.2 or
101 # ${TOOLS}/lib64/ld-linux.so.2#
102 # This sets --dynamic-linker correctly in the generated spec file
103
104 cd ${SRC}/${PKGDIR}/gcc/config
105 for hfile in ${dl_hfiles} ; do
106 if [ -f ${hfile} ]; then
107 if [ ! -f ${hfile}-ORIG ]; then
108 cp ${hfile} ${hfile}-ORIG
109 fi
110
111 sed -e "s@\(/lib\(\|32\|64\)\)\(/ld\(\|64\)\.so\.1\|/ld-linux\(\|-ia64\|-x86-64\)\.so\.\(1\|2\)\)@${TGT_TOOLS}&@g" \
112 -e "/elf.._sparc -Y P/s@/usr/lib@${TGT_TOOLS}/lib@g" \
113 ${hfile}-ORIG > ${hfile}
114 else
115 echo "${0}: specs_set_dynamic_linker" 1>&2
116 echo " header file ${hfile} does not exist" 1>&2
117 echo "" 1>&2
118 echo " Please check that the gcc_specs_mod function" 1>&2
119 echo " ( in cross-lfs/scripts/funcs/cross_gcc_funcs }" 1>&2
120 echo " is correct for your target arch." 1>&2
121 barf
122 fi
123 done
124
125}
126
127specs_set_startfile_prefix_spec() {
128
129 # Set STARTFILE_PREFIX_SPEC appropriately.
130 echo " o setting STARTFILE_PREFIX_SPEC"
131
132 cd ${SRC}/${PKGDIR}/gcc/config
133 for hfile in ${sf_hfiles} ; do
134 if [ -f ${hfile} ]; then
135 echo "" >> ${hfile}
136 echo "#undef STARTFILE_PREFIX_SPEC" >> ${hfile}
137 echo "#define STARTFILE_PREFIX_SPEC \"${TGT_TOOLS}/lib/\"" >> ${hfile}
138 else
139 echo "${0}: specs_set_startfile_prefix_spec" 1>&2
140 echo " header file ${hfile} does not exist" 1>&2
141 echo "" 1>&2
142 echo " Please check that the gcc_specs_mod function" 1>&2
143 echo " ( in cross-lfs/scripts/funcs/cross_gcc_funcs }" 1>&2
144 echo " is correct for your target arch." 1>&2
145 barf
146 fi
147 done
148}
149
150cpp_set_cross_system_header_dir() {
151
152 # Set cpp's default include search path, and the path
153 # fixincludes uses to search for headers
154 echo " o setting ${TGT_TOOLS}/include as cpp's default include search dir"
155 cd ${SRC}/${PKGDIR}/gcc
156 test -f Makefile.in-ORIG ||
157 mv Makefile.in Makefile.in-ORIG
158
159 sed "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 ${TGT_TOOLS}/include@g" \
160 Makefile.in-ORIG > Makefile.in
161}
162
163cpp_undef_standard_include_dir() {
164
165 # We need to stop cpp using /usr/include as the standard include directory
166 # when cross-building a target-native gcc.
167 # This is defined in gcc/cppdefault.c using STANDARD_INCLUDE_DIR
168 cd ${SRC}/${PKGDIR}/gcc
169 test ! -f cppdefault.c-ORIG &&
170 cp -p cppdefault.c cppdefault.c-ORIG
171
172 sed -e '/#define STANDARD_INCLUDE_DIR/s@"/usr/include"@0@g' \
173 cppdefault.c-ORIG > cppdefault.c
174}
175
176fixincludes_set_native_system_header_dir() {
177
178 # For cross-building a target native gcc.
179 # Set the path fixincludes uses to search for headers
180 echo " o setting NATIVE_SYSTEM_HEADER_DIR to ${TGT_TOOLS}/include"
181 cd ${SRC}/${PKGDIR}/gcc
182 test -f Makefile.in-ORIG ||
183 mv Makefile.in Makefile.in-ORIG
184
185 sed "s@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 ${TGT_TOOLS}/include@g" \
186 Makefile.in-ORIG > Makefile.in
187
188}
189
190configure_fix_flags_for_target() {
191
192 # This is only necessary if
193 # o you are building a multi-lib cross-compiler
194 # o you are not building into a sys-root
195 # o if ${TGT_TOOLS} = ${HST_TOOLS}/${TARGET}
196 # but doesn't hurt to apply in general.
197
198 if [ "${TGT_TOOLS}" = "${HST_TOOLS}/${TARGET}" -a ! "${USE_SYSROOT}" = "Y" ]
199 then
200
201 # -B${HST_TOOLS}/${TARGET}/lib (set in FLAGS_FOR_TARGET)
202 # is passed during the build, which causes issues if you are installing
203 # all your target startfiles/libraries under
204 # ${HST_TOOLS}/${TARGET}/lib{,32,64}
205 #
206 # -B takes precedence over -L and doesn't get altered by
207 # the multilib spec, so you always end up linking in startfiles
208 # from ${HST_TOOLS}/${TARGET}/lib when creating a shared libgcc.
209 #
210 # This is kinda painful when it should be, say, linking 64bit
211 # startfiles in from under */lib64 when creating the 64bit shared libgcc
212 #
213 # Here we just remove -B*/lib from FLAGS_FOR_TARGET.
214 #
215 # NOTE: for gcc-3.3.3 all we had do edit was configure.in,
216 # FLAGS_FOR_TARGET was only specified here.
217 # As of gcc-3.4.0 we need to edit configure itself.
218 # So, we'll just attempt to edit both
219
220 cd ${SRC}/${PKGDIR}
221 for file in configure configure.in; do
222 grep FLAGS_FOR_TARGET ${file} > /dev/null 2>&1 &&
223 {
224 test -f ${file}-ORIG ||
225 cp -p ${file} ${file}-ORIG
226
227 sed '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' \
228 ${file}-ORIG > ${file}
229 }
230 done
231 fi
232
233}
234
235export -f specs_set_startfile_prefix_spec
236export -f specs_set_dynamic_linker
237export -f gcc_specs_mod
238
239export -f fixincludes_set_native_system_header_dir
240
241export -f cpp_set_cross_system_header_dir
242export -f cpp_undef_standard_include_dir
243export -f configure_fix_flags_for_target
Note: See TracBrowser for help on using the repository browser.