source: scripts/funcs/kernel_stub_header-funcs.sh@ 617118d

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 617118d 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: 2.5 KB
RevLine 
[617118d]1#!/bin/bash
2#
3# Kernel stub header creation functions for cross-lfs build
4# ---------------------------------------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11set_stub_arch_switch() {
12 case ${TGT_ARCH} in
13 x86_64 | x86-64 )
14 ARCH_SWITCH=__x86_64__
15# ARCH1=x86_64
16# ARCH2=i386
17 ;;
18 sparc* | ultrasparc* )
19 ARCH_SWITCH=__arch64__
20# ARCH1=sparc64
21# ARCH2=sparc
22 ;;
23 ppc* | powerpc* )
24 ARCH_SWITCH=__powerpc64__
25# ARCH1=ppc64
26# ARCH2=ppc
27 ;;
28 s390* )
29 ARCH_SWITCH=__s390x__
30# ARCH1=s390x
31# ARCH2=s390
32 ;;
33 esac
34}
35
36# Creates kernel header stubs for biarch builds
37create_kernel_stubs() {
38 ARCH1=${1}
39 ARCH1_SWITCH=${2}
40 ARCH2=${3}
41 KERN_HDR_DIR=${4}
42
43 # Store the current directory so we can return.
44 startdir=`pwd`
45 for arch in ${ARCH1} ${ARCH2}; do
46 cd ${KERN_HDR_DIR}/asm-${arch}
47 dirs=`find . -type d | sed 's@^\.*\(\|/\)@@g'`
48 hdrs=`find . -type f -name \*.h | sed 's@^\.*\(\|/\)@@g'`
49 DIRS=`echo ${DIRS} ${dirs} | sort | uniq`
50 HDRS=`echo ${HDRS} ${hdrs} | sort | uniq`
51 done
52 cd ${startdir}
53
54 # Create directories (if required) under include/asm
55 if [ "${DIRS}" != "" ]; then
56 for dir in ${DIRS}; do
57 mkdir -p ${KERN_HDR_DIR}/asm/${dir}
58 done
59 fi
60
61 for hdr in ${HDRS}; do
62 # include barrier
63 name=`basename ${hdr} | tr [a-z]. [A-Z]_`
64 cat > ${KERN_HDR_DIR}/asm/${hdr} << EOF
65#ifndef __STUB__${name}__
66#define __STUB__${name}__
67
68EOF
69
70 # check whether we exist in arch1
71 if [ -f ${KERN_HDR_DIR}/asm-${ARCH1}/${hdr} ]; then
72 # check if we also exist arch2
73 if [ -f ${KERN_HDR_DIR}/asm-${ARCH2}/${hdr} ]; then
74 # we exist in both
75 cat >> ${KERN_HDR_DIR}/asm/${hdr} << EOF
76#ifdef ${ARCH1_SWITCH}
77#include <asm-${ARCH1}/${hdr}>
78#else
79#include <asm-${ARCH2}/${hdr}>
80#endif
81EOF
82 else
83 # we only exist in arch1
84 cat >> ${KERN_HDR_DIR}/asm/${hdr} << EOF
85#ifdef ${ARCH1_SWITCH}
86#include <asm-${ARCH1}/${hdr}>
87#endif
88EOF
89 fi
90 # end arch1
91 else
92 # if we get here we only exist in arch2
93 cat >> ${KERN_HDR_DIR}/asm/${hdr} << EOF
94#ifndef ${ARCH1_SWITCH}
95#include <asm-${ARCH2}/${hdr}>
96#endif
97EOF
98
99 fi
100 cat >> ${KERN_HDR_DIR}/asm/${hdr} << EOF
101
102#endif /* __STUB__${name}__ */
103EOF
104 echo " - ${KERN_HDR_DIR}/asm/${hdr} created"
105
106 done
107}
108
109# Export functions
110export -f set_stub_arch_switch
111export -f create_kernel_stubs
112
Note: See TracBrowser for help on using the repository browser.