1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # functions for cross-lfs glibc builds
|
---|
4 | # -----------------------------------------
|
---|
5 | # $LastChangedBy$
|
---|
6 | # $LastChangedDate$
|
---|
7 | # $LastChangedRevision$
|
---|
8 | # $HeadURL$
|
---|
9 |
|
---|
10 | apply_glibc_patches() {
|
---|
11 |
|
---|
12 | # This function should only be called from inside the unpacked glibc source
|
---|
13 | # This function also expects the following vars to be set by the caller
|
---|
14 | #
|
---|
15 | # target_gcc_ver : should be derived either from gcc itself or gcc headers
|
---|
16 | # target_glibc_ver : should be derived from glibc headers
|
---|
17 | # kernver : should be derived from kernel headers
|
---|
18 |
|
---|
19 | # Patching
|
---|
20 | #---------
|
---|
21 | # TODO: check if patches still reqd for < glibc 2.3.3 with later gcc's
|
---|
22 | # (ie 3.4+)
|
---|
23 | case ${target_gcc_ver} in
|
---|
24 | 4.* )
|
---|
25 | echo " o compiling with gcc 4.x"
|
---|
26 | case ${target_glibc_ver} in
|
---|
27 | 2.3.[6-9]* | 2.4.* ) ;;
|
---|
28 | 2.3.5 )
|
---|
29 | # gcc4 support is working in CVS glibc
|
---|
30 | if [ ! -d ${SRC}/${PKGDIR}/CVS ]; then
|
---|
31 | echo " - applying gcc4 fixes"
|
---|
32 | apply_patch glibc-2.3.4-gcc4_elf_fixes
|
---|
33 | apply_patch glibc-2.3.4-allow-gcc-4.0-iconvdata
|
---|
34 | apply_patch glibc-2.3.4-allow-gcc-4.0-powerpc-procfs
|
---|
35 | apply_patch glibc-2.3.5-allow-gcc-4.0-wordexp
|
---|
36 | apply_patch glibc-2.3.5-allow-gcc4-string
|
---|
37 | apply_patch glibc-2.3.5-allow-gcc4-symbols
|
---|
38 | apply_patch glibc-2.3.5-allow-gcc4-wcstol_l
|
---|
39 | fi
|
---|
40 | case ${TGT_ARCH} in
|
---|
41 | sparc* )
|
---|
42 | # fix CFLAGS-rtld to remove deprecated sparc compiler options
|
---|
43 | # from sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
|
---|
44 | # ( -mv8 is no longer supported ). Use -mcpu -mtune options
|
---|
45 | # from TGT_CFLAGS (which get passed regardless)
|
---|
46 | echo " - removing deprecated gcc options from sysdeps/unix/sysv/linux/sparc/sparc32/Makefile"
|
---|
47 | file="sysdeps/unix/sysv/linux/sparc/sparc32/Makefile"
|
---|
48 | if [ ! -f ${file}-ORIG ]; then cp -p ${file} ${file}-ORIG ; fi
|
---|
49 | grep -v \\-mv8 ${file}-ORIG > ${file}
|
---|
50 | ;;
|
---|
51 | esac
|
---|
52 |
|
---|
53 | ;;
|
---|
54 | 2.3.4* )
|
---|
55 | echo " - applying gcc4 fixes"
|
---|
56 | apply_patch glibc-2.3.4-gcc4_elf_fixes
|
---|
57 | apply_patch glibc-2.3.4-allow-gcc-4.0-iconvdata
|
---|
58 | apply_patch glibc-2.3.4-allow-gcc-4.0-powerpc-procfs
|
---|
59 | apply_patch glibc-2.3.5-allow-gcc4-string
|
---|
60 | apply_patch glibc-2.3.5-allow-gcc4-symbols
|
---|
61 | apply_patch glibc-2.3.5-allow-gcc4-wcstol_l
|
---|
62 |
|
---|
63 | case ${TGT_ARCH} in
|
---|
64 | sparc* )
|
---|
65 | # fix CFLAGS-rtld to remove deprecated sparc compiler options
|
---|
66 | # from sysdeps/unix/sysv/linux/sparc/sparc32/Makefile
|
---|
67 | # ( -mv8 is no longer supported ). Use -mcpu -mtune options
|
---|
68 | # from TGT_CFLAGS (which get passed regardless)
|
---|
69 | echo " - removing deprecated gcc options from sysdeps/unix/sysv/linux/sparc/sparc32/Makefile"
|
---|
70 | file="sysdeps/unix/sysv/linux/sparc/sparc32/Makefile"
|
---|
71 | if [ ! -f ${file}-ORIG ]; then cp -p ${file} ${file}-ORIG ; fi
|
---|
72 | grep -v \\-mv8 ${file}-ORIG > ${file}
|
---|
73 | ;;
|
---|
74 | esac
|
---|
75 |
|
---|
76 | ;;
|
---|
77 | * )
|
---|
78 | echo " compiling with gcc4 for ${target_glibc_ver} not supported" 1>&2
|
---|
79 | barf
|
---|
80 | ;;
|
---|
81 | esac
|
---|
82 | ;;
|
---|
83 | 3.3* )
|
---|
84 | echo " o compiling with gcc 3.3x"
|
---|
85 | case ${target_glibc_ver} in
|
---|
86 | 2.3.[345] ) ;;
|
---|
87 | 2.3.2 )
|
---|
88 | # CVS glibc doesn't require gcc-33 patch
|
---|
89 | if [ ! -d ${SRC}/${PKGDIR}/CVS ]; then
|
---|
90 | apply_patch glibc-2.3.2-gcc33
|
---|
91 | fi
|
---|
92 | ;;
|
---|
93 | 2.3* )
|
---|
94 | apply_patch glibc-2.3.2-gcc33
|
---|
95 | ;;
|
---|
96 | esac
|
---|
97 | ;;
|
---|
98 | esac
|
---|
99 |
|
---|
100 | # 20031008 - add patch to fix assertion in rtld.c
|
---|
101 | # this smells hackish but we will see...
|
---|
102 | # TODO: should check for presence of sysinfo DSO in kernel source
|
---|
103 | # 20040711 - not required for current ( 2.3.3 + 2.3.4 ) glibc's
|
---|
104 | #apply_patch glibc-${XXX}2.3.2-fix-rtld
|
---|
105 |
|
---|
106 | case ${kernver} in
|
---|
107 | 2.[56].* )
|
---|
108 | # 2.3.1b2 20030630
|
---|
109 | # We have to patch sysdeps/unix/sysv/linux/sys/sysctl.h to
|
---|
110 | # so we can build against 2.5/2.6 kernels (if not fixed already).
|
---|
111 | fname="${SRC}/${PKGDIR}/sysdeps/unix/sysv/linux/sys/sysctl.h"
|
---|
112 | grep "linux/compiler.h" ${fname} > /dev/null 2>&1 ||
|
---|
113 | {
|
---|
114 | echo " - patching ${fname}"
|
---|
115 | mv ${fname} ${fname}-ORIG
|
---|
116 | sed -e '/#include <linux\/sysctl.h>/i\
|
---|
117 | #include <linux/compiler.h>' \
|
---|
118 | ${fname}-ORIG > ${fname}
|
---|
119 | }
|
---|
120 | case ${TGT_ARCH} in
|
---|
121 | m68k* )
|
---|
122 | echo - applying m68k no-precision-timers patch
|
---|
123 | patch -p1 < ${PATCHES}/glibc-2.3.3-lfh-m68k-no-precision-timers.patch
|
---|
124 | ;;
|
---|
125 | arm* ) apply_patch glibc-arm-ctl_bus_isa ;;
|
---|
126 | esac
|
---|
127 | ;;
|
---|
128 | 2.4.2[4-9] | 2.4.3* )
|
---|
129 | case ${TGT_ARCH} in
|
---|
130 | arm* ) apply_patch glibc-arm-ctl_bus_isa ;;
|
---|
131 | esac
|
---|
132 | ;;
|
---|
133 | esac
|
---|
134 |
|
---|
135 | case ${TGT_ARCH} in
|
---|
136 | m68k* )
|
---|
137 | # TODO: wrap some logic around this to check glibc ver
|
---|
138 | # before applying this patch
|
---|
139 | apply_patch glibc-2.3.3-lfs-5.1-m68k_fix_fcntl
|
---|
140 | ;;
|
---|
141 | mips* )
|
---|
142 | # Fix syscalls for mips w 2.3.4
|
---|
143 | case ${target_glibc_ver} in
|
---|
144 | 2.3.[45] ) apply_patch glibc-2.3.4-mips_syscall-2 ;;
|
---|
145 | esac
|
---|
146 | ;;
|
---|
147 | esac
|
---|
148 | }
|
---|
149 |
|
---|
150 | export -f apply_glibc_patches
|
---|