source: scripts_home/scripts/cross-scripts/cross-kern-hdrs.sh@ 1c9c5c3

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

r624@server (orig r622): jim | 2005-10-31 12:40:28 -0800
Rearranging Archive

  • Property mode set to 100755
File size: 4.4 KB
Line 
1#!/bin/bash
2
3# cross-lfs kernel header creation
4# --------------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11# install kernel headers
12
13cd ${SRC}
14LOG=kernel-headers.log
15unpack_tarball linux-${KERNEL_VER} &&
16cd ${PKGDIR}
17
18# 20030510
19# If we are building for x86_64, and the kernel is greater than 2.6.4,
20# we need to fix unistd.h so glibc doesn't barf during assembly.
21# TODO: track this issue, still exists as of 2.6.6 ...
22case ${KERNEL_VER} in
23 2.6.[4-6] )
24 apply_patch linux-2.6.6-x86_64-unistd_h-fix
25 ;;
26esac
27
28max_log_init kernel-headers ${KERNEL_VER} '' ${INSTLOGS} ${LOG}
29
30#
31case ${TGT_ARCH} in
32 i?86 ) ARCH=i386 ;;
33 x86_64 | x86-64 ) ARCH=i386 ;;
34 sparc64* | ultrasparc* ) ARCH=sparc64 ;;
35 sparc* ) ARCH=sparc ;;
36 powerpc64 | ppc64 ) ARCH=ppc64 ;;
37 powerpc | ppc ) ARCH=ppc ;;
38 s390* ) ARCH=s390 ;;
39 mips* ) ARCH=mips ;;
40 arm* ) ARCH=arm ;;
41 * ) ARCH=${TGT_ARCH} ;;
42esac
43
44set -x
45ARCH=${ARCH} CROSS_COMPILE=${TARGET}- make mrproper \
46 >> ${LOGFILE} 2>&1 &&
47set +x
48# Pre-configure kernel
49# TODO: for want of somewhere better, put kernel .config files
50# in ${SCRIPTS}. Should really let user supply filename
51# via plfs-config
52# Kernel .config files should reside under ${CONFIGS}/kernel
53test -f ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config &&
54{
55 echo "got kernel config"
56 cp ${CONFIGS}/kernel/linux-${KERNEL_VER}-${TGT_ARCH}.config .config
57 yes "" | make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- oldconfig
58} >> ${LOGFILE} 2>&1
59
60# 2.5/2.6 series kernels dont have "make symlinks" target but use
61# "make include/asm"
62# Check for the include/asm target and use it if its available
63make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- include/linux/version.h &&
64grep "^include/asm:" Makefile > /dev/null 2>&1 &&
65{
66 case ${ARCH} in
67 arm | cris ) make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- \
68 include/asm include/asm-${ARCH}/.arch ;;
69 * ) make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- include/asm ;;
70 esac
71} || {
72 make ARCH=${ARCH} CROSS_COMPILE=${TARGET}- symlinks
73} >> ${LOGFILE} 2>&1 &&
74
75# Install the headers.
76
77# If we are using sanitised headers, and we are installing the
78# raw kernel headers, install raw headers into
79# ${TGT_TOOLS}/kernel-hdrs and the sanitised ones into
80# ${TGT_TOOLS}/include
81
82if [ "${USE_SYSROOT}" = "Y" ]; then
83 INSTALL_PREFIX="${LFS}/usr"
84else
85 INSTALL_PREFIX="${TGT_TOOLS}"
86fi
87
88if [ "${USE_SANITISED_HEADERS}" = "Y" ]; then
89 KERN_HDR_DIR="${INSTALL_PREFIX}/kernel-hdrs"
90else
91 KERN_HDR_DIR="${INSTALL_PREFIX}/include"
92fi
93
94# If we are doing a multiarch build we will need the kernel headers for
95# both architectures and will have to create stub headers in include/asm
96
97test "Y" = "${MULTIARCH}" &&
98{
99 case ${TGT_ARCH} in
100 x86_64 | x86-64 )
101 ARCH1_SWITCH=__x86_64__
102 ARCH1=x86_64
103 ARCH2=i386
104 ;;
105 sparc* | ultrasparc* )
106 ARCH1_SWITCH=__arch64__
107 ARCH1=sparc64
108 ARCH2=sparc
109 ;;
110 ppc* | powerpc* )
111 ARCH1_SWITCH=__powerpc64__
112 ARCH1=ppc64
113 ARCH2=ppc
114 ;;
115 s390* )
116 ARCH1_SWITCH=__s390x__
117 ARCH1=s390x
118 ARCH2=s390
119 ;;
120 esac
121
122 # TODO: This needs to be done better
123 # Here we are handling the case of mips, where only the one set of
124 # asm headers are provided (and needed) for multi-arch.
125 if [ -z "${ARCH1_SWITCH}" ]; then
126 mkdir -p ${KERN_HDR_DIR}/asm
127 yes | cp -Rp include/asm/* ${KERN_HDR_DIR}/asm
128 else
129 mkdir -p ${KERN_HDR_DIR}/asm
130 yes | cp -Rp include/asm-${ARCH1} ${KERN_HDR_DIR}
131 yes | cp -Rp include/asm-${ARCH2} ${KERN_HDR_DIR}
132
133 # Create stubs ( see build-init.x.x.x.sh )
134 create_kernel_stubs ${ARCH1} ${ARCH1_SWITCH} ${ARCH2} ${KERN_HDR_DIR}
135 fi
136
137} || {
138 # Install kernel headers in
139 # ${TGT_TOOLS}/include
140 mkdir -p ${KERN_HDR_DIR}/asm
141 yes | cp -Rp include/asm/* ${KERN_HDR_DIR}/asm
142}
143
144yes | cp -Rp include/asm-generic ${KERN_HDR_DIR}
145yes | cp -Rp include/linux ${KERN_HDR_DIR}
146
147# Don't need this if we pre-configured the kernel
148touch ${KERN_HDR_DIR}/linux/autoconf.h
149
Note: See TracBrowser for help on using the repository browser.