1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # build-target.sh
|
---|
4 | #
|
---|
5 | # Script for cross building target native tools
|
---|
6 | #
|
---|
7 | # Authors: Ryan Oliver <ryan.oliver@pha.com.au
|
---|
8 | # Finn Thain
|
---|
9 | #
|
---|
10 | # $LastChangedBy$
|
---|
11 | # $LastChangedDate$
|
---|
12 | # $LastChangedRevision$
|
---|
13 |
|
---|
14 | set +h
|
---|
15 |
|
---|
16 | # Set SELF to be name of script called, minus any path...
|
---|
17 | SELF=$(basename ${0})
|
---|
18 | echo "Running ${SELF}"
|
---|
19 | VERSION="2.4.4"
|
---|
20 | DATE=$(date +'%Y%m%d')
|
---|
21 | export DATE
|
---|
22 |
|
---|
23 | # Read in build configuration information
|
---|
24 | # plfs-config should reside in the same directory as this script.
|
---|
25 | # We need to use dirname to determine where to find it as SCRIPTS
|
---|
26 | # env var is not set yet (set in plfs-config itself)
|
---|
27 | . `dirname ${0}`/plfs-config
|
---|
28 |
|
---|
29 | # Sanity check, are ${LFS}, ${HST_TOOLS} and ${TGT_TOOLS} set?
|
---|
30 | if [ "X${LFS}" = "X" -o "X${HST_TOOLS}" = "X" -o "X${TGT_TOOLS}" = "X" ]; then
|
---|
31 | echo "Error: Not all required environment vars have been set." 1>&2
|
---|
32 | echo " Check plfs-config" 1>&2
|
---|
33 | exit 1
|
---|
34 | fi
|
---|
35 |
|
---|
36 | # Get package version information
|
---|
37 | . ${SCRIPTS}/plfs-packages
|
---|
38 |
|
---|
39 | # Source Functions and definitions
|
---|
40 | . ${SCRIPTS}/build-init.sh
|
---|
41 |
|
---|
42 |
|
---|
43 | set +x
|
---|
44 | unset LD_LIBRARY_PATH
|
---|
45 | unset LD_PRELOAD
|
---|
46 |
|
---|
47 | # Configure uses these if set, and will not look for a cross-compiler
|
---|
48 | unset CC CXX
|
---|
49 |
|
---|
50 | export LDFLAGS="-s"
|
---|
51 |
|
---|
52 | # Setup PATH
|
---|
53 | #export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
---|
54 | export PATH=${HST_TOOLS}/bin:${HST_TOOLS}/sbin:${PATH}
|
---|
55 |
|
---|
56 | # If ${SRC} does not exist, create it
|
---|
57 | test -d ${SRC} || mkdir -p ${SRC}
|
---|
58 |
|
---|
59 | if [ ! "${USE_SYSROOT}" = "Y" ]; then
|
---|
60 | # If ${LFS}${TGT_TOOLS} directory doesn't exist, create it
|
---|
61 | test -d ${LFS}${TGT_TOOLS} || mkdir -p ${LFS}${TGT_TOOLS}
|
---|
62 |
|
---|
63 | # create it ${TGT_TOOLS} symlink
|
---|
64 | if [ ! -d `dirname ${TGT_TOOLS}` ]; then mkdir -p `dirname ${TGT_TOOLS}` ; fi
|
---|
65 | ln -sf ${LFS}${TGT_TOOLS} `dirname ${TGT_TOOLS}`
|
---|
66 | fi
|
---|
67 |
|
---|
68 | mkdir -p ${CONFLOGS}
|
---|
69 | mkdir -p ${BUILDLOGS}
|
---|
70 | mkdir -p ${INSTLOGS}
|
---|
71 | mkdir -p ${TESTLOGS}
|
---|
72 | cd ${SRC}
|
---|
73 |
|
---|
74 | #scripts_dir="cross-scripts-${VERSION}"
|
---|
75 | scripts_dir="target-scripts"
|
---|
76 |
|
---|
77 | # scripts for building target tools
|
---|
78 | test "Y" = "${MULTIARCH}" &&
|
---|
79 | {
|
---|
80 | script_list="target-binutils.sh
|
---|
81 | target-gcc.sh
|
---|
82 | target-zlib-32.sh
|
---|
83 | target-zlib-n32.sh
|
---|
84 | target-zlib-64.sh
|
---|
85 | target-gawk.sh
|
---|
86 | target-coreutils.sh
|
---|
87 | target-bzip2-32.sh
|
---|
88 | target-bzip2-n32.sh
|
---|
89 | target-bzip2-64.sh
|
---|
90 | target-gzip.sh
|
---|
91 | target-diffutils.sh
|
---|
92 | target-findutils.sh
|
---|
93 | target-m4.sh
|
---|
94 | target-bison.sh
|
---|
95 | target-flex.sh
|
---|
96 | target-make.sh
|
---|
97 | target-grep.sh
|
---|
98 | target-sed.sh
|
---|
99 | target-gettext-32.sh
|
---|
100 | target-gettext-n32.sh
|
---|
101 | target-gettext-64.sh
|
---|
102 | target-ncurses-32.sh
|
---|
103 | target-ncurses-n32.sh
|
---|
104 | target-ncurses-64.sh
|
---|
105 | target-patch.sh
|
---|
106 | target-tar.sh
|
---|
107 | target-bash.sh"
|
---|
108 | } || {
|
---|
109 | script_list="target-binutils.sh
|
---|
110 | target-gcc.sh
|
---|
111 | target-zlib.sh
|
---|
112 | target-gawk.sh
|
---|
113 | target-coreutils.sh
|
---|
114 | target-bzip2.sh
|
---|
115 | target-gzip.sh
|
---|
116 | target-diffutils.sh
|
---|
117 | target-findutils.sh
|
---|
118 | target-m4.sh
|
---|
119 | target-bison.sh
|
---|
120 | target-flex.sh
|
---|
121 | target-make.sh
|
---|
122 | target-grep.sh
|
---|
123 | target-sed.sh
|
---|
124 | target-gettext.sh
|
---|
125 | target-ncurses.sh
|
---|
126 | target-patch.sh
|
---|
127 | target-tar.sh
|
---|
128 | target-bash.sh"
|
---|
129 | }
|
---|
130 |
|
---|
131 | # Packages common to both BIARCH and non-BIARCH
|
---|
132 | script_list="${script_list}
|
---|
133 | target-e2fsprogs.sh
|
---|
134 | target-procps.sh
|
---|
135 | target-sysvinit.sh
|
---|
136 | target-module-init-tools.sh
|
---|
137 | target-nettools.sh
|
---|
138 | target-inetutils.sh
|
---|
139 | target-util-linux.sh
|
---|
140 | target-strace.sh
|
---|
141 | target-sysklogd.sh"
|
---|
142 |
|
---|
143 | if [ "${USE_HOTPLUG}" = "Y" ]; then
|
---|
144 | script_list="${script_list}
|
---|
145 | target-hotplug.sh"
|
---|
146 | fi
|
---|
147 |
|
---|
148 | script_list="${script_list}
|
---|
149 | target-dev.sh
|
---|
150 | target-lfs-bootscripts.sh
|
---|
151 | target-kernel.sh
|
---|
152 | target-iana-etc.sh"
|
---|
153 |
|
---|
154 | #target-modutils.sh
|
---|
155 | # Lilo bootloader
|
---|
156 | if [ "${USE_LILO}" = "Y" ]; then
|
---|
157 | script_list="${script_list}
|
---|
158 | host-nasm.sh
|
---|
159 | host-bin86.sh
|
---|
160 | host-lilo.sh
|
---|
161 | target-nasm.sh
|
---|
162 | target-bin86.sh
|
---|
163 | target-lilo.sh"
|
---|
164 | fi
|
---|
165 |
|
---|
166 | # TODO: add nfs client, tcpwrappers portmap etc scripts
|
---|
167 | # ( to allow us to nfs mount root on target box )
|
---|
168 | script_list="${script_list}
|
---|
169 | target-nfsutils.sh
|
---|
170 | target-tcp-wrappers.sh
|
---|
171 | target-portmap.sh"
|
---|
172 |
|
---|
173 | script_list="${script_list}
|
---|
174 | target-iproute2.sh
|
---|
175 | target-final-prep-wrapper.sh"
|
---|
176 |
|
---|
177 |
|
---|
178 | SCRIPTLIST=`echo "${script_list}" | \
|
---|
179 | sed "s@\(.*\)@${scripts_dir}/\1@"`
|
---|
180 |
|
---|
181 | # Check if we are resuming from a particular script
|
---|
182 | test ! -z "${1}" &&
|
---|
183 | {
|
---|
184 | SCRIPTLIST=`echo ${SCRIPTLIST} | sed "s@.*\(${1}.*\)@\1@g"`
|
---|
185 | }
|
---|
186 |
|
---|
187 | echo ' o Checking for needed sources and tarballs'
|
---|
188 | check_tarballs ${SCRIPTLIST}
|
---|
189 |
|
---|
190 | for script in ${SCRIPTLIST}; do
|
---|
191 | echo "Running ${SCRIPTS}/${script}"
|
---|
192 | # HACK: export SELF to be the script we are running
|
---|
193 | # (keeps logfile output correct)
|
---|
194 | export SELF=${script}
|
---|
195 | ${SCRIPTS}/${script}
|
---|
196 |
|
---|
197 | test 0 = ${?} ||
|
---|
198 | {
|
---|
199 | echo
|
---|
200 | echo "Failed script was ${script}"
|
---|
201 | echo "Please fix the error above from"
|
---|
202 | echo " ${SCRIPTS}/${script}"
|
---|
203 | echo "and rerun the build with the command"
|
---|
204 | echo
|
---|
205 | echo " ${0} $script"
|
---|
206 | echo
|
---|
207 | echo "to resume the build."
|
---|
208 | exit 1
|
---|
209 | }
|
---|
210 | done
|
---|