Skip to content

Commit 6c5846f

Browse files
authored
Merge pull request #349 from rianquinn/opensus_support
OpenSUSE Support
2 parents 890f974 + 9da166b commit 6c5846f

File tree

5 files changed

+48
-311
lines changed

5 files changed

+48
-311
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ COMMON_FLAGS=""
3838
COMMON_FLAGS="$COMMON_FLAGS -g"
3939
COMMON_FLAGS="$COMMON_FLAGS -fpic"
4040
COMMON_FLAGS="$COMMON_FLAGS -fexceptions"
41-
COMMON_FLAGS="$COMMON_FLAGS -fstack-protector-strong"
4241
COMMON_FLAGS="$COMMON_FLAGS -mstackrealign"
4342
COMMON_FLAGS="$COMMON_FLAGS -mmmx"
4443
COMMON_FLAGS="$COMMON_FLAGS -msse"
@@ -53,6 +52,7 @@ COMMON_FLAGS="$COMMON_FLAGS -maes"
5352

5453
CROSS_COMMON_FLAGS="$COMMON_FLAGS"
5554
CROSS_COMMON_FLAGS="$CROSS_COMMON_FLAGS -ffreestanding"
55+
CROSS_COMMON_FLAGS="$CROSS_COMMON_FLAGS -fstack-protector-strong"
5656
CROSS_COMMON_FLAGS="$CROSS_COMMON_FLAGS -mno-red-zone"
5757
CROSS_COMMON_FLAGS="$CROSS_COMMON_FLAGS -D_HAVE_LONG_DOUBLE"
5858
CROSS_COMMON_FLAGS="$CROSS_COMMON_FLAGS -D_LDBL_EQ_DBL"

include/constants.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525

2626
#include <types.h>
2727

28+
#ifdef CROSS_COMPILED
29+
2830
#if defined(__GNUC__) || defined(__clang__)
2931
#if __has_include("user_constants.h")
3032
#include "user_constants.h"
3133
#endif
3234
#endif
3335

