From fcde2ae5aa34141c659eb056dd551dec7a63177a Mon Sep 17 00:00:00 2001 From: AdminXVII Date: Sat, 2 May 2020 17:54:37 +0000 Subject: [PATCH 1/7] Change shebang of bootstrap to /usr/bin/env to be more cross-platform --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index eb73b41..ed1a9c8 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash ########################################################## # This function is simply a banner to introduce the script From bed8fcc41a4c0085a13bc7b6a3395a7da5b76dbf Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Sat, 2 May 2020 20:13:21 -0400 Subject: [PATCH 2/7] Start adding basic support for FreeBSD --- bootstrap.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++----- mk/config.mk | 6 ++++++ mk/prefix.mk | 28 ++++++++++++++-------------- 3 files changed, 65 insertions(+), 19 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index ed1a9c8..d5fb309 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -12,12 +12,12 @@ banner() ################################################################################### # This function takes care of installing a dependency via package manager of choice -# for building redox on MacOS. +# for building redox on BSDs (MacOS, FreeBSD, etc.). # @params: $1 package manager # $2 package name # $3 binary name (optional) ################################################################################### -install_macos_pkg() +install_bsd_pkg() { PKG_MANAGER=$1 PKG_NAME=$2 @@ -37,17 +37,22 @@ install_macos_pkg() install_macports_pkg() { - install_macos_pkg "sudo port" "$1" "$2" + install_bsd_pkg "sudo port" "$1" "$2" } install_brew_pkg() { - install_macos_pkg "brew" $@ + install_bsd_pkg "brew" $@ } install_brew_cask_pkg() { - install_macos_pkg "brew cask" $@ + install_bsd_pkg "brew cask" $@ +} + +install_freebsd_pkg() +{ + install_bsd_pkg "sudo pkg" $@ } ############################################################################### @@ -136,6 +141,35 @@ osx_homebrew() install_brew_pkg "redox-os/gcc_cross_compilers/x86_64-elf-gcc" "x86_64-elf-gcc" } +############################################################################### +# This function takes care of installing all dependencies using pkg +# for building redox on FreeBSD +# @params: $1 the emulator to install, virtualbox or qemu +############################################################################### +freebsd() +{ + echo "FreeBSD detected!" + echo "Installing missing packages..." + + install_freebsd_pkg "git" + + if [ "$1" == "qemu" ]; then + install_freebsd_pkg "qemu" "qemu-system-x86_64" + else + install_freebsd_pkg "virtualbox" + fi + + install_freebsd_pkg "coreutils" + install_freebsd_pkg "findutils" + install_freebsd_pkg "gcc" + install_freebsd_pkg "nasm" + install_freebsd_pkg "pkgconf" + install_freebsd_pkg "fusefs-libs" + install_freebsd_pkg "cmake" + install_freebsd_pkg "gmake" + install_freebsd_pkg "wget" +} + ############################################################################### # This function takes care of installing all dependencies for building redox on # Arch linux @@ -574,6 +608,12 @@ else # Arch linux elif hash 2>/dev/null pacman; then archLinux "$emulator" + # FreeBSD + elif hash 2>/dev/null pkg; then + freebsd "$emulator" + # Unsupported platform + else + printf "\e[31;1mFatal error: \e[0;31mUnsupported platform, please open an issue\[0m" fi fi diff --git a/mk/config.mk b/mk/config.mk index e848450..1b5e028 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -18,6 +18,12 @@ ifeq ($(UNAME),Darwin) PREFIX_BINARY=0 VB_AUDIO=coreaudio VBM=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage +ifeq ($(UNAME),FreeBSD) + FUMOUNT=sudo umount + export NPROC=sysctl -n hw.ncpu + PREFIX_BINARY=0 + VB_AUDIO=pulse # To check, will probaly be OSS on most setups + VBM=VBoxManage else FUMOUNT=fusermount -u export NPROC=nproc diff --git a/mk/prefix.mk b/mk/prefix.mk index 68421e4..ed87cf6 100644 --- a/mk/prefix.mk +++ b/mk/prefix.mk @@ -38,8 +38,8 @@ $(PREFIX)/relibc-install: $(ROOT)/relibc | $(PREFIX)/gcc-install cd "$<" && \ export PATH="$(ROOT)/$@.partial/bin:$$PATH" && \ export CARGO="env -u CARGO xargo" && \ - make -j `$(NPROC)` all && \ - make -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial/$(TARGET)" + $(MAKE) -j `$(NPROC)` all && \ + $(MAKE) -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial/$(TARGET)" cd "$@.partial" && $(PREFIX_STRIP) touch "$@.partial" mv "$@.partial" "$@" @@ -67,9 +67,9 @@ $(PREFIX)/rust-install: $(ROOT)/rust | $(PREFIX)/relibc-install --tools=cargo \ --target="$(TARGET)" \ && \ - make -j `$(NPROC)` && \ + $(MAKE) -j `$(NPROC)` && \ rm -rf "$(ROOT)/$@.partial/lib/rustlib" "$(ROOT)/$@.partial/share/doc/rust" && \ - make -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial" + $(MAKE) -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial" rm -rf "$(PREFIX)/rust-build" mkdir -p "$@.partial/lib/rustlib/x86_64-unknown-linux-gnu/bin" cd "$@.partial" && find . -name *.old -exec rm {} ';' && $(PREFIX_STRIP) @@ -122,8 +122,8 @@ $(PREFIX)/binutils-install: $(PREFIX)/binutils --prefix="" \ --disable-werror \ && \ - make -j `$(NPROC)` all && \ - make -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial" + $(MAKE) -j `$(NPROC)` all && \ + $(MAKE) -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial" rm -rf "$<-build" cd "$@.partial" && $(PREFIX_STRIP) touch "$@.partial" @@ -155,8 +155,8 @@ $(PREFIX)/gcc-freestanding-install: $(PREFIX)/gcc | $(PREFIX)/binutils-install --enable-languages=c,c++ \ --without-headers \ && \ - make -j `$(NPROC)` all-gcc && \ - make -j `$(NPROC)` install-gcc DESTDIR="$(ROOT)/$@.partial" + $(MAKE) -j `$(NPROC)` all-gcc && \ + $(MAKE) -j `$(NPROC)` install-gcc DESTDIR="$(ROOT)/$@.partial" rm -rf "$<-freestanding-build" cd "$@.partial" && $(PREFIX_STRIP) touch "$@.partial" @@ -176,8 +176,8 @@ $(PREFIX)/rust-freestanding-install: $(ROOT)/rust | $(PREFIX)/binutils-install --enable-llvm-static-stdcpp \ --tools=cargo \ && \ - make -j `$(NPROC)` && \ - make -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial" + $(MAKE) -j `$(NPROC)` && \ + $(MAKE) -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial" rm -rf "$(PREFIX)/rust-freestanding-build" mkdir -p "$@.partial/lib/rustlib/x86_64-unknown-linux-gnu/bin" cd "$@.partial" && $(PREFIX_STRIP) @@ -191,8 +191,8 @@ $(PREFIX)/relibc-freestanding-install: $(ROOT)/relibc | $(PREFIX_BASE_INSTALL) $ export PATH="$(PREFIX_BASE_INSTALL):$(PREFIX_FREESTANDING_PATH):$$PATH" && \ export CARGO="env -u CARGO xargo" && \ export CC_$(subst -,_,$(TARGET))="$(TARGET)-gcc -isystem $(ROOT)/$@.partial/$(TARGET)/include" && \ - make -j `$(NPROC)` all && \ - make -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial/$(TARGET)" + $(MAKE) -j `$(NPROC)` all && \ + $(MAKE) -j `$(NPROC)` install DESTDIR="$(ROOT)/$@.partial/$(TARGET)" cd "$@.partial" && $(PREFIX_STRIP) touch "$@.partial" mv "$@.partial" "$@" @@ -217,8 +217,8 @@ $(PREFIX)/gcc-install: $(PREFIX)/gcc | $(PREFIX)/relibc-freestanding-install --enable-shared \ --enable-threads=posix \ && \ - make -j `$(NPROC)` all-gcc all-target-libgcc all-target-libstdc++-v3 && \ - make -j `$(NPROC)` install-gcc install-target-libgcc install-target-libstdc++-v3 DESTDIR="$(ROOT)/$@.partial" && \ + $(MAKE) -j `$(NPROC)` all-gcc all-target-libgcc all-target-libstdc++-v3 && \ + $(MAKE) -j `$(NPROC)` install-gcc install-target-libgcc install-target-libstdc++-v3 DESTDIR="$(ROOT)/$@.partial" && \ rm $(ROOT)/$@.partial/$(TARGET)/lib/*.la rm -rf "$<-build" cd "$@.partial" && $(PREFIX_STRIP) From a622fc100199ac760509bf811cd72e8df3c098d8 Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Sat, 2 May 2020 20:45:15 -0400 Subject: [PATCH 3/7] Fix conditional target --- bootstrap.sh | 2 ++ mk/config.mk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index d5fb309..49320b3 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -148,6 +148,7 @@ osx_homebrew() ############################################################################### freebsd() { + set -xe echo "FreeBSD detected!" echo "Installing missing packages..." @@ -168,6 +169,7 @@ freebsd() install_freebsd_pkg "cmake" install_freebsd_pkg "gmake" install_freebsd_pkg "wget" + set +xe } ############################################################################### diff --git a/mk/config.mk b/mk/config.mk index 1b5e028..5140291 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -18,7 +18,7 @@ ifeq ($(UNAME),Darwin) PREFIX_BINARY=0 VB_AUDIO=coreaudio VBM=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage -ifeq ($(UNAME),FreeBSD) +else ifeq ($(UNAME),FreeBSD) FUMOUNT=sudo umount export NPROC=sysctl -n hw.ncpu PREFIX_BINARY=0 From 098bc25ebb87809f5776cff16ca7713ef7e968a6 Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Sat, 2 May 2020 20:51:21 -0400 Subject: [PATCH 4/7] Add texinfo for makeinfo --- bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap.sh b/bootstrap.sh index 49320b3..1b9d2ab 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -169,6 +169,7 @@ freebsd() install_freebsd_pkg "cmake" install_freebsd_pkg "gmake" install_freebsd_pkg "wget" + install_freebsd_pkg "texinfo" set +xe } From c5d50d34de1fef0bc135116a9bbbffced0bd4acb Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Sat, 2 May 2020 21:06:57 -0400 Subject: [PATCH 5/7] Add python --- bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap.sh b/bootstrap.sh index 1b9d2ab..bdabf56 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -170,6 +170,7 @@ freebsd() install_freebsd_pkg "gmake" install_freebsd_pkg "wget" install_freebsd_pkg "texinfo" + install_freebsd_pkg "python" set +xe } From 7cc5e1eac92e14a27e9ac10a0e6c1e1c494b9b7d Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Sun, 3 May 2020 14:33:22 -0400 Subject: [PATCH 6/7] Add sha256 and make sure to use gmake with freebsd --- bootstrap.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index bdabf56..fa59f6c 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -171,6 +171,7 @@ freebsd() install_freebsd_pkg "wget" install_freebsd_pkg "texinfo" install_freebsd_pkg "python" + install_freebsd_pkg "sha256sum" set +xe } @@ -544,8 +545,12 @@ boot() statusCheck echo "Run the following commands to build redox:" echo "cd redox" - echo "make all" - echo "make virtualbox or qemu" + MAKE="make" + if [[ "$(uname)" -eq FreeBSD ]]; then + MAKE="gmake" + fi + echo "$MAKE all" + echo "$MAKE virtualbox or qemu" echo echo " Good luck!" From 6fa84e73fa78dc14ac5cded29cadde7fe729b1f2 Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux Date: Sun, 3 May 2020 18:57:52 -0400 Subject: [PATCH 7/7] Add dependencies for user-space programs on FreeBSD --- bootstrap.sh | 6 +++++- config/desktop.toml | 2 +- cookbook | 2 +- mk/config.mk | 3 +++ mk/qemu.mk | 5 +++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index fa59f6c..9750968 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -171,7 +171,10 @@ freebsd() install_freebsd_pkg "wget" install_freebsd_pkg "texinfo" install_freebsd_pkg "python" - install_freebsd_pkg "sha256sum" + install_freebsd_pkg "automake" + install_freebsd_pkg "gettext" + install_freebsd_pkg "bison" + install_freebsd_pkg "gperf" set +xe } @@ -548,6 +551,7 @@ boot() MAKE="make" if [[ "$(uname)" -eq FreeBSD ]]; then MAKE="gmake" + echo "kldload fuse.ko # This loads the kernel module for fuse" fi echo "$MAKE all" echo "$MAKE virtualbox or qemu" diff --git a/config/desktop.toml b/config/desktop.toml index cfa80e9..3597545 100644 --- a/config/desktop.toml +++ b/config/desktop.toml @@ -86,7 +86,7 @@ logd = {} #ncursesw = {} netdb = {} netstack = {} -netsurf = {} +#netsurf = {} netutils = {} #neverball = {} #newlib = {} diff --git a/cookbook b/cookbook index 50c3f86..5097c70 160000 --- a/cookbook +++ b/cookbook @@ -1 +1 @@ -Subproject commit 50c3f8642cce2f541da9854a8e2c3bf677604269 +Subproject commit 5097c70245514908477c1d032f7399390c089292 diff --git a/mk/config.mk b/mk/config.mk index 5140291..ac4b113 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -15,18 +15,21 @@ UNAME := $(shell uname) ifeq ($(UNAME),Darwin) FUMOUNT=sudo umount export NPROC=sysctl -n hw.ncpu + export REDOX_MAKE=make PREFIX_BINARY=0 VB_AUDIO=coreaudio VBM=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage else ifeq ($(UNAME),FreeBSD) FUMOUNT=sudo umount export NPROC=sysctl -n hw.ncpu + export REDOX_MAKE=gmake PREFIX_BINARY=0 VB_AUDIO=pulse # To check, will probaly be OSS on most setups VBM=VBoxManage else FUMOUNT=fusermount -u export NPROC=nproc + export REDOX_MAKE=make VB_AUDIO=pulse VBM=VBoxManage endif diff --git a/mk/qemu.mk b/mk/qemu.mk index d325894..462c2b5 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -45,8 +45,13 @@ endif #,int,pcall #-device intel-iommu +ifeq ($(UNAME),Linux) build/extra.bin: fallocate --posix --length 1G $@ +else +build/extra.bin: + truncate -s 1g $@ +endif qemu: build/harddrive.bin build/extra.bin $(QEMU) $(QEMUFLAGS) \