2019-08-10 17:57:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2016-08-04 00:31:35 +02:00
|
|
|
# tools/sethost.sh
|
|
|
|
#
|
2020-04-27 19:22:40 +02:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership. The
|
|
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance with the
|
|
|
|
# License. You may obtain a copy of the License at
|
2016-08-04 00:31:35 +02:00
|
|
|
#
|
2020-04-27 19:22:40 +02:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2016-08-04 00:31:35 +02:00
|
|
|
#
|
2020-04-27 19:22:40 +02:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2016-08-04 00:31:35 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
progname=$0
|
2020-02-06 08:16:53 +01:00
|
|
|
host=
|
|
|
|
wenv=
|
2016-08-04 00:31:35 +02:00
|
|
|
|
|
|
|
function showusage {
|
2020-01-05 17:29:59 +01:00
|
|
|
echo ""
|
2020-03-21 11:14:41 +01:00
|
|
|
echo "USAGE: $progname [-l|m|c|u|g|n] [make-opts]"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo " $progname -h"
|
|
|
|
echo ""
|
|
|
|
echo "Where:"
|
2020-01-19 18:29:34 +01:00
|
|
|
echo " -l|m|c|u|g|n selects Linux (l), macOS (m), Cygwin (c),"
|
|
|
|
echo " Ubuntu under Windows 10 (u), MSYS/MSYS2 (g)"
|
|
|
|
echo " or Windows native (n). Default Linux"
|
2020-03-20 05:08:27 +01:00
|
|
|
echo " make-opts directly pass to make"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo " -h will show this help test and terminate"
|
|
|
|
exit 1
|
2016-08-04 00:31:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse command line
|
|
|
|
|
|
|
|
while [ ! -z "$1" ]; do
|
2020-01-05 17:29:59 +01:00
|
|
|
case $1 in
|
|
|
|
-l )
|
|
|
|
host=linux
|
|
|
|
;;
|
|
|
|
-c )
|
|
|
|
host=windows
|
|
|
|
wenv=cygwin
|
|
|
|
;;
|
|
|
|
-g )
|
|
|
|
host=windows
|
|
|
|
wenv=msys
|
|
|
|
;;
|
|
|
|
-u )
|
|
|
|
host=windows
|
|
|
|
wenv=ubuntu
|
|
|
|
;;
|
|
|
|
-m )
|
|
|
|
host=macos
|
|
|
|
;;
|
|
|
|
-n )
|
|
|
|
host=windows
|
|
|
|
wenv=native
|
|
|
|
;;
|
|
|
|
-h )
|
|
|
|
showusage
|
|
|
|
;;
|
|
|
|
* )
|
2020-03-20 05:08:27 +01:00
|
|
|
break
|
2020-01-05 17:29:59 +01:00
|
|
|
;;
|
2016-08-04 00:31:35 +02:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2020-02-06 08:16:53 +01:00
|
|
|
# If the host was not explicitly given, try to guess.
|
|
|
|
# Examples of "uname -s" outputs:
|
|
|
|
# macOS: Darwin
|
|
|
|
# Cygwin: CYGWIN_NT-10.0-WOW
|
|
|
|
# Linux: Linux
|
|
|
|
# MSYS: MINGW32_NT-6.2
|
2020-03-28 18:04:23 +01:00
|
|
|
|
2020-02-06 08:16:53 +01:00
|
|
|
if [ -z "$host" ]; then
|
|
|
|
case $(uname -s) in
|
|
|
|
Darwin)
|
|
|
|
host=macos
|
|
|
|
;;
|
|
|
|
CYGWIN*)
|
|
|
|
host=windows
|
|
|
|
wenv=cygwin
|
|
|
|
;;
|
|
|
|
MINGW32*)
|
|
|
|
host=windows
|
|
|
|
wenv=msys
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Assume linux as a fallback
|
2020-03-28 18:04:23 +01:00
|
|
|
|
2020-02-06 08:16:53 +01:00
|
|
|
host=linux
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2020-03-19 03:41:36 +01:00
|
|
|
WD=`test -d ${0%/*} && cd ${0%/*}; pwd`
|
|
|
|
cd $WD
|
|
|
|
|
2016-08-04 00:31:35 +02:00
|
|
|
if [ -x sethost.sh ]; then
|
2020-03-20 05:08:27 +01:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -x tools/sethost.sh ]; then
|
|
|
|
nuttx=$PWD
|
2016-08-04 00:31:35 +02:00
|
|
|
else
|
2020-03-28 18:04:23 +01:00
|
|
|
echo "This script must be executed in nuttx/ or nuttx/tools directories"
|
2020-03-20 05:08:27 +01:00
|
|
|
exit 1
|
2016-08-04 00:31:35 +02:00
|
|
|
fi
|
|
|
|
|
2020-03-19 04:47:34 +01:00
|
|
|
if [ ! -r $nuttx/.config ]; then
|
|
|
|
echo "There is no .config at $nuttx"
|
|
|
|
exit 1
|
2016-08-04 00:31:35 +02:00
|
|
|
fi
|
|
|
|
|
2020-03-19 04:47:34 +01:00
|
|
|
if [ ! -r $nuttx/Make.defs ]; then
|
|
|
|
echo "ERROR: No readable Make.defs file exists at $nuttx"
|
|
|
|
exit 1
|
2016-08-04 00:31:35 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Modify the configuration
|
|
|
|
|
2018-06-01 22:21:04 +02:00
|
|
|
if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" ]; then
|
2016-08-04 00:31:35 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
# Disable Windows (to suppress warnings from Window Environment selections)
|
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_WINDOWS
|
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Enable Linux or macOS
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ "X$host" == "Xlinux" ]; then
|
|
|
|
echo " Select CONFIG_HOST_LINUX=y"
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_LINUX
|
2020-01-05 17:29:59 +01:00
|
|
|
else
|
|
|
|
echo " Select CONFIG_HOST_MACOS=y"
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_MACOS
|
2020-01-05 17:29:59 +01:00
|
|
|
fi
|
2016-08-04 00:31:35 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
# Enable the System V ABI
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_SYSTEMV
|
2016-08-04 00:31:35 +02:00
|
|
|
else
|
2020-01-05 17:29:59 +01:00
|
|
|
echo " Select CONFIG_HOST_WINDOWS=y"
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
# Enable Windows and the Microsoft ABI
|
2016-08-04 00:31:35 +02:00
|
|
|
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_WINDOWS
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_MICROSOFT
|
2018-05-31 19:53:09 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Enable Windows environment
|
2018-06-01 22:21:04 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ "X$wenv" == "Xcygwin" ]; then
|
|
|
|
echo " Select CONFIG_WINDOWS_CYGWIN=y"
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_CYGWIN
|
2020-01-05 17:29:59 +01:00
|
|
|
else
|
|
|
|
if [ "X$wenv" == "Xmsys" ]; then
|
|
|
|
echo " Select CONFIG_WINDOWS_MSYS=y"
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_MSYS
|
2016-08-04 00:31:35 +02:00
|
|
|
else
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ "X$wenv" == "Xubuntu" ]; then
|
|
|
|
echo " Select CONFIG_WINDOWS_UBUNTU=y"
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_UBUNTU
|
2017-01-01 22:34:23 +01:00
|
|
|
else
|
2020-01-05 17:29:59 +01:00
|
|
|
echo " Select CONFIG_WINDOWS_NATIVE=y"
|
2020-04-27 19:22:40 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_NATIVE
|
2017-01-01 22:34:23 +01:00
|
|
|
fi
|
2016-08-04 00:31:35 +02:00
|
|
|
fi
|
2020-01-05 17:29:59 +01:00
|
|
|
fi
|
2016-08-04 00:31:35 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo " Refreshing..."
|
2020-03-23 20:15:18 +01:00
|
|
|
|
2020-07-16 14:19:44 +02:00
|
|
|
make olddefconfig $* || { echo "ERROR: failed to refresh"; exit 1; }
|