Subversion Repositories QNX 8.QNX8 GNU binutils

Rev

Rev 14 | Rev 19 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 15
Line 36... Line 36...
36
}
36
}
37
 
37
 
38
# verify we're a x86_64 Linux host
38
# verify we're a x86_64 Linux host
39
if [ ! "$(uname)" = "Linux" ] || [ ! "$(uname -m)" = "x86_64" ]; then
39
if [ ! "$(uname)" = "Linux" ] || [ ! "$(uname -m)" = "x86_64" ]; then
40
        print_error_and_die "Error: this script requires a x86_64 Linux machine (possibly a virtual machine) as the build host."
40
        print_error_and_die "Error: this script requires a x86_64 Linux machine (possibly a virtual machine) as the build host."
41
fi
-
 
42
 
-
 
43
# verify that we have the QNX platform SDK
-
 
44
if [ ! -d "${QNXSDK_PATH}/${QNXSDK_HOSTPATH}" ] || [ ! -d "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}" ]; then
-
 
45
        print_error_and_die "Error: the ${QNXSDK_PATH} path doesn't contain a QNX SDK. It must contain the 'host' and 'target' directories of the QNX SDP for the targeted version of QNX and the ${BUILD_TARGET_ARCH} platform. Please deploy these directories and try again."
-
 
46
fi
41
fi
47
 
42
 
48
# verify that we have the required tools
43
# verify that we have the required tools
49
for REQUIRED_TOOL in ${REQUIRED_TOOLS}; do
44
for REQUIRED_TOOL in ${REQUIRED_TOOLS}; do
50
        "${REQUIRED_TOOL}" --version > /dev/null 2>&1 || print_error_and_die \
45
        "${REQUIRED_TOOL}" --version > /dev/null 2>&1 || print_error_and_die \
51
                "Error: this script requires at the very least the following tools installed:" \
46
                "Error: this script requires at the very least the following tools installed:" \
52
                "       $(echo "${REQUIRED_TOOLS}"|sed 's/ /\n  /g')" \
47
                "       $(echo "${REQUIRED_TOOLS}"|sed 's/ /\n  /g')" \
53
                "Please install them (possibly as binary packages with apt-get) and try again." \
48
                "Please install them (possibly as binary packages with apt-get) and try again." \
54
                "More specifically, the following tool was not found: '${REQUIRED_TOOL}'"
49
                "More specifically, the following tool was not found: '${REQUIRED_TOOL}'"
55
done
50
done
-
 
51
 
-
 
52
# verify that we have the QNX platform SDK
-
 
53
if [ ! -d "${QNXSDK_PATH}/${QNXSDK_HOSTPATH}" ] || [ ! -d "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}" ]; then
-
 
54
        print_error_and_die "Error: the ${QNXSDK_PATH} path doesn't contain a QNX SDK. It must contain the 'host' and 'target' directories of the QNX SDP for the targeted version of QNX and the ${BUILD_TARGET_ARCH} platform. Please deploy these directories and try again."
-
 
55
fi
-
 
56
 
-
 
57
# change to an immediately visible path, i.e. the user's desktop (failsafe to $HOME if xdg-user-dir is unavailable or points to a nonexistent directory)
-
 
58
STAGING_PATH="$(xdg-user-dir DESKTOP 2>/dev/null || echo "${HOME}")"
-
 
59
test -d "${STAGING_PATH}" || STAGING_PATH="${HOME}"
-
 
60
cd "${STAGING_PATH}"
-
 
61
 
-
 
62
# are we running the Windows Subsystem for Linux, instead of a real Linux ?
-
 
63
if [ -n "${WSL_DISTRO_NAME}" ]; then
-
 
64
        # yes. In order to avoid the horrible 9p protocol for file interchange between NTFS and ext4 (a remarkably bad idea by Microsoft),
-
 
65
        # use the copy of the QNX SDP that our caller is supposed to have put in our $HOME in the WSL2 filesystem. The speed gain is considerable.
-
 
66
        QNXSDK_CANONICAL_PATH="${HOME}/$(basename "${QNXSDK_PATH}")"
-
 
67
        if [ ! -d "${QNXSDK_CANONICAL_PATH}/${QNXSDK_HOSTPATH}" ] || [ ! -d "${QNXSDK_CANONICAL_PATH}/${QNXSDK_TARGETPATH}" ]; then
-
 
68
                print_error_and_die "Error: the QNX SDP hasn't been deployed to ${QNXSDK_CANONICAL_PATH}. Please do so and run this script again."
-
 
69
        fi
-
 
70
else
-
 
71
        # we're not in WSL. We can expect reasonably good file access speeds to the QNX SDP that's bundled with this repository, so just use it.
-
 
72
        QNXSDK_CANONICAL_PATH="$(realpath "${CURRENT_DIR}/${QNXSDK_PATH}")"
-
 
73
fi
56
 
74
 
57
# verify that the symlinks are deployed in the SDK -- just test one of them in each relevant directory ($QNX_HOST for the tools, $QNX_TARGET for the sysroot)
75
# verify that the symlinks are deployed in the SDK -- just test one of them in each relevant directory ($QNX_HOST for the tools, $QNX_TARGET for the sysroot)
58
if [ ! -e "${QNXSDK_PATH}/${QNXSDK_HOSTPATH}/usr/bin/gcc" ] || [ ! -e "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}/usr/include/readline.h" ]; then
76
if [ ! -e "${QNXSDK_CANONICAL_PATH}/${QNXSDK_HOSTPATH}/usr/bin/gcc" ] || [ ! -e "${QNXSDK_CANONICAL_PATH}/${QNXSDK_TARGETPATH}/usr/include/readline.h" ]; then
59
        print_error_and_die \
