make.sh: Remove KGCC variable.
[people/teissler/ipfire-2.x.git] / tools / make-functions
CommitLineData
15679d9f 1#!/bin/bash
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
33e7a260 5# Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
70df8302
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21###############################################################################
15679d9f
MT
22#
23# Beautifying variables & presentation & input output interface
24#
70df8302 25###############################################################################
15679d9f
MT
26
27## Screen Dimentions
28# Find current screen size
29if [ -z "${COLUMNS}" ]; then
30 COLUMNS=$(stty size)
31 COLUMNS=${COLUMNS##* }
32fi
33
34# When using remote connections, such as a serial port, stty size returns 0
35if [ "${COLUMNS}" = "0" ]; then
36 COLUMNS=80
37fi
38
39## Measurements for positioning result messages
40RESULT_WIDTH=4
41TIME_WIDTH=8
42OPT_WIDTH=6
43VER_WIDTH=10
44RESULT_COL=$((${COLUMNS} - $RESULT_WIDTH - 4))
45TIME_COL=$((${RESULT_COL} - $TIME_WIDTH - 5))
46OPT_COL=$((${TIME_COL} - $OPT_WIDTH - 5))
47VER_COL=$((${OPT_COL} - $VER_WIDTH - 5))
48
49## Set Cursur Position Commands, used via echo -e
50SET_RESULT_COL="\\033[${RESULT_COL}G"
51SET_TIME_COL="\\033[${TIME_COL}G"
52SET_OPT_COL="\\033[${OPT_COL}G"
53SET_VER_COL="\\033[${VER_COL}G"
54
55# Define color for messages
56BOLD="\\033[1;39m"
57DONE="\\033[1;32m"
58SKIP="\\033[1;34m"
59WARN="\\033[1;35m"
60FAIL="\\033[1;31m"
61NORMAL="\\033[0;39m"
62
bcb9dc13
MT
63configure_target() {
64 local target_arch="${1}"
65
66 if [ "${target_arch}" = "default" ]; then
67 target_arch="$(configure_target_guess)"
68 fi
69
70 case "${target_arch}" in
71 i586)
72 BUILDTARGET="${TARGET_ARCH}-pc-linux-gnu"
73 CROSSTARGET="${BUILD_ARCH}-cross-linux-gnu"
74 CFLAGS_ARCH="-march=i586 -fomit-frame-pointer"
75 ;;
76
77 armv5tel)
78 BUILDTARGET="${TARGET_ARCH}-unknown-linux-gnueabi"
79 CROSSTARGET="${BUILD_ARCH}-cross-linux-gnueabi"
80 CFLAGS_ARCH="-march=armv5te -mfloat-abi=soft -fomit-frame-pointer"
81 MACHINE_TYPE="arm"
82 ;;
83
84 *)
85 exiterror "Cannot build for architure ${target_arch}"
86 ;;
87 esac
88
89 # Check if the QEMU helper is available if needed.
90 if qemu_is_required "${target_arch}"; then
91 local qemu_target_helper="$(qemu_find_target_helper_name "${target_arch}")"
92
93 if [ -n "${qemu_target_helper}" ]; then
94 QEMU_TARGET_HELPER="${qemu_target_helper}"
95 else
96 exiterror "Could not find a binfmt_misc helper entry for ${target_arch}"
97 fi
98 fi
99
100 TARGET_ARCH="${target_arch}"
101
102 # Old variable names
103 MACHINE="${TARGET_ARCH}"
104
105 CFLAGS="-O2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fPIC"
106 CFLAGS="${CFLAGS} -fstack-protector-all --param=ssp-buffer-size=4 ${CFLAGS_ARCH}"
107 CXXFLAGS="${CFLAGS}"
108 C2FLAGS="${CFLAGS}"
109 CXX2FLAGS="${CXXFLAGS}"
110}
111
112configure_target_guess() {
113 case "${BUILD_ARCH}" in
114 x86_64|i686|i586)
115 echo "i586"
116 ;;
117 armv7*|armv6*|armv5*)
118 echo "armv5tel"
119 ;;
120 *)
121 exiterror "Cannot guess target architecture"
122 ;;
123 esac
124}
125
15679d9f
MT
126evaluate() {
127 if [ "$?" -eq "0" ]; then
128 beautify message DONE
129 else
130 EXITCODE=$1
131 shift 1
132 beautify message FAIL
133 $*
134 if [ $EXITCODE -ne "0" ]; then
135 exit $EXITCODE
136 fi
137 fi
138}
139
140position_cursor()
141{
142 # ARG1=starting position on screen
143 # ARG2=string to be printed
144 # ARG3=offset, negative for left movement, positive for right movement, relative to ARG1
145 # For example if your starting position is column 50 and you want to print Hello three columns to the right
146 # of your starting position, your call will look like this:
147 # position_cursor 50 "Hello" 3 (you'll get the string Hello at position 53 (= 50 + 3)
148 # If on the other hand you want your string "Hello" to end three columns to the left of position 50,
149 # your call will look like this:
150 # position_cursor 50 "Hello" -3 (you'll get the string Hello at position 42 (= 50 - 5 -3)
151 # If you want to start printing at the exact starting location, use offset 0
152
153 START=$1
154 STRING=$2
155 OFFSET=$3
156
157 STRING_LENGTH=${#STRING}
158
159 if [ ${OFFSET} -lt 0 ]; then
160 COL=$((${START} + ${OFFSET} - ${STRING_LENGTH}))
161 else
162 COL=$((${START} + ${OFFSET}))
163 fi
164
165 SET_COL="\\033[${COL}G"
166
167 echo $SET_COL
168} # End of position_cursor()
169
170
171beautify()
172{
173 # Commands: build_stage, make_pkg, message, result
174 case "$1" in
175 message)
176 case "$2" in
177 DONE)
178 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
179 ;;
180 WARN)
181 echo -ne "${WARN}${3}${NORMAL}${SET_RESULT_COL}[${WARN} WARN ${NORMAL}]\n"
182 ;;
183 FAIL)
184 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
185 ;;
186 SKIP)
187 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
188 ;;
189 esac
190 ;;
0b59f25c 191 build_stage)
15679d9f 192 MESSAGE=$2
0b59f25c
MT
193 if [ "$STAGE_TIME_START" ]; then
194 LAST_STAGE_TIME=$[ `date +%s` - $STAGE_TIME_START ]
195 fi
7ab7a9b4 196 STAGE_TIME_START=`date +%s`
0b59f25c
MT
197 echo -ne "${BOLD}*** ${MESSAGE}${NORMAL}"
198 if [ "$LAST_STAGE_TIME" ]; then
199 echo -ne "${DONE} (Last stage took $LAST_STAGE_TIME secs)${NORMAL}"
200 fi
201 echo -ne "${BOLD}${SET_VER_COL} version${SET_OPT_COL} options${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
7ab7a9b4
MT
202 ;;
203 build_start)
204 BUILD_TIME_START=`date +%s`
205 ;;
206 build_end)
207 BUILD_TIME_END=`date +%s`
070fb401
CS
208 seconds=$[ $BUILD_TIME_END - $BUILD_TIME_START ]
209 hours=$((seconds / 3600))
210 seconds=$((seconds % 3600))
211 minutes=$((seconds / 60))
212 seconds=$((seconds % 60))
213
214 echo -ne "${DONE}***Build is finished now and took $hours hour(s) $minutes minute(s) $seconds second(s)!${NORMAL}\n"
7ab7a9b4 215 ;;
15679d9f
MT
216 make_pkg)
217 echo "$2" | while read PKG_VER PROGRAM OPTIONS
218 do
219 SET_VER_COL_REAL=`position_cursor $OPT_COL $PKG_VER -3`
220
221 if [ "$OPTIONS" == "" ]; then
222 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
223 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
224 else
225 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
226 echo -ne "${NORMAL} ]${SET_OPT_COL}[ ${BOLD}${OPTIONS}"
227 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
228 fi
229 done
230 ;;
231 result)
232 RESULT=$2
233
234 if [ ! $3 ]; then
235 PKG_TIME=0
236 else
237 PKG_TIME=$3
238 fi
239
240 SET_TIME_COL_REAL=`position_cursor $RESULT_COL $PKG_TIME -3`
241 case "$RESULT" in
242 DONE)
243 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
244 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
245 ;;
246 FAIL)
247 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
248 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
249 ;;
250 SKIP)
15679d9f
MT
251 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
252 ;;
253 esac
254 ;;
255 esac
256} # End of beautify()
257
258
259get_pkg_ver()
260{
33e7a260 261 PKG_VER=`grep -E "^VER |^VER=|^VER " $1 | awk '{print $3}'`
15679d9f
MT
262
263 if [ -z $PKG_VER ]; then
264 PKG_VER=`grep "Exp " $1 | awk '{print $4}'`
265 fi
33e7a260
AF
266 if [ -z $PKG_VER ]; then
267 PKG_VER="?"
268 fi
15679d9f
MT
269 if [ ${#PKG_VER} -gt $VER_WIDTH ]; then
270 # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters
271 # and replace enough characters to fit the resulting string on the screen. We'll replace
272 # the extra character with .. (two dots). That's why the "+ 2" in the formula below.
273 # Example: if we have a 21-long version number that we want to fit into a 10-long space,
274 # we have to remove 11 characters. But if we replace 11 characters with 2 characters, we'll
275 # end up with a 12-character long string. That's why we replace 12 characters with ..
276 REMOVE=`expr substr "$PKG_VER" 4 $[ ${#PKG_VER} - $VER_WIDTH + 2 ]`
277 PKG_VER=`echo ${PKG_VER/$REMOVE/..}`
278 fi
279
280 echo "$PKG_VER"
281} # End of get_pkg_ver()
282
15679d9f
MT
283# Define immediately
284stdumount() {
b4b6bcdb
MT
285 umount $BASEDIR/build/sys 2>/dev/null;
286 umount $BASEDIR/build/dev/shm 2>/dev/null;
15679d9f 287 umount $BASEDIR/build/dev/pts 2>/dev/null;
b4b6bcdb 288 umount $BASEDIR/build/dev 2>/dev/null;
15679d9f
MT
289 umount $BASEDIR/build/proc 2>/dev/null;
290 umount $BASEDIR/build/install/mnt 2>/dev/null;
291 umount $BASEDIR/build/usr/src/cache 2>/dev/null;
292 umount $BASEDIR/build/usr/src/ccache 2>/dev/null;
293 umount $BASEDIR/build/usr/src/config 2>/dev/null;
294 umount $BASEDIR/build/usr/src/doc 2>/dev/null;
295 umount $BASEDIR/build/usr/src/html 2>/dev/null;
296 umount $BASEDIR/build/usr/src/langs 2>/dev/null;
297 umount $BASEDIR/build/usr/src/lfs 2>/dev/null;
298 umount $BASEDIR/build/usr/src/log 2>/dev/null;
299 umount $BASEDIR/build/usr/src/src 2>/dev/null;
300}
301
302exiterror() {
303 stdumount
304 for i in `seq 0 7`; do
305 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
306 losetup -d /dev/loop${i} 2>/dev/null
307 fi;
308 done
309 echo -e "\nERROR: $*"
310 echo " Check $LOGFILE for errors if applicable"
311 exit 1
312}
313
b848d53c
MT
314fake_environ() {
315 [ -e "${BASEDIR}/build/tools/lib/libpakfire_preload.so" ] || return
316
317 local env="LD_PRELOAD=/tools/lib/libpakfire_preload.so"
318
319 # Fake kernel version, because some of the packages do not compile
320 # with kernel 3.0 and later.
321 env="${env} UTS_RELEASE=${KVER}"
322
323 # Fake machine version.
bcb9dc13
MT
324 env="${env} UTS_MACHINE=${TARGET_ARCH}"
325
326 echo "${env}"
327}
328
329qemu_environ() {
330 local env
331
332 # Don't add anything if qemu is not used.
333 if ! qemu_is_required; then
334 return
335 fi
336
337 # Set default qemu options
338 case "${TARGET_ARCH}" in
339 arm*)
340 QEMU_CPU="${QEMU_CPU:-cortex-a9}"
341
342 env="${env} QEMU_CPU=${QEMU_CPU}"
343 ;;
344 esac
345
346 # Enable QEMU strace
347 #env="${env} QEMU_STRACE=1"
b848d53c
MT
348
349 echo "${env}"
350}
351
bcb9dc13
MT
352qemu_is_required() {
353 local target_arch="${1}"
354
355 if [ -z "${target_arch}" ]; then
356 target_arch="${TARGET_ARCH}"
357 fi
358
359 case "${BUILD_ARCH},${target_arch}" in
360 x86_64,arm*|i?86,arm*)
361 return 0
362 ;;
363 *)
364 return 1
365 ;;
366 esac
367}
368
369qemu_install_helper() {
370 # Do nothing, if qemu is not required
371 if ! qemu_is_required; then
372 return 0
373 fi
374
375 if [ -z "${QEMU_TARGET_HELPER}" ]; then
376 exiterror "QEMU_TARGET_HELPER not set"
377 fi
378
379 # Check if the helper is already installed.
380 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
381 return 0
382 fi
383
384 # Try to find a suitable binary that we can install
385 # to the build environment.
386 local file
387 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
388 # file must exist and be executable.
389 [ -x "${file}" ] || continue
390
391 # Must be static.
392 file_is_static "${file}" || continue
393
394 local dirname="${LFS}$(dirname "${file}")"
395 mkdir -p "${dirname}"
396
397 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
398 return 0
399 done
400
401 exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
402}
403
404qemu_find_target_helper_name() {
405 local target_arch="${1}"
406
407 local magic
408 case "${target_arch}" in
409 arm*)
410 magic="7f454c4601010100000000000000000002002800"
411 ;;
412 esac
413
414 [ -z "${magic}" ] && return 1
415
416 local file
417 for file in /proc/sys/fs/binfmt_misc/*; do
418 # Search for the file with the correct magic value.
419 grep -qE "^magic ${magic}$" "${file}" || continue
420
421 local interpreter="$(grep "^interpreter" "${file}" | awk '{ print $2 }')"
422
423 [ -n "${interpreter}" ] || continue
424 [ "${interpreter:0:1}" = "/" ] || continue
425 [ -x "${interpreter}" ] || continue
426
427 echo "${interpreter}"
428 return 0
429 done
430
431 return 1
432}
433
434file_is_static() {
435 local file="${1}"
436
437 file ${file} 2>/dev/null | grep -q "statically linked"
438}
439
15679d9f
MT
440entershell() {
441 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
442 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
443 fi
b848d53c 444
bcb9dc13
MT
445 # Install QEMU helper, if needed
446 qemu_install_helper
447
15679d9f 448 echo "Entering to a shell inside LFS chroot, go out with exit"
bb0ab381 449 chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
e4783340 450 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
15679d9f
MT
451 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
452 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
453 CFLAGS="$CF2LAGS" CXXFLAGS="$CXX2FLAGS" \
454 CCACHE_DIR=/usr/src/ccache \
36d351ff 455 CCACHE_COMPRESS=1 \
ad92a4b8 456 CCACHE_COMPILERCHECK="none" \
15679d9f 457 KVER=$KVER \
df94e866 458 BUILDTARGET="$BUILDTARGET" \
c1b57e25 459 CROSSTARGET="${CROSSTARGET}" \
df94e866
MT
460 MACHINE="$MACHINE" \
461 MACHINE_TYPE="$MACHINE_TYPE" \
b848d53c 462 $(fake_environ) \
bcb9dc13 463 $(qemu_environ) \
a1531946 464 /tools/bin/bash -i
15679d9f
MT
465 if [ $? -ne 0 ]; then
466 beautify message FAIL
467 exiterror "chroot error"
468 else
469 stdumount
470 fi
471}
472
473############################################################################
474# #
475# Necessary shell functions #
476# #
477############################################################################
478#
479# Common checking before entering the chroot and compilling
480#
481# Return:0 caller can continue
482# :1 skip (nothing to do)
483# or fail if no script file found
484#
485lfsmakecommoncheck()
486{
15679d9f
MT
487 # Script present?
488 if [ ! -f $BASEDIR/lfs/$1 ]; then
489 exiterror "No such file or directory: $BASEDIR/$1"
490 fi
491
492 local PKG_VER=`get_pkg_ver $BASEDIR/lfs/$1`
493 beautify make_pkg "$PKG_VER $*"
494
846e756e
MT
495 # Check if this package is supported by our architecture.
496 # If no SUP_ARCH is found, we assume the package can be built for all.
497 if grep "^SUP_ARCH" ${BASEDIR}/lfs/${1} >/dev/null; then
498 # Check if package supports ${MACHINE} or all architectures.
499 if ! grep -E "^SUP_ARCH.*${MACHINE}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
500 beautify result SKIP
501 return 1
502 fi
503 fi
504
15679d9f
MT
505 # Script slipped?
506 local i
507 for i in $SKIP_PACKAGE_LIST
508 do
a50d04ab 509 if [ "$i" == "$1" ]; then
15679d9f
MT
510 beautify result SKIP
511 return 1;
512 fi
513 done
514
515 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
516
51f9e7ac 517 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
df94e866 518 MACHINE_TYPE="$MACHINE_TYPE" \
51f9e7ac 519 MESSAGE="$1\t " download >> $LOGFILE 2>&1
15679d9f
MT
520 if [ $? -ne 0 ]; then
521 exiterror "Download error in $1"
522 fi
523
51f9e7ac 524 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
df94e866 525 MACHINE_TYPE="$MACHINE_TYPE" \
51f9e7ac 526 MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
15679d9f
MT
527 if [ $? -ne 0 ]; then
528 exiterror "md5sum error in $1, check file in cache or signature"
529 fi
530
531 return 0 # pass all!
532} # End of lfsmakecommoncheck()
533
534lfsmake1() {
535 lfsmakecommoncheck $*
536 [ $? == 1 ] && return 0
537
538 local PKG_TIME_START=`date +%s`
539
540 cd $BASEDIR/lfs && make -f $* BUILDTARGET=$BUILDTARGET \
c1b57e25 541 CROSSTARGET="${CROSSTARGET}" \
15679d9f 542 MACHINE=$MACHINE \
df94e866 543 MACHINE_TYPE=$MACHINE_TYPE \
15679d9f
MT
544 LFS_BASEDIR=$BASEDIR \
545 ROOT=$LFS \
546 KVER=$KVER \
547 MAKETUNING=$MAKETUNING \
548 install >> $LOGFILE 2>&1
549 local COMPILE_SUCCESS=$?
550 local PKG_TIME_END=`date +%s`
551
552 if [ $COMPILE_SUCCESS -ne 0 ]; then
553 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
554 exiterror "Building $*";
555 else
556 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
557 fi
558
559 return 0
560}
561
562lfsmake2() {
563 lfsmakecommoncheck $*
564 [ $? == 1 ] && return 0
565
bcb9dc13
MT
566 # Install QEMU helper, if needed
567 qemu_install_helper
568
15679d9f 569 local PKG_TIME_START=`date +%s`
bb0ab381 570 chroot $LFS /tools/bin/env -i HOME=/root \
15679d9f 571 TERM=$TERM PS1='\u:\w\$ ' \
e4783340 572 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
065c9931 573 VERSION=$VERSION PAKFIRE_CORE="${PAKFIRE_CORE}" \
d02853e7 574 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
15679d9f
MT
575 CONFIG_ROOT=$CONFIG_ROOT \
576 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
577 CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
ad92a4b8
MT
578 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 \
579 CCACHE_COMPILERCHECK="none" \
15679d9f 580 KVER=$KVER MAKETUNING=$MAKETUNING \
c1b57e25
MT
581 BUILDTARGET="$BUILDTARGET" \
582 CROSSTARGET="${CROSSTARGET}" \
583 MACHINE="$MACHINE" \
df94e866 584 MACHINE_TYPE="$MACHINE_TYPE" \
bcb9dc13 585 $(qemu_environ) \
b848d53c 586 $(fake_environ) \
15679d9f
MT
587 /tools/bin/bash -x -c "cd /usr/src/lfs && \
588 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
589 local COMPILE_SUCCESS=$?
590 local PKG_TIME_END=`date +%s`
591
592 if [ $COMPILE_SUCCESS -ne 0 ]; then
593 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
594 exiterror "Building $*";
595 else
596 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
597 fi
598
599 return 0
600}
601
602ipfiremake() {
603 lfsmakecommoncheck $*
604 [ $? == 1 ] && return 0
605
bcb9dc13
MT
606 # Install QEMU helper, if needed
607 qemu_install_helper
608
15679d9f 609 local PKG_TIME_START=`date +%s`
bb0ab381 610 chroot $LFS /tools/bin/env -i HOME=/root \
15679d9f 611 TERM=$TERM PS1='\u:\w\$ ' \
e4783340 612 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
15679d9f 613 VERSION=$VERSION \
a01fc474 614 CORE=$CORE \
15679d9f
MT
615 CONFIG_ROOT=$CONFIG_ROOT \
616 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
5b6acb88 617 SYSTEM_RELEASE="$SYSTEM_RELEASE" \
15679d9f 618 CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
ad92a4b8
MT
619 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 \
620 CCACHE_COMPILERCHECK="none" \
15679d9f 621 KVER=$KVER MAKETUNING=$MAKETUNING \
c1b57e25
MT
622 BUILDTARGET="$BUILDTARGET" \
623 CROSSTARGET="${CROSSTARGET}" \
624 MACHINE="$MACHINE" \
df94e866 625 MACHINE_TYPE="$MACHINE_TYPE" \
bcb9dc13 626 $(qemu_environ) \
b848d53c 627 $(fake_environ) \
15679d9f
MT
628 /bin/bash -x -c "cd /usr/src/lfs && \
629 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
630
631 local COMPILE_SUCCESS=$?
632 local PKG_TIME_END=`date +%s`
633
634 if [ $COMPILE_SUCCESS -ne 0 ]; then
635 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
636 exiterror "Building $*";
637 else
638 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
639 fi
640 return 0
641}
642
643ipfiredist() {
0d909a4a
MT
644 lfsmakecommoncheck $*
645 [ $? == 1 ] && return 0
646
bcb9dc13
MT
647 # Install QEMU helper, if needed
648 qemu_install_helper
649
0d909a4a
MT
650 local PKG_TIME_START=`date +%s`
651 chroot $LFS /tools/bin/env -i HOME=/root \
652 TERM=$TERM PS1='\u:\w\$ ' \
e4783340 653 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
0d909a4a
MT
654 VERSION=$VERSION \
655 CONFIG_ROOT=$CONFIG_ROOT \
656 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
657 CFLAGS="$C2FLAGS" CXXFLAGS="$CXX2FLAGS" \
ad92a4b8
MT
658 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 \
659 CCACHE_COMPILERCHECK="none" \
3c937429 660 KVER=$KVER \
c1b57e25
MT
661 BUILDTARGET="$BUILDTARGET" \
662 CROSSTARGET="${CROSSTARGET}" \
663 MACHINE="$MACHINE" \
df94e866 664 MACHINE_TYPE="$MACHINE_TYPE" \
bcb9dc13 665 $(qemu_environ) \
b848d53c 666 $(fake_environ) \
0d909a4a
MT
667 /bin/bash -x -c "cd /usr/src/lfs && \
668 make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
669
670 local COMPILE_SUCCESS=$?
671 local PKG_TIME_END=`date +%s`
672
673 if [ $COMPILE_SUCCESS -ne 0 ]; then
674 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
675 exiterror "Packaging $*";
15679d9f 676 else
0d909a4a 677 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
15679d9f
MT
678 fi
679 return 0
680}
681
682installmake() {
41921bd9
MT
683 lfsmakecommoncheck $*
684 [ $? == 1 ] && return 0
685
bcb9dc13
MT
686 # Install QEMU helper, if needed
687 qemu_install_helper
688
41921bd9 689 local PKG_TIME_START=`date +%s`
bb0ab381 690 chroot $LFS /tools/bin/env -i HOME=/root \
15679d9f 691 TERM=$TERM PS1='\u:\w\$ ' \
e4783340 692 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
15679d9f 693 VERSION=$VERSION \
42e4fa80 694 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
15679d9f 695 CONFIG_ROOT=$CONFIG_ROOT \
15679d9f
MT
696 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
697 CFLAGS="-Os" CXXFLAGS="-Os" \
36d351ff 698 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 CCACHE_HASHDIR=1 \
3c937429 699 KVER=$KVER \
c1b57e25
MT
700 BUILDTARGET="$BUILDTARGET" \
701 CROSSTARGET="${CROSSTARGET}" \
702 MACHINE="$MACHINE" \
df94e866 703 MACHINE_TYPE="$MACHINE_TYPE" \
bc259fdc
MT
704 LD_LIBRARY_PATH=/tools/lib \
705 /tools/bin/bash -x -c "cd /usr/src/lfs && \
706 /tools/bin/make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
41921bd9
MT
707
708 local COMPILE_SUCCESS=$?
709 local PKG_TIME_END=`date +%s`
710
711 if [ $COMPILE_SUCCESS -ne 0 ]; then
712 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
713 exiterror "Building $*";
15679d9f 714 else
41921bd9 715 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
15679d9f
MT
716 fi
717 return 0
718}
719
8a5f0f44
MT
720update_langs() {
721 echo -ne "Checking the translations for missing or obsolete strings..."
1065bfea 722 chmod 755 $BASEDIR/tools/{check_strings.pl,sort_strings.pl,check_langs.sh}
8a5f0f44
MT
723 $BASEDIR/tools/sort_strings.pl en
724 $BASEDIR/tools/sort_strings.pl de
e73e134c
AF
725 $BASEDIR/tools/sort_strings.pl fr
726 $BASEDIR/tools/sort_strings.pl es
196e5f8f 727 $BASEDIR/tools/sort_strings.pl pl
2bb7b134 728 $BASEDIR/tools/sort_strings.pl ru
b34dac1f 729 $BASEDIR/tools/sort_strings.pl nl
910193da 730 $BASEDIR/tools/sort_strings.pl tr
8a5f0f44
MT
731 $BASEDIR/tools/check_strings.pl en > $BASEDIR/doc/language_issues.en
732 $BASEDIR/tools/check_strings.pl de > $BASEDIR/doc/language_issues.de
e73e134c
AF
733 $BASEDIR/tools/check_strings.pl fr > $BASEDIR/doc/language_issues.fr
734 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.es
196e5f8f 735 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.pl
2bb7b134 736 $BASEDIR/tools/check_strings.pl ru > $BASEDIR/doc/language_issues.ru
b34dac1f 737 $BASEDIR/tools/check_strings.pl nl > $BASEDIR/doc/language_issues.nl
910193da 738 $BASEDIR/tools/check_strings.pl tr > $BASEDIR/doc/language_issues.tr
8a5f0f44
MT
739 $BASEDIR/tools/check_langs.sh > $BASEDIR/doc/language_missings
740 beautify message DONE
741}