From 2abe1e9282684f742b355247851e1419c98754d3 Mon Sep 17 00:00:00 2001 From: Tomasz 'CeDeROM' CEDRO Date: Sat, 16 Oct 2021 18:30:54 +0200 Subject: [PATCH] configure/sethost: Add BSD host (-B switch) + MAKECMD (make vs gmake). This patch adds -B switch to select BSD host platforms. Linux uses GNU Make as default, command is `make`. BSD uses BSD Make as default, command is also `make`. BSD can also use GNU Make, but the command is `gmake`. This patch uses `make` on GNU platforms and `gmake` on BSD platforms. Signed-off-by: Tomasz 'CeDeROM' CEDRO tools/sethost.sh: Add BSD host (-B switch) + MAKECMD (make vs gmake). Signed-off-by: Tomasz 'CeDeROM' CEDRO tools/configure.c: Add BSD host (-B switch). Signed-off-by: Tomasz 'CeDeROM' CEDRO --- tools/configure.c | 32 ++++++++++++++++++++++++++++++-- tools/configure.sh | 13 ++++++++++--- tools/sethost.sh | 32 +++++++++++++++++++++++++------- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/tools/configure.c b/tools/configure.c index 28dd4f7760..aa6d523164 100644 --- a/tools/configure.c +++ b/tools/configure.c @@ -52,6 +52,7 @@ #define HOST_LINUX 1 #define HOST_MACOS 2 #define HOST_WINDOWS 3 +#define HOST_BSD 4 #define WINDOWS_NATIVE 1 #define WINDOWS_CYGWIN 2 @@ -166,7 +167,7 @@ static const char *g_optfiles[] = static void show_usage(const char *progname, int exitcode) { - fprintf(stderr, "\nUSAGE: %s [-d] [-E] [-e] [-b|f] [-L] [-l|m|c|g|n] " + fprintf(stderr, "\nUSAGE: %s [-d] [-E] [-e] [-b|f] [-L] [-l|m|c|g|n|B] " "[-a ] : [make-opts]\n", progname); fprintf(stderr, "\nUSAGE: %s [-h]\n", progname); @@ -203,6 +204,7 @@ static void show_usage(const char *progname, int exitcode) fprintf(stderr, " Selects the host environment.\n"); fprintf(stderr, " -l Selects the Linux (l) host environment.\n"); fprintf(stderr, " -m Selects the macOS (m) host environment.\n"); + fprintf(stderr, " -B Selects the *BSD (B) host environment.\n"); fprintf(stderr, " -c Selects the Windows Cygwin (c) environment.\n"); fprintf(stderr, " -g Selects the Windows MinGW/MSYS environment.\n"); fprintf(stderr, " -n Selects the Windows native (n) environment.\n"); @@ -266,7 +268,7 @@ static void parse_args(int argc, char **argv) /* Parse command line options */ - while ((ch = getopt(argc, argv, "a:bcdEefghLlmnu")) > 0) + while ((ch = getopt(argc, argv, "a:bcdEefghLlmBnu")) > 0) { switch (ch) { @@ -320,6 +322,10 @@ static void parse_args(int argc, char **argv) g_host = HOST_MACOS; break; + case 'B' : + g_host = HOST_BSD; + break; + case 'n' : g_host = HOST_WINDOWS; g_windows = WINDOWS_NATIVE; @@ -1352,6 +1358,7 @@ static void set_host(const char *destconfig) enable_feature(destconfig, "CONFIG_HOST_LINUX"); disable_feature(destconfig, "CONFIG_HOST_WINDOWS"); disable_feature(destconfig, "CONFIG_HOST_MACOS"); + disable_feature(destconfig, "CONFIG_HOST_BSD"); disable_feature(destconfig, "CONFIG_WINDOWS_NATIVE"); disable_feature(destconfig, "CONFIG_WINDOWS_CYGWIN"); @@ -1369,6 +1376,7 @@ static void set_host(const char *destconfig) disable_feature(destconfig, "CONFIG_HOST_LINUX"); disable_feature(destconfig, "CONFIG_HOST_WINDOWS"); + disable_feature(destconfig, "CONFIG_HOST_BSD"); enable_feature(destconfig, "CONFIG_HOST_MACOS"); disable_feature(destconfig, "CONFIG_WINDOWS_NATIVE"); @@ -1381,11 +1389,31 @@ static void set_host(const char *destconfig) } break; + case HOST_BSD: + { + printf(" Select the BSD host\n"); + + disable_feature(destconfig, "CONFIG_HOST_LINUX"); + disable_feature(destconfig, "CONFIG_HOST_WINDOWS"); + disable_feature(destconfig, "CONFIG_HOST_MACOS"); + enable_feature(destconfig, "CONFIG_HOST_BSD"); + + disable_feature(destconfig, "CONFIG_WINDOWS_NATIVE"); + disable_feature(destconfig, "CONFIG_WINDOWS_CYGWIN"); + disable_feature(destconfig, "CONFIG_WINDOWS_MSYS"); + disable_feature(destconfig, "CONFIG_WINDOWS_OTHER"); + + enable_feature(destconfig, "CONFIG_SIM_X8664_SYSTEMV"); + disable_feature(destconfig, "CONFIG_SIM_X8664_MICROSOFT"); + } + break; + case HOST_WINDOWS: { enable_feature(destconfig, "CONFIG_HOST_WINDOWS"); disable_feature(destconfig, "CONFIG_HOST_LINUX"); disable_feature(destconfig, "CONFIG_HOST_MACOS"); + disable_feature(destconfig, "CONFIG_HOST_BSD"); disable_feature(destconfig, "CONFIG_WINDOWS_OTHER"); diff --git a/tools/configure.sh b/tools/configure.sh index 4b1e37ddc2..e32ecf2f6e 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -21,9 +21,10 @@ set -e WD=`test -d ${0%/*} && cd ${0%/*}; pwd` TOPDIR="${WD}/.." +MAKECMD="make" USAGE=" -USAGE: ${0} [-E] [-e] [-l|m|c|g|n] [L] [-a ] : [make-opts] +USAGE: ${0} [-E] [-e] [-l|m|c|g|n|B] [L] [-a ] : [make-opts] Where: -E enforces distclean if already configured. @@ -33,6 +34,7 @@ Where: -c selects the Windows host and Cygwin (c) environment. -g selects the Windows host and MinGW/MSYS environment. -n selects the Windows host and Windows native (n) environment. + -B selects the *BSD (B) host environment. Default: Use host setup in the defconfig file Default Windows: Cygwin -L Lists all available configurations. @@ -86,6 +88,11 @@ while [ ! -z "$1" ]; do winnative=y host+=" $1" ;; + -B ) + winnative=n + host+=" $1" + MAKECMD="gmake" + ;; -E ) enforce_distclean=y ;; @@ -173,7 +180,7 @@ fi if [ -r ${dest_config} ]; then if [ "X${enforce_distclean}" = "Xy" ]; then - make -C ${TOPDIR} distclean + ${MAKECMD} -C ${TOPDIR} distclean else if cmp -s ${src_config} ${backup_config}; then echo "No configuration change." @@ -181,7 +188,7 @@ if [ -r ${dest_config} ]; then fi if [ "X${distclean}" = "Xy" ]; then - make -C ${TOPDIR} distclean + ${MAKECMD} -C ${TOPDIR} distclean else echo "Already configured!" echo "Please 'make distclean' and try again." diff --git a/tools/sethost.sh b/tools/sethost.sh index 16ff6d5b4a..6be7e920ca 100755 --- a/tools/sethost.sh +++ b/tools/sethost.sh @@ -22,14 +22,15 @@ set -e progname=$0 host= wenv= +MAKECMD="make" function showusage { echo "" - echo "USAGE: $progname [-l|m|c|g|n] [make-opts]" + echo "USAGE: $progname [-l|m|c|g|n|B] [make-opts]" echo " $progname -h" echo "" echo "Where:" - echo " -l|m|c|g|n selects Linux (l), macOS (m), Cygwin (c)," + echo " -l|m|c|g|n|B selects Linux (l), macOS (m), Cygwin (c), BSD (B)," echo " MSYS/MSYS2 (g) or Windows native (n). Default Linux" echo " make-opts directly pass to make" echo " -h will show this help test and terminate" @@ -58,6 +59,10 @@ while [ ! -z "$1" ]; do host=windows wenv=native ;; + -B ) + host=bsd + MAKECMD="gmake" + ;; -h ) showusage ;; @@ -74,12 +79,17 @@ done # Cygwin: CYGWIN_NT-10.0-WOW # Linux: Linux # MSYS: MINGW32_NT-6.2 +# BSD: FreeBSD, OpenBSD, NetBSD, *BSD if [ -z "$host" ]; then case $(uname -s) in Darwin) host=macos ;; + *BSD) + host=bsd + MAKECMD="gmake" + ;; CYGWIN*) host=windows wenv=cygwin @@ -122,23 +132,30 @@ fi # Modify the configuration -if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" ]; then +if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" -o "X$host" == "Xbsd" ]; then # Disable Windows (to suppress warnings from Window Environment selections) kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_WINDOWS - # Enable Linux or macOS + # Enable Linux or macOS or BSD if [ "X$host" == "Xlinux" ]; then echo " Select CONFIG_HOST_LINUX=y" - kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS + kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_BSD kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_LINUX + + elif [ "X$host" == "Xbsd" ]; then + echo " Select CONFIG_HOST_BSD=y" + kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS + kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX + kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_BSD + else echo " Select CONFIG_HOST_MACOS=y" - kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX + kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_BSD kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_MACOS fi @@ -150,6 +167,7 @@ else kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS + kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_BSD # Enable Windows and the Microsoft ABI @@ -174,4 +192,4 @@ fi echo " Refreshing..." -make olddefconfig $* || { echo "ERROR: failed to refresh"; exit 1; } +${MAKECMD} olddefconfig $* || { echo "ERROR: failed to refresh"; exit 1; }