77
        print_error_and_die \
60
                "Error: the toolchain platform-specific symbolic links have not been deployed in this QNX SDK. Please run" \
78
                "Error: the toolchain platform-specific symbolic links have not been deployed in this QNX SDK. Please run" \
61
                "(on a POSIX machine:)" \
79
                "(on a POSIX machine:)" \
62
                "       cd ${QNXSDK_PATH}" \
80
                "       cd ${QNXSDK_CANONICAL_PATH}" \
63
                "       find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state" \
81
                "       find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state" \
64
                "(else on a Windows machine:)" \
82
                "(else on a Windows machine:)" \
65
                "       cd %QNXSDK_PATH%" \
83
                "       cd ${QNXSDK_CANONICAL_PATH}" \
66
                "       host\\win64\\x86_64\\usr\\bin\\busybox.exe sh -c \"find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state\"" \
84
                "       host\\win64\\x86_64\\usr\\bin\\busybox.exe sh -c \"find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state\"" \
67
                "Note that this step WILL take time on a Win32 machine, but is only done once."
85
                "Note that this step WILL take time on a Win32 machine, but is only done once."
68
fi
86
fi
69
 
87
 
70
# create a symlink in /tmp that will lead to the QNX platform SDK so as to avoid spaces in paths if it doesn't exist already
88
# Create a symlink in /tmp that will lead to the QNX platform SDK so as to avoid spaces in paths if it doesn't exist already
71
# (this is totally prohibitive with the official QNX toolchain)
89
# (this is totally prohibitive with the official QNX toolchain)
72
if [ ! -L /tmp/qnxsdk ] || [ ! "$(readlink /tmp/qnxsdk)" = "$(realpath "${CURRENT_DIR}/${QNXSDK_PATH}")" ]; then
90
if [ ! -L /tmp/qnxsdk ] || [ ! "$(readlink /tmp/qnxsdk)" = "${QNXSDK_CANONICAL_PATH}" ]; then
73
        echo "Creating symlink to QNX toolchain in /tmp/qnxsdk..."
91
        echo "Creating symlink to QNX toolchain in /tmp/qnxsdk..."
74
        rm -rf /tmp/qnxsdk 2>/dev/null
92
        rm -rf /tmp/qnxsdk 2>/dev/null
75
        ln -fs "$(realpath "${CURRENT_DIR}/${QNXSDK_PATH}")" /tmp/qnxsdk || exit 1
93
        ln -fs "${QNXSDK_CANONICAL_PATH}" /tmp/qnxsdk || exit 1
76
fi
94
fi
77
 
95
 
78
# setup the environment
96
# setup the environment
79
export QNX_HOST="/tmp/qnxsdk/${QNXSDK_HOSTPATH}"
97
export QNX_HOST="/tmp/qnxsdk/${QNXSDK_HOSTPATH}"
80
export QNX_TARGET="/tmp/qnxsdk/${QNXSDK_TARGETPATH}"
98
export QNX_TARGET="/tmp/qnxsdk/${QNXSDK_TARGETPATH}"
Line 83... Line 101...
83
 
101
 
84
# print the build environment
102
# print the build environment
85
echo "QNX_HOST=${QNX_HOST}"
103
echo "QNX_HOST=${QNX_HOST}"
86
echo "QNX_TARGET=${QNX_TARGET}"
104
echo "QNX_TARGET=${QNX_TARGET}"
87
echo "MAKEFLAGS=${MAKEFLAGS}"
105
echo "MAKEFLAGS=${MAKEFLAGS}"
88
 
-
 
89
# change to an immediately visible path, i.e. the user's desktop (failsafe to $HOME if xdg-user-dir is unavailable or points to a nonexistent directory)
-
 
90
STAGING_PATH="$(xdg-user-dir DESKTOP 2>/dev/null || echo "${HOME}")"
-
 
91
test -d "${STAGING_PATH}" || STAGING_PATH="${HOME}"
-
 
92
cd "${STAGING_PATH}"
-
 
93
 
106
 
94
# download the involved source packages and unpack them if not done yet
107
# download the involved source packages and unpack them if not done yet
95
download_and_unpack_if_necessary()
108
download_and_unpack_if_necessary()
96
{
109
{
97
        # helper function that downloads a sources tarball, extracts it and patches it if necessary
110
        # helper function that downloads a sources tarball, extracts it and patches it if necessary
Line 289... Line 302...
289
 
302
 
290
        # return to the sources dir and proceed to the next arch
303
        # return to the sources dir and proceed to the next arch
291
        cd ../..
304
        cd ../..
292
done
305
done
293
 
306
 
294
/bin/printf "\n\xf0\x9f\x8d\xba\x20\x43\x68\x65\x65\x72\x73\x2e\n"
307
test -z "${WSL_DISTRO_NAME}" && /bin/printf "\n\xf0\x9f\x8d\xba\x20\x43\x68\x65\x65\x72\x73\x2e\n"
295
exit 0
308
exit 0