Unverified Commit bed8fcc4 authored by Xavier L'Heureux's avatar Xavier L'Heureux
Browse files

Start adding basic support for FreeBSD

parent aa76286e
Pipeline #7423 failed with stage
in 3 minutes and 50 seconds
......@@ -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
......
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment