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