-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (83 loc) · 2.25 KB
/
install.sh
File metadata and controls
executable file
·105 lines (83 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
THREADS=1
INSTALL=1
CLEAN=0
HELP=0
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--no-install)
INSTALL=0
shift
;;
-c|--clean)
CLEAN=1
shift
;;
-t|--threads)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
THREADS="$2"
shift 2
else
echo "Error: -t/--threads requires a positive integer argument"
exit 1
fi
;;
-h|--help)
HELP=1
shift
;;
*)
shift
;;
esac
done
if [ "$HELP" -gt 0 ]; then
echo "Usage: install.sh [OPTIONS]"
echo
echo "Options:"
echo " --no-install Build the tool without installing it to the system."
echo " -c --clean Remove build files for the tool."
echo " -t --threads N Specify the number of threads to use for building. 0 = CPU core count (default: 1)."
echo " -h --help Display this help message."
exit 0
fi
# We need to clean build files if clean is enabled.
if [ "$CLEAN" -gt 0 ]; then
# Clean common files first.
echo "Cleaning Common Repository build files..."
make -C modules/common clean
echo "Done."
echo "Cleaning build files..."
make clean
echo "Done."
exit 0
fi
# Set thread count to CPU core count if less than 1.
if [ "$THREADS" -lt 1]; then
THREADS=$(nproc)
fi
echo "Building Packet Batch using $THREADS threads..."
# First, we want to build our common objects which includes LibYAML. Read the PB-Common directory for more information.
echo "Building JSON-C..."
make -j $THREADS jsonc
echo "Done..."
if [ "$INSTALL" -gt 0 ]; then
echo "Installing JSON-C..."
sudo make -j $THREADS jsonc_install
fi
# Next, build LibBPF objects.
echo "Building LibBPF..."
make -j $THREADS libbpf
echo "Done..."
# Now build our primary objects and executables.
echo "Building Main..."
make -j $THREADS
echo "Done..."
# Finally, install our binary. This must be ran by root or with sudo.
if [ "$INSTALL" -gt 0 ]; then
echo "Installing Main..."
sudo make -j $THREADS install
echo "Done..."
fi
echo "Build and/or installation completed!"