forked from dailker/everyutil-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
61 lines (52 loc) · 1.63 KB
/
build.sh
File metadata and controls
61 lines (52 loc) · 1.63 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
#!/bin/sh
# Exit on any error
set -e
# Clean up m4 and build directories if they exist
echo "Cleaning up m4 and build directories..."
[ -d m4 ] && rm -rf m4
[ -d build ] && rm -rf build
# Function to detect package manager and install dependencies
install_dependencies() {
if command -v pacman >/dev/null 2>&1; then
# MSYS2
echo "Detected MSYS2. Installing dependencies with pacman..."
pacman -S --noconfirm autoconf gcc make
elif command -v apt-get >/dev/null 2>&1; then
# Ubuntu/Debian
echo "Detected Ubuntu/Debian. Installing dependencies with apt-get..."
sudo apt-get update && sudo apt-get install -y autoconf gcc make
elif command -v dnf >/dev/null 2>&1; then
# Fedora/RHEL
echo "Detected Fedora/RHEL. Installing dependencies with dnf..."
sudo dnf install -y autoconf gcc make
elif command -v brew >/dev/null 2>&1; then
# macOS with Homebrew
echo "Detected Homebrew. Installing dependencies with brew..."
brew install autoconf gcc make
else
echo "Error: No supported package manager found (pacman, apt-get, dnf, or brew)."
exit 1
fi
}
# Check for required tools and install if missing
for tool in autoconf gcc make; do
if ! command -v $tool >/dev/null 2>&1; then
echo "$tool not found. Attempting to install dependencies..."
install_dependencies
break
fi
done
# Run autoreconf to generate configure script
echo "Running autoreconf..."
autoreconf --install
# Run configure
echo "Running configure..."
./configure
# Build the project
echo "Building project..."
make clean
make
# Run tests
echo "Running tests..."
make test
echo "Build and test completed successfully."