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 | echo
|
---|
35 |
|
---|
36 | exit "$want_help"
|
---|
37 | fi
|
---|
38 |
|
---|
39 | if [ "$PWD" = "$SOURCE_DIR" ]; then
|
---|
40 | echo "We don't support in-tree build."
|
---|
41 | echo "Please create a build directory, cd into it, and run this script from there."
|
---|
42 | echo "Or run \`$0 --help\` to see usage."
|
---|
43 | exit 1
|
---|
44 | fi
|
---|
45 |
|
---|
46 | ninja_help() {
|
---|
47 | echo 'Run `ninja config` to adjust configuration.'
|
---|
48 | echo 'Run `ninja` to build all program and library binaries, but not bootable image.'
|
---|
49 | echo 'Run `ninja image_path` to build boot image. The file image_path will contain path to the boot image file.'
|
---|
50 | }
|
---|
51 |
|
---|
52 | if [ -f build.ninja ]; then
|
---|
53 | echo "This build directory was already configured."
|
---|
54 | echo
|
---|
55 | ninja_help
|
---|
56 | exit 0
|
---|
57 | fi
|
---|
58 |
|
---|
59 | # Run HelenOS config tool.
|
---|
60 | if [ "$#" -eq 1 ]; then
|
---|
61 | "${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" hands-off "$1" || exit 1
|
---|
62 | else
|
---|
63 | "${SOURCE_DIR}/tools/config.py" "${CONFIG_RULES}" "${CONFIG_DEFAULTS}" || exit 1
|
---|
64 | fi
|
---|
65 |
|
---|
66 | PLATFORM=`sed -n '/^PLATFORM\b/p' Makefile.config | sed 's:[^=]*= ::'`
|
---|
67 | MACHINE=`sed -n '/^MACHINE\b/p' Makefile.config | sed 's:[^=]*= ::'`
|
---|
68 |
|
---|
69 | cross_target="$PLATFORM"
|
---|
70 | if [ "$PLATFORM" = 'abs32le' ]; then
|
---|
71 | cross_target='ia32'
|
---|
72 | fi
|
---|
73 | if [ "$MACHINE" = 'bmalta' ]; then
|
---|
74 | cross_target='mips32eb'
|
---|
75 | fi
|
---|
76 |
|
---|
77 | meson "${SOURCE_DIR}" '.' --cross-file "${SOURCE_DIR}/meson/cross/${cross_target}" || exit 1
|
---|
78 |
|
---|
79 | echo
|
---|
80 | echo "Configuration for platform $PLATFORM finished."
|
---|
81 | echo
|
---|
82 | ninja_help
|
---|