4 # Copyright (c) 2013 Vojtech Horky
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # - Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # - Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # - The name of the author may not be used to endorse or promote products
17 # derived from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 # Calling harbour functions:
32 # These functions are always called in a subshell to "guard" them a little
33 # bit (variables set by the harbour, cd into package directory).
35 # Notice on usage of set -o errexit (set -e)
36 # We want to use that option for the harbour scripts to get rid of the
37 # "|| return 1" at the end of each line.
38 # Obvious solution is to wrap the call like this:
39 # ( set -o errexit; build ) || { hsct_error "..."; return 1; }
40 # This doesn't work because the whole subshell is then part of a ||
41 # operand and thus the set -e is ignored (even if it is a subshell).
42 # See https://groups.google.com/d/msg/gnu.bash.bug/NCK_0GmIv2M/y6RQF1AWUQkJ
43 # Thus, we need to use the following template to get past this:
44 # ( set -o errexit; build; exit $? );
45 # [ $? -eq 0 ] || { hsct_error "..."; return 1; }
47 # Also notice that we never ever call exit from the top-most shell when
48 # leaving after an error. That is to prevent terminating user shell when
49 # this script is sourced ("env" command). It complicates the error handling
50 # a bit but it is more reliable than trying to guess whether we are running
51 # in a subshell or not.
54 HSCT_HOME
=`which -- "$0" 2>/dev/null`
55 # Maybe, we are running Bash
56 [ -z "$HSCT_HOME" ] && HSCT_HOME
=`which -- "$BASH_SOURCE" 2>/dev/null`
57 HSCT_HOME
=`dirname -- "$HSCT_HOME"`
58 HSCT_HSCT
="$HSCT_HOME/hsct.sh"
62 HSCT_SOURCES_DIR
=`pwd`/sources
63 HSCT_BUILD_DIR
=`pwd`/build
64 HSCT_INCLUDE_DIR
=`pwd`/include
65 HSCT_LIB_DIR
=`pwd`/libs
66 HSCT_DIST_DIR
="`pwd`/dist/"
67 HSCT_ARCHIVE_DIR
="`pwd`/archives/"
68 HSCT_DISABLED_CFLAGS
="-Werror -Werror-implicit-function-declaration"
69 HSCT_CACHE_DIR
=`pwd`/helenos
72 # Does not exit the whole script.
75 echo " $1 action [package]"
76 echo " Action can be one of following:"
77 echo " clean Clean built directory."
78 echo " build Build given package."
79 echo " package Save installable files to allow cleaning."
80 echo " install Install to uspace/dist of HelenOS."
81 echo " archive Create tarball instead of installing."
82 echo " $1 update [rebuild]"
83 echo " Update the cached headers and libraries."
84 echo " If 'rebuild' is specified, HelenOS is forcefully rebuild and"
85 echo " cache is updated afterwards."
86 echo " $1 init /path/to/HelenOS [profile] [build]"
87 echo " Initialize current directory as coastline build directory".
88 echo " Full path has to be provided to the HelenOS source tree."
89 echo " If profile is specified, prepare for that configuration."
90 echo " If 'build' is given, forcefully rebuild to specified profile."
92 echo " Display this help and exit."
95 # Print high-level information message.
100 # Print lower-level information message (additional info after hsct_info).
105 # Print information message from HARBOUR script.
110 # Print high-level error message.
112 echo "[hsct]:" "Error:" "$@" >&2
115 # Print additional details to the error message.
117 echo "[hsct]:" " -> " "$@" >&2
120 # Run a command but print it first.
124 echo -n "$___i" |
sed -e 's#"#\\"#g' -e 's#.*#"&" #'
130 # Run comman from HARBOUR script and print it as well.
135 # Tells whether HelenOS in $HSCT_HELENOS_ROOT is configured.
136 hsct_is_helenos_configured
() {
137 [ -e "$HSCT_HELENOS_ROOT/Makefile.config" ]
141 # hsct_get_config CONFIG_FILE variable
143 grep '^[ \t]*'"$2" "$1" \
146 |
sed -e 's/^[ \t]*//' -e 's/[ \t]*$//'
149 # Fetch all the specified files in the HARBOUR
151 mkdir
-p "$HSCT_SOURCES_DIR"
152 hsct_info
"Fetching sources..."
153 for _url
in $shipsources; do
154 _filename
=`basename "$_url"`
155 if [ "$_filename" = "$_url" ]; then
158 if ! [ -r "$HSCT_SOURCES_DIR/$_filename" ]; then
159 hsct_info2
"Fetching $_filename..."
160 if ! wget
"$_url" -O "$HSCT_SOURCES_DIR/$_filename"; then
161 rm -f "$HSCT_SOURCES_DIR/$_filename"
162 hsct_error
"Failed to fetch $_url."
172 # get_var_from_makefile CC Makefile.common
173 hsct_get_var_from_makefile
() {
174 # echo "make -C `dirname "$2"` -f - -s __armagedon_" >&2
181 echo "CONFIG_DEBUG=n"
182 echo include
`basename "$2"`
183 echo "CONFIG_DEBUG=n"
185 echo "__armagedon__:"
188 ) |
make -C `dirname "$2"` -f - -s __armagedon__
191 # Retrieve variable from uspace/ Makefile.
192 hsct_get_var_from_uspace
() {
194 hsct_get_var_from_makefile
"$1" "$HSCT_HELENOS_ROOT/uspace/Makefile.common" "USPACE_PREFIX=$HSCT_HELENOS_ROOT/uspace"
196 hsct_get_var_from_makefile
"$1" "$HSCT_HELENOS_ROOT/uspace/$2" "USPACE_PREFIX=$HSCT_HELENOS_ROOT/uspace" "$3" "$4"
200 # Cache and export a variable.
203 hsct_cache_variable
() {
209 echo -n "export $1=\"";
210 echo -n "$2" |
sed -e 's#"#\\"#g' -e 's#\\#\\\\#g'
212 ) >>"$HSCT_CACHE_DIR/env.sh"
215 # Update the cache - copy headers, libraries etc to this directory.
216 # Does not check that update is possible!
217 hsct_cache_update
() {
218 hsct_info
"Caching headers, libraries and compile flags"
220 mkdir
-p "$HSCT_CACHE_DIR"
224 echo "# This is automatically generated file."
225 echo "# All changes will be LOST upon next invocation of hsct.sh"
227 ) >"$HSCT_CACHE_DIR/env.sh"
228 chmod +x
"$HSCT_CACHE_DIR/env.sh"
232 # Start with binaries
235 hsct_cache_variable HSCT_CC
`hsct_get_var_from_uspace CC`
236 hsct_cache_variable HSCT_AS
`hsct_get_var_from_uspace AS`
237 hsct_cache_variable HSCT_LD
`hsct_get_var_from_uspace LD`
238 hsct_cache_variable HSCT_AR
`hsct_get_var_from_uspace AR`
239 hsct_cache_variable HSCT_STRIP
`hsct_get_var_from_uspace STRIP`
240 hsct_cache_variable HSCT_OBJCOPY
`hsct_get_var_from_uspace OBJCOPY`
241 hsct_cache_variable HSCT_OBJDUMP
`hsct_get_var_from_uspace OBJDUMP`
242 # HelenOS do not use ranlib or nm but some applications require it
243 hsct_cache_variable HSCT_RANLIB
`echo "$HSCT_AR" | sed 's/-ar$/-ranlib/'`
244 hsct_cache_variable HSCT_NM
`echo "$HSCT_AR" | sed 's/-ar$/-nm/'`
249 hsct_cache_variable HSTC_HELENOS_ROOT
"$HSCT_HELENOS_ROOT"
250 hsct_cache_variable HSCT_INCLUDE_DIR
"$HSCT_INCLUDE_DIR"
251 hsct_cache_variable HSCT_LIB_DIR
"$HSCT_LIB_DIR"
252 hsct_cache_variable HSCT_MISC_DIR
"$HSCT_MISC_DIR"
253 hsct_cache_variable HSCT_APPS_DIR
"$HSCT_APPS_DIR"
254 hsct_cache_variable HSCT_CACHE_DIR
"$HSCT_CACHE_DIR"
255 hsct_cache_variable HSCT_CACHE_INCLUDE
"$HSCT_CACHE_DIR/include"
256 hsct_cache_variable HSCT_CACHE_LIB
"$HSCT_CACHE_DIR/lib/other"
259 # Get architecture, convert to target
261 hsct_cache_variable HSCT_UARCH
`hsct_get_var_from_uspace UARCH`
265 HSCT_GNU_TARGET
="amd64-linux-gnu"
266 HSCT_HELENOS_TARGET
="amd64-helenos"
269 HSCT_GNU_TARGET
="arm-linux-gnueabi"
270 HSCT_HELENOS_TARGET
="arm-helenos-gnueabi"
273 HSCT_GNU_TARGET
="i686-pc-linux-gnu"
274 HSCT_HELENOS_TARGET
="i686-pc-helenos"
277 HSCT_GNU_TARGET
="ia64-pc-linux-gnu"
278 HSCT_HELENOS_TARGET
="ia64-pc-helenos"
281 HSCT_GNU_TARGET
="mipsel-linux-gnu"
282 HSCT_HELENOS_TARGET
="mipsel-helenos"
285 HSCT_GNU_TARGET
="mips-linux-gnu"
286 HSCT_HELENOS_TARGET
="mips-helenos"
289 HSCT_GNU_TARGET
="mips64el-linux-gnu"
290 HSCT_HELENOS_TARGET
="mips64el-helenos"
293 HSCT_GNU_TARGET
="ppc-linux-gnu"
294 HSCT_HELENOS_TARGET
="ppc-helenos"
297 HSCT_GNU_TARGET
="ppc64-linux-gnu"
298 HSCT_HELENOS_TARGET
="ppc64-helenos"
301 HSCT_GNU_TARGET
="sparc-leon3-linux-gnu"
302 HSCT_HELENOS_TARGET
="sparc-leon3-helenos"
305 HSCT_GNU_TARGET
="sparc64-linux-gnu"
306 HSCT_HELENOS_TARGET
="sparc64-helenos"
309 hsct_error
'Unsupported architecture: $(UARCH) =' "'$HSCT_UARCH'."
313 hsct_cache_variable HSCT_GNU_TARGET
"$HSCT_GNU_TARGET"
314 hsct_cache_variable HSCT_HELENOS_TARGET
"$HSCT_HELENOS_TARGET"
315 case `hsct_get_var_from_uspace COMPILER` in
317 hsct_cache_variable HSCT_TARGET
"$HSCT_HELENOS_TARGET"
320 hsct_cache_variable HSCT_TARGET
"$HSCT_GNU_TARGET"
326 # Copy the files and update the flags accordingly
328 mkdir
-p "$HSCT_CACHE_INCLUDE"
329 mkdir
-p "$HSCT_CACHE_DIR/lib"
330 mkdir
-p "$HSCT_CACHE_LIB"
333 hsct_info2
"Copying linker script and startup object file"
334 _LINKER_SCRIPT
=`hsct_get_var_from_uspace LINKER_SCRIPT`
337 _STARTUP_OBJECT
=`sed -n 's#.*STARTUP(\([^)]*\)).*#\1#p' <"$_LINKER_SCRIPT" 2>/dev/null`
338 cp "$_STARTUP_OBJECT" "$HSCT_CACHE_DIR/lib/entry.o" ||
return 1
339 sed "s#$_STARTUP_OBJECT#$HSCT_CACHE_DIR/lib/entry.o#" \
340 <"$_LINKER_SCRIPT" >"$HSCT_CACHE_DIR/link.ld"
342 if [ $?
-ne 0 ]; then
343 hsct_error
"Failed preparing linker script."
347 _LINKER_SCRIPT
="$HSCT_CACHE_DIR/link.ld"
350 hsct_info2
"Copying libraries"
352 "$HSTC_HELENOS_ROOT/uspace/lib/c/libc.a" \
353 "$HSTC_HELENOS_ROOT/uspace/lib/math/libmath.a" \
354 "$HSTC_HELENOS_ROOT/uspace/lib/softint/libsoftint.a" \
355 "$HSTC_HELENOS_ROOT/uspace/lib/softfloat/libsoftfloat.a" \
356 "$HSTC_HELENOS_ROOT/uspace/lib/posix/libc4posix.a" \
357 "$HSTC_HELENOS_ROOT/uspace/lib/posix/libposixaslibc.a" \
358 "$HSCT_CACHE_DIR/lib/"
359 if [ $?
-ne 0 ]; then
360 hsct_error
"Failed copying libraries to cache."
365 hsct_info2
"Copying headers"
368 cp -L -R "$HSTC_HELENOS_ROOT/uspace/lib/posix/include/posix/" "$HSCT_CACHE_DIR/include/"
369 mkdir
-p "$HSCT_CACHE_DIR/include/libc"
370 cp -L -R "$HSTC_HELENOS_ROOT/uspace/lib/c/include/"* "$HSCT_CACHE_DIR/include/libc"
371 cp -L -R "$HSTC_HELENOS_ROOT/abi/include/abi/" "$HSCT_CACHE_DIR/include/"
372 cp -L -R "$HSTC_HELENOS_ROOT/uspace/lib/c/arch/$HSCT_UARCH/include/libarch/" "$HSCT_CACHE_DIR/include/"
373 # We intentionally merge libc and libmath again (as per C standard)
374 cp -L -R "$HSTC_HELENOS_ROOT/uspace/lib/math/include/"* "$HSCT_CACHE_DIR/include/libc"
375 cp -L -R "$HSTC_HELENOS_ROOT/uspace/lib/math/arch/$HSCT_UARCH/include/libarch/" "$HSCT_CACHE_DIR/include/"
376 ln -s -f -n "libc" "$HSCT_CACHE_DIR/include/libmath"
378 if [ $?
-ne 0 ]; then
379 hsct_error
"Failed copying headers to cache."
383 hsct_info2
"Fixing includes in libc headers"
384 find "$HSCT_CACHE_DIR/include/libc" "$HSCT_CACHE_DIR/include/libarch" -name '*.h' -exec sed \
385 -e 's:#include <:#include <libc/:' \
386 -e 's:#include <libc/libarch/:#include <libarch/:' \
387 -e 's:#include <libc/abi/:#include <abi/:' \
388 -e 's:#include <libc/libc/:#include <libc/:' \
391 # Remember the configuration
392 hsct_info2
"Saving config files"
395 cp "$HSTC_HELENOS_ROOT/config.h" "$HSCT_CACHE_INCLUDE/system_config.h"
396 cp "$HSTC_HELENOS_ROOT/Makefile.config" "$HSCT_CACHE_DIR/Makefile.config"
398 if [ $?
-ne 0 ]; then
399 hsct_error
"Failed saving config files."
403 # Extra libraries and headers
404 hsct_info2
"Copying extra headers and libraries"
408 cp -L "$HSTC_HELENOS_ROOT/uspace/lib/clui/libclui.a" "$HSCT_CACHE_LIB"
409 mkdir
-p "$HSCT_CACHE_INCLUDE/libclui/"
410 cp -L "$HSTC_HELENOS_ROOT/uspace/lib/clui/tinput.h" "$HSCT_CACHE_INCLUDE/libclui/"
412 if [ $?
-ne 0 ]; then
413 hsct_error
"Failed copying extra headers and libraries to cache."
420 hsct_info2
"Fixing compiler flags"
423 _CFLAGS
=`hsct_get_var_from_uspace CFLAGS`
424 _LDFLAGS
=`hsct_get_var_from_uspace LFLAGS`
427 #_CFLAGS=`echo "$_CFLAGS" | sed 's#-imacros[ \t]*\([^ \t]*/config.h\)#-imacros '"$HSCT_CACHE_DIR"'/include/system_config.h#'`
428 _CFLAGS_OLD
="$_CFLAGS"
431 for _flag
in $_CFLAGS_OLD; do
433 case "$_next_kind" in
438 if echo "$_flag" |
grep -q '/config.h$'; then
439 _flag
="$HSCT_CACHE_DIR/include/system_config.h"
447 for _disabled_flag
in $HSCT_DISABLED_CFLAGS; do
448 if [ "$_disabled_flag" = "$_flag" ]; then
454 if [ "$_flag" = "-L" ]; then
458 if [ "$_flag" = "-I" ]; then
462 if [ "$_flag" = "-imacros" ]; then
465 if echo "$_flag" |
grep -q '^-[IL]'; then
469 if ! $_disabled; then
470 _CFLAGS
="$_CFLAGS $_flag"
475 _LDFLAGS_OLD
="$_LDFLAGS"
477 for _flag
in $_LDFLAGS_OLD; do
479 # Get rid of library paths, the files are stored locally
480 if echo "$_flag" |
grep -q '^-[L]'; then
483 if ! $_disabled; then
484 _LDFLAGS
="$_LDFLAGS $_flag"
488 # Add paths to cached headers and libraries
489 _LDFLAGS
="$_LDFLAGS -L$HSCT_CACHE_DIR/lib -n -T $_LINKER_SCRIPT"
490 _CFLAGS
="$_CFLAGS -I$HSCT_CACHE_DIR/include/posix -I$HSCT_CACHE_DIR/include/"
492 # Actually used libraries
493 # The --whole-archive is used to allow correct linking of static libraries
494 # (otherwise, the ordering is crucial and we usally cannot change that in the
495 # application Makefiles).
496 _BASE_LIBS
=`hsct_get_var_from_uspace BASE_LIBS | sed 's#[ \t]\+#\n#g' | sed 's#.*/lib\(.*\).a$#\1#' | paste '-sd '`
500 _USE_SOFTFLOAT
="-lsoftfloat"
507 _USE_SOFTFLOAT
="-lsoftfloat"
510 _USE_SOFTFLOAT
="-lsoftfloat"
515 _POSIX_LINK_LFLAGS
="--whole-archive --start-group -lposixaslibc -lsoftint $_USE_SOFTFLOAT --end-group --no-whole-archive -lc4posix"
517 _LDFLAGS
="$_LDFLAGS $_POSIX_LINK_LFLAGS"
519 # The LDFLAGS might be used through CC, thus prefixing with -Wl is required
521 for _flag
in $_LDFLAGS; do
522 _LDFLAGS_FOR_CC
="$_LDFLAGS_FOR_CC -Wl,$_flag"
525 hsct_cache_variable HSCT_LDFLAGS
"$_LDFLAGS"
526 hsct_cache_variable HSCT_LDFLAGS_FOR_CC
"$_LDFLAGS_FOR_CC"
527 hsct_cache_variable HSCT_CFLAGS
"$_CFLAGS"
530 # Source the env.sh if present otherwise exit with failure.
532 if ! [ -e "$HSCT_CACHE_DIR/env.sh" ]; then
533 hsct_error
"Cache is not initialized. Maybe HelenOS is not configured?"
537 # Source env.sh to get HSCT_* variables
538 .
"$HSCT_CACHE_DIR/env.sh"
540 if [ "$shipfunnels" -gt "$HSCT_PARALLELISM" ] 2>/dev
/null
; then
541 shipfunnels
="$HSCT_PARALLELISM"
542 elif [ "$shipfunnels" -le "$HSCT_PARALLELISM" ] 2>/dev
/null
; then
543 if [ "$shipfunnels" -le "0" ]; then
544 shipfunnels
="$HSCT_PARALLELISM"
551 # Remove the build directory of given package.
553 hsct_info
"Cleaning build directory..."
554 rm -rf "$HSCT_BUILD_DIR/$shipname/"*
557 # Decide whether it is possible to update the cache.
558 hsct_can_update_cache
() {
559 # If HelenOS is configured, we want to update the cache.
560 # However, if architecture is specified only if the current
561 # configuration is the same.
562 _arch
=`hsct_get_config "$HSCT_CONFIG" arch`
563 if [ -z "$_arch" ]; then
564 # Building for any architecture. We update the cache if
565 # HelenOS is configured.
566 hsct_is_helenos_configured
569 # Update the cache only if HelenOS is configured and the
570 # architecture matches
571 if hsct_is_helenos_configured
; then
572 _uarch
=`hsct_get_var_from_uspace UARCH`
573 [ "$_uarch" = "$_arch" ]
583 mkdir
-p "$HSCT_BUILD_DIR/$shipname"
584 if [ -e "$HSCT_BUILD_DIR/${shipname}.built" ]; then
585 hsct_info
"No need to build $shipname."
589 if hsct_can_update_cache
; then
590 if ! hsct_cache_update
; then
595 # Check for prerequisities
596 for tug
in $shiptugs; do
597 if ! [ -e "$HSCT_BUILD_DIR/${tug}.packaged" ]; then
598 hsct_info
"Need to build $tug first."
599 hsct_info2
"Running $HSCT_HSCT package $tug"
601 $HSCT_HSCT package
$tug
604 if [ $?
-ne 0 ]; then
605 hsct_error
"Failed to package dependency $tug."
606 hsct_error2
"Cannot continue building $shipname."
609 hsct_info2
"Back from building $tug."
613 hsct_prepare_env ||
return 1
615 hsct_fetch ||
return 1
617 for _url
in $shipsources; do
618 _filename
=`basename "$_url"`
619 if [ "$_filename" = "$_url" ]; then
620 _origin
="$HSCT_HOME/$shipname/$_filename"
622 _origin
="$HSCT_SOURCES_DIR/$_filename"
624 ln -sf "$_origin" "$HSCT_BUILD_DIR/$shipname/$_filename"
628 cd "$HSCT_BUILD_DIR/$shipname/"
629 hsct_info
"Building..."
634 if [ $?
-ne 0 ]; then
635 hsct_error
"Build failed!"
638 touch "$HSCT_BUILD_DIR/${shipname}.built"
642 # Pseudo-installation - copy from build directory to "my" directory, copy libraries
644 mkdir
-p "$HSCT_INCLUDE_DIR" ||
{ hsct_error
"Failed to create include directory."; return 1; }
645 mkdir
-p "$HSCT_LIB_DIR" ||
{ hsct_error
"Failed to create library directory."; return 1; }
646 mkdir
-p "$HSCT_MY_DIR" ||
{ hsct_error
"Failed to create package directory."; return 1; }
648 if [ -e "$HSCT_BUILD_DIR/${shipname}.packaged" ]; then
649 hsct_info
"No need to package $shipname."
653 hsct_build ||
return 1
655 hsct_prepare_env ||
return 1
658 cd "$HSCT_BUILD_DIR/$shipname/"
659 hsct_info
"Packaging..."
664 if [ $?
-ne 0 ]; then
665 hsct_error
"Packaging failed!"
668 touch "$HSCT_BUILD_DIR/${shipname}.packaged"
672 # Install the package to HelenOS source tree (to uspace/overlay).
674 hsct_package ||
return 1
676 if ! hsct_can_update_cache
; then
677 hsct_error
"Installation cannot be performed."
678 hsct_error2
"HelenOS is not configured for the proper architecture."
682 hsct_info
"Installing..."
683 if ls "$HSCT_MY_DIR"/* &>/dev
/null
; then
684 cp -v -r -L "$HSCT_MY_DIR"/* "$HSCT_OVERLAY" ||
return 1
685 hsct_info2
"Do not forget to rebuild the image."
687 hsct_info2
"Note: nothing to install."
692 # Create tarball to allow redistribution of the build packages
694 hsct_package ||
return 1
696 hsct_info
"Creating the tarball..."
697 mkdir
-p "$HSCT_ARCHIVE_DIR"
700 cd "$HSCT_DIST_DIR/$shipname"
701 tar cJf
"$HSCT_ARCHIVE_DIR/$shipname.tar.xz" .
703 if [ $?
-ne 0 ]; then
704 hsct_error
"Archiving failed!"
712 # Initialize current directory for coastline building.
714 if [ -e "$HSCT_CONFIG" ]; then
715 hsct_error
"Directory is already initialized ($HSCT_CONFIG exists)."
719 hsct_info
"Initializing this build directory."
720 _root_dir
=`( cd "$1"; pwd ) 2>/dev/null`
721 if ! [ -e "$_root_dir/HelenOS.config" ]; then
722 hsct_error
"$1 does not look like a valid HelenOS directory.";
726 # If no architecture is specified, we would read it from
728 _uarch
=`hsct_get_var_from_uspace UARCH`
729 _machine
=`hsct_get_var_from_uspace MACHINE`
731 if [ -z "$_uarch" ]; then
732 hsct_error
"HelenOS is not configured and you haven't specified the architecture";
736 if [ "$3" = "build" ]; then
740 hsct_info2
"Cleaning previous configuration in $PWD."
741 make distclean
>/dev
/null
2>&1
742 hsct_info2
"Configuring for $2."
743 make Makefile.config
"PROFILE=$2" HANDS_OFF
=y
>/dev
/null
744 hsct_info2
"Building (may take a while)."
747 if [ $?
-ne 0 ]; then
748 hsct_error
"Failed to automatically configure HelenOS for $2."
751 _uarch
=`echo "$2" | cut '-d/' -f 1`
752 _machine
=`echo "$2" | cut '-d/' -f 2`
754 if [ "$_uarch" != "$2" ]; then
755 hsct_error
"HelenOS is configured for different architecture (maybe add 'build' parameter?)"
760 hsct_info2
"Generating the configuration file."
761 cat >$HSCT_CONFIG <<EOF_CONFIG
771 # Update the cache manually.
773 if [ "$1" = "rebuild" ]; then
774 hsct_info
"Rebuilding HelenOS to match local configuration"
777 cd "$HSCT_HELENOS_ROOT"
778 hsct_info2
"Cleaning previous configuration in $PWD."
779 make distclean
>/dev
/null
2>&1
780 hsct_info2
"Configuring for $HSCT_HELENOS_PROFILE."
781 make Makefile.config \
782 "PROFILE=$HSCT_HELENOS_PROFILE" HANDS_OFF
=y \
783 2>&1 >/dev
/null |
sed '/^Fetching current.*ok$/d'
784 hsct_info2
"Overriding configuration with the stored one."
785 cp "$HSCT_CACHE_DIR/Makefile.config" Makefile.config
786 cp "$HSCT_CACHE_DIR/include/system_config.h" config.h
787 hsct_info2
"Building (may take a while)."
790 if [ $?
-ne 0 ]; then
791 hsct_error
"Failed to automatically rebuild HelenOS."
795 if ! hsct_can_update_cache
; then
804 alias leave_script_ok
='return 0 2>/dev/null || exit 0'
805 alias leave_script_err
='return 1 2>/dev/null || exit 1'
814 HSCT_HELENOS_ROOT
="$2"
815 HSCT_LOAD_CONFIG
=false
817 update|clean|build|package|
install|archive
)
818 HSCT_LOAD_CONFIG
=true
827 if $HSCT_LOAD_CONFIG; then
828 if ! [ -e "$HSCT_CONFIG" ]; then
829 hsct_error
"Configuration file $HSCT_CONFIG missing."
832 HSCT_HELENOS_ROOT
=`hsct_get_config "$HSCT_CONFIG" root`
833 HSCT_HELENOS_ARCH
=`hsct_get_config "$HSCT_CONFIG" arch`
834 HSCT_HELENOS_MACHINE
=`hsct_get_config "$HSCT_CONFIG" machine`
835 HSCT_PARALLELISM
=`hsct_get_config "$HSCT_CONFIG" parallel`
837 if [ -z "$HSCT_HELENOS_ARCH" ]; then
838 hsct_error
"I don't know for which architecture you want to build."
842 if [ -z "$HSCT_HELENOS_MACHINE" ]; then
843 HSCT_HELENOS_PROFILE
="$HSCT_HELENOS_ARCH"
845 HSCT_HELENOS_PROFILE
="$HSCT_HELENOS_ARCH/$HSCT_HELENOS_MACHINE"
848 if ! [ "$HSCT_PARALLELISM" -ge 0 ] 2>/dev
/null
; then
853 if [ -z "$HSCT_HELENOS_ROOT" ]; then
854 hsct_error
"I don't know where is the HelenOS source root."
859 clean|build|package|
install|archive
)
860 HSCT_HARBOUR_NAME
="$2"
861 if [ -z "$HSCT_HARBOUR_NAME" ]; then
867 hsct_init
"$2" "$3" "$4"
875 hsct_error
"Internal error, we shall not get to this point!"
881 if ! [ -d "$HSCT_HOME/$HSCT_HARBOUR_NAME" ]; then
882 hsct_error
"Unknown package $2"
886 if ! [ -r "$HSCT_HOME/$HSCT_HARBOUR_NAME/HARBOUR" ]; then
887 hsct_error
"HARBOUR file missing." >&2
891 HSCT_OVERLAY
="$HSCT_HELENOS_ROOT/uspace/overlay"
892 HSCT_MY_DIR
="$HSCT_DIST_DIR/$HSCT_HARBOUR_NAME"
894 # Source the harbour to get access to the variables and functions
895 .
"$HSCT_HOME/$HSCT_HARBOUR_NAME/HARBOUR"
914 hsct_error
"Internal error, we shall not get to this point!"
919 if [ $?
-eq 0 ]; then