Lines 16-22
Link Here
|
16 |
# This will be able to go away once the klibc author updates his code |
16 |
# This will be able to go away once the klibc author updates his code |
17 |
# to build again the headers provided by the kernel's 'headers_install' target. |
17 |
# to build again the headers provided by the kernel's 'headers_install' target. |
18 |
|
18 |
|
19 |
inherit eutils multilib toolchain-funcs |
19 |
inherit eutils multilib toolchain-funcs savedconfig |
20 |
|
20 |
|
21 |
DESCRIPTION="A minimal libc subset for use with initramfs." |
21 |
DESCRIPTION="A minimal libc subset for use with initramfs." |
22 |
HOMEPAGE="http://www.zytor.com/mailman/listinfo/klibc" |
22 |
HOMEPAGE="http://www.zytor.com/mailman/listinfo/klibc" |
Lines 37-45
Link Here
|
37 |
${KERNEL_URI}" |
37 |
${KERNEL_URI}" |
38 |
|
38 |
|
39 |
LICENSE="|| ( GPL-2 LGPL-2 )" |
39 |
LICENSE="|| ( GPL-2 LGPL-2 )" |
40 |
KEYWORDS="~amd64 -mips ~ppc ~sparc ~x86" |
40 |
KEYWORDS="~amd64 ~arm -mips ~ppc ~sparc ~x86" |
41 |
SLOT="0" |
41 |
SLOT="0" |
42 |
IUSE="debug n32" |
42 |
IUSE="debug n32 savedconfig" |
43 |
|
43 |
|
44 |
DEPEND="dev-lang/perl" |
44 |
DEPEND="dev-lang/perl" |
45 |
RDEPEND="${DEPEND}" |
45 |
RDEPEND="${DEPEND}" |
Lines 51-57
Link Here
|
51 |
# Do not strip |
51 |
# Do not strip |
52 |
RESTRICT="strip" |
52 |
RESTRICT="strip" |
53 |
|
53 |
|
|
|
54 |
SAVED_DEFCONFIG_SRC="${PORTAGE_CONFIGROOT}etc/portage/savedconfig/${CATEGORY}/${PF}" |
55 |
|
56 |
kernel_asm_arch() { |
57 |
a="${1:${ARCH}}" |
58 |
case ${a} in |
59 |
# Merged arches |
60 |
x86|amd64) echo x86 ;; |
61 |
ppc*) echo powerpc ;; |
62 |
arm*) echo arm ;; |
63 |
# Non-merged |
64 |
alphaia64|m68k|mips|sh|sparc*) echo ${1} ;; |
65 |
*) die "TODO: Update the code for your asm-ARCH symlink" ;; |
66 |
esac |
67 |
} |
68 |
|
69 |
savedconfig_dst() { |
70 |
local a="$(kernel_asm_arch ${ARCH})" |
71 |
echo "${KS}/arch/${a}/configs/savedconfig_defconfig" |
72 |
} |
73 |
|
74 |
# for non-standardized defconfigs (e.g. arm*) |
75 |
require_savedconfig() { |
76 |
case ${ARCH} in |
77 |
arm*) return 0 ;; |
78 |
*) return 1 ;; |
79 |
esac |
80 |
} |
81 |
|
54 |
src_unpack() { |
82 |
src_unpack() { |
|
|
83 |
# do first to avoid wasting time or resources |
84 |
if require_savedconfig ; then |
85 |
if ! use savedconfig ; then |
86 |
eerror "Your ARCH requires a saved defconfig located at" |
87 |
eerror "${SAVED_DEFCONFIG_SRC}" |
88 |
eerror "Please create the file using linux-${OKV}, and then add" |
89 |
eerror "\"dev-libs/klibc savedconfig\" to " |
90 |
eerror "${PORTAGE_CONFIGROOT}etc/portage/package.use" |
91 |
die "USE=\"savedconfig\" is required for ARCH=${ARCH}" |
92 |
else |
93 |
if [ ! -f "${SAVED_DEFCONFIG_SRC}" ]; then |
94 |
eerror "Your savedconfig file does not exist at" |
95 |
eerror "${SAVED_DEFCONFIG_SRC}" |
96 |
eerror "Please create the file using linux-${OKV}." |
97 |
die "${SAVED_DEFCONFIG_SRC}: No such file or directory." |
98 |
fi |
99 |
fi |
100 |
else |
101 |
if use savedconfig ; then |
102 |
ewarn "Using a saved defconfig with ARCH=${ARCH} is discouraged and also completely" |
103 |
ewarn "unsupported. You have been warned." |
104 |
epause |
105 |
fi |
106 |
fi |
107 |
|
55 |
unpack linux-${OKV}.tar.bz2 ${P}.tar.bz2 |
108 |
unpack linux-${OKV}.tar.bz2 ${P}.tar.bz2 |
56 |
[ -n "${PKV}" ] && EPATCH_OPTS="-d ${KS} -p1" epatch "${DISTDIR}"/patch-${PKV}.bz2 |
109 |
[ -n "${PKV}" ] && EPATCH_OPTS="-d ${KS} -p1" epatch "${DISTDIR}"/patch-${PKV}.bz2 |
57 |
cd "${S}" |
110 |
cd "${S}" |
Lines 77-82
Link Here
|
77 |
|
130 |
|
78 |
# bug 229525, usr/include/arch/x86_64/sys/io.h has undefined variables |
131 |
# bug 229525, usr/include/arch/x86_64/sys/io.h has undefined variables |
79 |
epatch "${FILESDIR}"/${PN}-1.5.11-x86_64-io.h-return.diff |
132 |
epatch "${FILESDIR}"/${PN}-1.5.11-x86_64-io.h-return.diff |
|
|
133 |
|
134 |
[[ ${ARCH} =~ arm.* ]] && [[ ${CHOST} =~ .*eabi ]] && |
135 |
sed -i -e "s/# CONFIG_AEABI is not set/CONFIG_AEABI=y/" \ |
136 |
defconfig |
137 |
|
138 |
for i in dash_readopt losetup klibc_kexecsyscall \ |
139 |
klibc-1.5.15/wc klibc-1.5.15/modprobe \ |
140 |
klibc-1.5.15/fstype-sane-vfat-and-jffs2-for-1.5; do |
141 |
epatch "${FILESDIR}"/oe/${i}.patch || die "" |
142 |
done |
143 |
|
144 |
if use savedconfig ; then |
145 |
restore_config "$(savedconfig_dst)" || die |
146 |
fi |
80 |
} |
147 |
} |
81 |
|
148 |
|
82 |
# For a given Gentoo ARCH, |
149 |
# For a given Gentoo ARCH, |
Lines 87-93
Link Here
|
87 |
case ${a} in |
154 |
case ${a} in |
88 |
ppc64) echo ppc64_defconfig ;; |
155 |
ppc64) echo ppc64_defconfig ;; |
89 |
ppc) echo pmac32_defconfig ;; |
156 |
ppc) echo pmac32_defconfig ;; |
90 |
arm*|sh*) die "TODO: Your arch is not supported by the klibc ebuild. Please suggest a defconfig in a bug." ;; |
157 |
arm*) echo $(basename $(savedconfig_dst)) ;; |
|
|
158 |
sh*) die "TODO: Your arch is not supported by the klibc ebuild. Please suggest a defconfig in a bug." ;; |
91 |
*) echo defconfig ;; |
159 |
*) echo defconfig ;; |
92 |
esac |
160 |
esac |
93 |
} |
161 |
} |
Lines 106-176
Link Here
|
106 |
esac |
174 |
esac |
107 |
} |
175 |
} |
108 |
|
176 |
|
109 |
kernel_asm_arch() { |
177 |
tc-get-toolchain-prefix() { |
110 |
a="${1:${ARCH}}" |
178 |
echo "${CHOST}-" |
111 |
case ${a} in |
|
|
112 |
# Merged arches |
113 |
x86|amd64) echo x86 ;; |
114 |
ppc*) echo powerpc ;; |
115 |
# Non-merged |
116 |
alpha|arm|ia64|m68k|mips|sh|sparc*) echo ${1} ;; |
117 |
*) die "TODO: Update the code for your asm-ARCH symlink" ;; |
118 |
esac |
119 |
} |
179 |
} |
120 |
|
180 |
|
121 |
src_compile() { |
181 |
src_compile() { |
122 |
local myargs="all" |
182 |
|
123 |
local myARCH="${ARCH}" myABI="${ABI}" |
183 |
# |
124 |
# TODO: For cross-compiling |
184 |
# for both linux and klibc |
125 |
# You should set ARCH and ABI here |
185 |
# |
126 |
CC="$(tc-getCC)" |
186 |
local xopts |
127 |
HOSTCC="$(tc-getBUILD_CC)" |
187 |
tc-is-cross-compiler && \ |
128 |
KLIBCARCH="$(klibc_arch ${ARCH})" |
188 |
xopts="ARCH=${ARCH} CROSS_COMPILE=$(tc-get-toolchain-prefix)" |
129 |
KLIBCASMARCH="$(kernel_asm_arch ${ARCH})" |
189 |
# |
130 |
libdir="$(get_libdir)" |
190 |
# for linux |
|
|
191 |
# |
192 |
|
131 |
# This should be the defconfig corresponding to your userspace! |
193 |
# This should be the defconfig corresponding to your userspace! |
132 |
# NOT your kernel. PPC64-32ul would choose 'ppc' for example. |
194 |
# NOT your kernel. PPC64-32ul would choose 'ppc' for example. |
133 |
defconfig=$(kernel_defconfig ${ARCH}) |
195 |
local defconfig=$(kernel_defconfig ${ARCH}) |
134 |
unset ABI ARCH # Unset these, because they interfere |
|
|
135 |
unset KBUILD_OUTPUT # we are using a private copy |
136 |
|
196 |
|
137 |
cd "${KS}" |
197 |
cd "${KS}" |
138 |
emake ${defconfig} CC="${CC}" HOSTCC="${HOSTCC}" || die "No defconfig" |
198 |
emake ${xopts} ${myopts} ${defconfig} &> /dev/null || \ |
139 |
emake prepare CC="${CC}" HOSTCC="${HOSTCC}" || die "Failed to prepare kernel sources for header usage" |
199 |
die "no defconfig" |
|
|
200 |
emake prepare ${xopts} ${myopts} &> /dev/null || \ |
201 |
die "make prepare failed" |
202 |
|
203 |
# |
204 |
# for klibc |
205 |
# |
206 |
|
207 |
# unset ABI ARCH # Unset these, because they interfere |
208 |
unset KBUILD_OUTPUT # we are using a private copy |
140 |
|
209 |
|
141 |
cd "${S}" |
210 |
cd "${S}" |
|
|
211 |
local myargs="all" |
212 |
local libdir="$(get_libdir)" |
213 |
|
214 |
[[ ! -z "$(tc-get-abi)" ]] && \ |
215 |
echo "CONFIG_$(tc-get-abi)=y" >> .config |
142 |
|
216 |
|
143 |
use debug && myargs="${myargs} V=1" |
217 |
use debug && myargs="${myargs} V=1" |
144 |
has test $FEATURES && myargs="${myargs} test" |
218 |
has test $FEATURES && myargs="${myargs} test" |
145 |
|
219 |
|
146 |
emake \ |
220 |
emake \ |
147 |
EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \ |
221 |
KLIBCARCH="$(klibc_arch ${ARCH})" \ |
148 |
EXTRA_KLIBCLDFLAGS="-z,noexecstack" \ |
222 |
KLIBCASMARCH="$(kernel_asm_arch ${ARCH})" \ |
149 |
HOSTCC="${HOSTCC}" CC="${CC}" \ |
|
|
150 |
INSTALLDIR="/usr/${libdir}/klibc" \ |
223 |
INSTALLDIR="/usr/${libdir}/klibc" \ |
151 |
KLIBCARCH=${KLIBCARCH} \ |
|
|
152 |
KLIBCASMARCH=${KLIBCASMARCH} \ |
153 |
SHLIBDIR="/${libdir}" \ |
224 |
SHLIBDIR="/${libdir}" \ |
154 |
libdir="/usr/${libdir}" \ |
225 |
libdir="/usr/${libdir}" \ |
155 |
mandir="/usr/share/man" \ |
226 |
mandir="/usr/share/man" \ |
156 |
T="${T}" \ |
227 |
${xopts} \ |
157 |
${myargs} || die "Compile failed!" |
228 |
${myargs} &> /dev/null || die "Compile failed!" |
158 |
|
|
|
159 |
#SHLIBDIR="/${libdir}" \ |
160 |
|
161 |
ARCH="${myARCH}" ABI="${myABI}" |
162 |
} |
229 |
} |
163 |
|
230 |
|
164 |
src_install() { |
231 |
src_install() { |
165 |
local myargs |
232 |
local myargs |
166 |
local myARCH="${ARCH}" myABI="${ABI}" |
|
|
167 |
# TODO: For cross-compiling |
168 |
# You should set ARCH and ABI here |
169 |
CC="$(tc-getCC)" |
170 |
HOSTCC="$(tc-getBUILD_CC)" |
171 |
KLIBCARCH="$(klibc_arch ${ARCH})" |
172 |
KLIBCASMARCH="$(kernel_asm_arch ${ARCH})" |
173 |
libdir="$(get_libdir)" |
233 |
libdir="$(get_libdir)" |
|
|
234 |
|
174 |
# This should be the defconfig corresponding to your userspace! |
235 |
# This should be the defconfig corresponding to your userspace! |
175 |
# NOT your kernel. PPC64-32ul would choose 'ppc' for example. |
236 |
# NOT your kernel. PPC64-32ul would choose 'ppc' for example. |
176 |
defconfig=$(kernel_defconfig ${ARCH}) |
237 |
defconfig=$(kernel_defconfig ${ARCH}) |
Lines 183-207
Link Here
|
183 |
else |
244 |
else |
184 |
klibc_prefix=$("${S}/klcc/klcc" -print-klibc-prefix) |
245 |
klibc_prefix=$("${S}/klcc/klcc" -print-klibc-prefix) |
185 |
fi |
246 |
fi |
|
|
247 |
local xopts |
248 |
tc-is-cross-compiler && \ |
249 |
xopts="CROSS_COMPILE=$(tc-get-toolchain-prefix) ARCH=${ARCH}" |
186 |
|
250 |
|
187 |
unset ABI ARCH # Unset these, because they interfere |
251 |
# unset ABI ARCH # Unset these, because they interfere ... really?? |
188 |
unset KBUILD_OUTPUT # we are using a private copy |
252 |
unset KBUILD_OUTPUT # we are using a private copy |
189 |
|
253 |
|
190 |
emake \ |
254 |
emake \ |
191 |
EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \ |
255 |
EXTRA_KLIBCAFLAGS="-Wa,--noexecstack" \ |
192 |
EXTRA_KLIBCLDFLAGS="-z,noexecstack" \ |
256 |
EXTRA_KLIBCLDFLAGS="-z,noexecstack" \ |
193 |
HOSTCC="${HOSTCC}" CC="${CC}" \ |
|
|
194 |
INSTALLDIR="/usr/${libdir}/klibc" \ |
257 |
INSTALLDIR="/usr/${libdir}/klibc" \ |
195 |
INSTALLROOT="${D}" \ |
258 |
INSTALLROOT="${D}" \ |
196 |
KLIBCARCH=${KLIBCARCH} \ |
259 |
KLIBCARCH="$(klibc_arch ${ARCH})" \ |
197 |
KLIBCASMARCH=${KLIBCASMARCH} \ |
260 |
KLIBCASMARCH="$(kernel_asm_arch ${ARCH})" \ |
198 |
SHLIBDIR="/${libdir}" \ |
261 |
SHLIBDIR="/${libdir}" \ |
199 |
libdir="/usr/${libdir}" \ |
262 |
libdir="/usr/${libdir}" \ |
200 |
mandir="/usr/share/man" \ |
263 |
mandir="/usr/share/man" \ |
201 |
${myargs} \ |
264 |
${myargs} \ |
202 |
install || die "Install failed!" |
265 |
${xopts} \ |
203 |
|
266 |
install &> /dev/null || die "Install failed!" |
204 |
#SHLIBDIR="/${libdir}" \ |
|
|
205 |
|
267 |
|
206 |
# klibc doesn't support prelinking, so we need to mask it |
268 |
# klibc doesn't support prelinking, so we need to mask it |
207 |
cat > "${T}/70klibc" <<-EOF |
269 |
cat > "${T}/70klibc" <<-EOF |