| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | # Find out the path to the script.
|
|---|
| 4 | SOURCE_DIR=`which -- "$0" 2>/dev/null`
|
|---|
| 5 | # Maybe we are running bash.
|
|---|
| 6 | [ -z "$SOURCE_DIR" ] && SOURCE_DIR=`which -- "$BASH_SOURCE"`
|
|---|
| 7 | [ -z "$SOURCE_DIR" ] && exit 1
|
|---|
| 8 | SOURCE_DIR=`dirname -- "$SOURCE_DIR"`
|
|---|
| 9 | SOURCE_DIR=`cd $SOURCE_DIR && echo $PWD`
|
|---|
| 10 |
|
|---|
| 11 | CONFIG_RULES="${SOURCE_DIR}/HelenOS.config"
|
|---|
| 12 | CONFIG_DEFAULTS="${SOURCE_DIR}/defaults"
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | test "$#" -eq 1 && { test "$1" = "-h" || test "$1" = "--help"; }
|
|---|
| 16 | want_help="$?"
|
|---|
| 17 |
|
|---|
| 18 | if [ "$#" -gt 1 ] || [ "$want_help" -eq 0 ]; then
|
|---|
| 19 |
|
|---|
| 20 | # Find all the leaf subdirectories in the defaults directory.
|
|---|
| 21 | PROFILES=`find ${CONFIG_DEFAULTS} -type d -links 2 -printf "%P\n" | sort`
|
|---|
| 22 |
|
|---|
| 23 | echo "Configures the current working directory as a HelenOS build directory."
|
|---|
| 24 | echo "In-tree build is not supported, you must create a separate directory for build."
|
|---|
| 25 | echo
|
|---|
| 26 | echo "Usage:"
|
|---|
| 27 | echo " $0 -h|--help"
|
|---|
| 28 | echo " $0 [PROFILE]"
|
|---|
| 29 | echo
|
|---|
| 30 | echo "If profile is not specified, a graphical configuration utility is launched."
|
|---|
| 31 | echo
|
|---|
| 32 | echo "Possible profiles:"
|
|---|
| 33 | printf "\t%s\n" $PROFILES
|
|---|
| 34 |
|
|---|
| 35 | exit "$want_help"
|
|---|
| 36 | fi
|
|---|
| 37 |
|
|---|
| 38 | if [ "$PWD" = "$SOURCE_DIR" ]; then
|
|---|
| 39 | echo "We don't support in-tree build."
|
|---|
| 40 | echo "Please create a build directory, cd into it, and run this script from there."
|
|---|
| 41 | echo "Or run \`$0 --help\` to see usage."
|
|---|
| 42 | exit 1
|
|---|
| 43 | fi
|
|---|
| 44 |
|
|---|
| 45 | ninja_help() {
|
|---|
| 46 | echo 'Run `ninja config` to adjust configuration.'
|
|---|
| 47 | echo 'Run `ninja` to build all program and library binaries, but not bootable image.'
|
|---|
| 48 | echo 'Run `ninja image_path` to build boot image. The file image_path will contain path to the boot image file.'
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | if [ -f build.ninja ]; then
|
|---|
| 52 | echo "This build directory was already configured."
|
|---|
| 53 | echo
|
|---|
| 54 | ninja_help
|
|---|
| 55 | exit 0
|
|---|
| 56 | fi
|
|---|
| 57 |
|
|---|
| 58 | # Run HelenOS config tool.
|
|---|
| 59 | if [ "$#" -eq 1 ]; then
|
|---|
| 60 | "${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" hands-off "$1" || exit 1
|
|---|
| 61 | else
|
|---|
| 62 | "${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" || exit 1
|
|---|
| 63 | fi
|
|---|
| 64 |
|
|---|
| 65 | PLATFORM=`sed -n '/^PLATFORM\b/p' Makefile.config | sed 's:[^=]*= ::'`
|
|---|
| 66 | MACHINE=`sed -n '/^MACHINE\b/p' Makefile.config | sed 's:[^=]*= ::'`
|
|---|
| 67 |
|
|---|
| 68 | cross_target="$PLATFORM"
|
|---|
| 69 | if [ "$PLATFORM" = 'abs32le' ]; then
|
|---|
| 70 | cross_target='ia32'
|
|---|
| 71 | fi
|
|---|
| 72 | if [ "$MACHINE" = 'bmalta' ]; then
|
|---|
| 73 | cross_target='mips32eb'
|
|---|
| 74 | fi
|
|---|
| 75 |
|
|---|
| 76 | meson "${SOURCE_DIR}" '.' --cross-file "${SOURCE_DIR}/meson/cross/${cross_target}" || exit 1
|
|---|
| 77 |
|
|---|
| 78 | echo
|
|---|
| 79 | echo "Configuration for platform $PLATFORM finished."
|
|---|
| 80 | echo
|
|---|
| 81 | ninja_help
|
|---|