36+
#endif
37+
3438
/*
3539
* Hypervisor Version
3640
*

tools/scripts/setup_debian.sh

Lines changed: 10 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,21 @@
2020
# License along with this library; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2222

23+
source $(dirname $0)/setup_common.sh
24+
2325
# ------------------------------------------------------------------------------
2426
# Checks
2527
# ------------------------------------------------------------------------------
2628

27-
case $(lsb_release -si) in
28-
Debian)
29-
;;
30-
*)
31-
echo "This script can only be used with: Debian"
32-
exit 1
33-
esac
34-
35-
if [[ ! -d "bfelf_loader" ]]; then
36-
echo "This script must be run from bareflank root directory"
37-
exit 1
38-
fi
39-
40-
if ! grep -q 'avx' /proc/cpuinfo; then
41-
echo "Hardware unsupported. AVX is required"
42-
exit 1
43-
fi
29+
check_distro debian
30+
check_folder
31+
check_hardware
4432

4533
# ------------------------------------------------------------------------------
46-
# Help
34+
# Parse Arguments
4735
# ------------------------------------------------------------------------------
4836

49-
option_help() {
50-
echo -e "Usage: setup_debian.sh [OPTION]"
51-
echo -e "Sets up the system to compile / use Bareflank"
52-
echo -e ""
53-
echo -e " -h, --help show this help menu"
54-
echo -e " -l, --local_compilers setup local cross compilers"
55-
echo -e " -n, --no-configure skip the configure step"
56-
echo -e " -g, --compiler <dirname> directory of cross compiler"
57-
echo -e " -o, --out_of_tree <dirname> setup out of tree build"
58-
echo -e ""
59-
}
37+
parse_arguments $@
6038

6139
# ------------------------------------------------------------------------------
6240
# Functions
@@ -96,50 +74,11 @@ prepare_docker() {
9674
sudo service docker restart
9775
}
9876

99-
# ------------------------------------------------------------------------------
100-
# Arguments
101-
# ------------------------------------------------------------------------------
102-
103-
while [[ $# -ne 0 ]]; do
104-
105-
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
106-
option_help
107-
exit 0
108-
fi
109-
110-
if [[ $1 == "-l" ]] || [[ $1 == "--local_compilers" ]]; then
111-
local="true"
112-
fi
113-
114-
if [[ $1 == "--compiler" ]]; then
115-
shift
116-
compiler="--compiler $1"
117-
fi
118-
119-
if [[ $1 == "--use_llvm_clang" ]]; then
120-
use_llvm_clang="--use_llvm_clang"
121-
fi
122-
123-
if [[ $1 == "-n" ]] || [[ $1 == "--no-configure" ]]; then
124-
noconfigure="true"
125-
fi
126-
127-
if [[ $1 == "-o" ]] || [[ $1 == "--out_of_tree" ]]; then
128-
shift
129-
out_of_tree="true"
130-
build_dir=$1
131-
hypervisor_dir=$PWD
132-
fi
133-
134-
shift
135-
136-
done
137-
13877
# ------------------------------------------------------------------------------
13978
# Setup System
14079
# ------------------------------------------------------------------------------
14180

142-
case $(lsb_release -sr) in
81+
case $( grep ^VERSION_ID= /etc/os-release | cut -d'=' -f 2 | tr -d '"' ) in
14382
testing)
14483
install_apt_tools
14584
add_docker_repositories
@@ -148,7 +87,7 @@ testing)
14887
;;
14988

15089
*)
151-
echo "This version of Debian is not supported"
90+
echo "This version of Ubuntu is not supported"
15291
exit 1
15392

15493
esac
@@ -157,34 +96,4 @@ esac
15796
# Setup Build Environment
15897
# ------------------------------------------------------------------------------
15998

160-
if [[ ! $noconfigure == "true" ]]; then
161-
if [[ $out_of_tree == "true" ]]; then
162-
mkdir -p $build_dir
163-
pushd $build_dir
164-
$hypervisor_dir/configure
165-
popd
166-
else
167-
./configure $compiler $use_llvm_clang
168-
fi
169-
fi
170-
171-
if [[ $local == "true" ]]; then
172-
CROSS_COMPILER=clang_38 ./tools/scripts/create_cross_compiler.sh
173-
fi
174-
175-
# ------------------------------------------------------------------------------
176-
# Done
177-
# ------------------------------------------------------------------------------
178-
179-
echo ""
180-
181-
echo "WARNING: If you are using ssh, or are logged into a GUI you "
182-
echo " might need to exit and log back in to compile!!!"
183-
echo ""
184-
185-
if [[ $out_of_tree == "true" ]]; then
186-
echo "To build, run:"
187-
echo " cd $build_dir"
188-
echo " make -j<# cores>"
189-
echo ""
190-
fi
99+
setup_build_environment

tools/scripts/setup_fedora.sh

Lines changed: 15 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,21 @@
2020
# License along with this library; if not, write to the Free Software
2121
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2222

23-
sudo dnf install -y redhat-lsb-core
23+
source $(dirname $0)/setup_common.sh
2424

2525
# ------------------------------------------------------------------------------
2626
# Checks
2727
# ------------------------------------------------------------------------------
2828

29-
case $(lsb_release -si) in
30-
Fedora)
31-
;;
32-
*)
33-
echo "This script can only be used with: Fedora"
34-
exit 1
35-
esac
36-
37-
if [[ ! -d "bfelf_loader" ]]; then
38-
echo "This script must be run from bareflank root directory"
39-
exit 1
40-
fi
41-
42-
if ! grep -q 'avx' /proc/cpuinfo; then
43-
echo "Hardware unsupported. AVX is required"
44-
exit 1
45-
fi
29+
check_distro fedora
30+
check_folder
31+
check_hardware
4632

4733
# ------------------------------------------------------------------------------
48-
# Help
34+
# Parse Arguments
4935
# ------------------------------------------------------------------------------
5036

51-
option_help() {
52-
echo -e "Usage: setup_fedora.sh [OPTION]"
53-
echo -e "Sets up the system to compile / use Bareflank"
54-
echo -e ""
55-
echo -e " -h, --help show this help menu"
56-
echo -e " -l, --local_compilers setup local cross compilers"
57-
echo -e " -n, --no-configure skip the configure step"
58-
echo -e " -g, --compiler <dirname> directory of cross compiler"
59-
echo -e " -o, --out_of_tree <dirname> setup out of tree build"
60-
echo -e ""
61-
}
37+
parse_arguments $@
6238

6339
# ------------------------------------------------------------------------------
6440
# Functions
@@ -88,57 +64,23 @@ prepare_docker() {
8864
sudo systemctl enable docker
8965
}
9066

91-
# ------------------------------------------------------------------------------
92-
# Arguments
93-
# ------------------------------------------------------------------------------
94-
95-
while [[ $# -ne 0 ]]; do
96-
97-
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
98-
option_help
99-
exit 0
100-
fi
101-
102-
if [[ $1 == "-l" ]] || [[ $1 == "--local_compilers" ]]; then
103-
local="true"
104-
fi
105-
106-
if [[ $1 == "--compiler" ]]; then
107-
shift
108-
compiler="--compiler $1"
109-
fi
110-
111-
if [[ $1 == "--use_llvm_clang" ]]; then
112-
use_llvm_clang="--use_llvm_clang"
113-
fi
114-
115-
if [[ $1 == "-n" ]] || [[ $1 == "--no-configure" ]]; then
116-
noconfigure="true"
117-
fi
118-
119-
if [[ $1 == "-o" ]] || [[ $1 == "--out_of_tree" ]]; then
120-
shift
121-
out_of_tree="true"
122-
build_dir=$1
123-
hypervisor_dir=$PWD
124-
fi
125-
126-
shift
127-
128-
done
129-
13067
# ------------------------------------------------------------------------------
13168
# Setup System
13269
# ------------------------------------------------------------------------------
13370

134-
case $(lsb_release -sr) in
135-
23)
71+
case $( grep ^VERSION_ID= /etc/os-release | cut -d'=' -f 2 | tr -d '"' ) in
72+
25)
73+
install_common_packages
74+
prepare_docker
75+
;;
76+
77+
24)
13678
install_common_packages
13779
prepare_docker
13880
;;
13981

14082
*)
141-
echo "This version of Fedora is not supported"
83+
echo "This version of Ubuntu is not supported"
14284
exit 1
14385

14486
esac
@@ -147,33 +89,4 @@ esac
14789
# Setup Build Environment
14890
# ------------------------------------------------------------------------------
14991

150-
if [[ ! $noconfigure == "true" ]]; then
151-
if [[ $out_of_tree == "true" ]]; then
152-
mkdir -p $build_dir
153-
pushd $build_dir
154-
$hypervisor_dir/configure
155-
popd
156-
else
157-
./configure $compiler $use_llvm_clang
158-
fi
159-
fi
160-
161-
if [[ $local == "true" ]]; then
162-
CROSS_COMPILER=clang_38 ./tools/scripts/create_cross_compiler.sh
163-
fi
164-
165-
# ------------------------------------------------------------------------------
166-
# Done
167-
# ------------------------------------------------------------------------------
168-
169-
echo ""
170-
171-
echo "WARNING: A reboot is required to build!!!"
172-
echo ""
173-
174-
if [[ $out_of_tree == "true" ]]; then
175-
echo "To build, run:"
176-
echo " cd $build_dir"
177-
echo " make -j<# cores>"
178-
echo ""
179-
fi
92+
setup_build_environment

0 commit comments

Comments
 (0)