-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·140 lines (115 loc) · 3.13 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·140 lines (115 loc) · 3.13 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Build script for ua project
# Supports both autotools and CMake build systems
set -e
show_help() {
cat << EOF
Build script for ua project
Usage: $0 [OPTIONS] [BUILD_SYSTEM]
OPTIONS:
-h, --help Show this help message
-c, --clean Clean build artifacts before building
-j, --jobs N Use N parallel jobs (default: auto-detect)
BUILD_SYSTEM:
autotools Use autotools (./configure && make) [default]
cmake Use CMake (mkdir build && cmake && make)
Examples:
$0 # Build with autotools
$0 cmake # Build with CMake
$0 -c autotools # Clean and build with autotools
$0 -j4 cmake # Build with CMake using 4 jobs
EOF
}
# Default values
BUILD_SYSTEM="autotools"
CLEAN=false
JOBS=$(nproc 2>/dev/null || echo 1)
CONFIGURE_SRC="configure.ac"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
-c|--clean)
CLEAN=true
shift
;;
-j|--jobs)
JOBS="$2"
shift 2
;;
autotools|cmake)
BUILD_SYSTEM="$1"
shift
;;
*)
echo "Unknown option: $1"
show_help
exit 1
;;
esac
done
echo "Building ua project with $BUILD_SYSTEM build system"
echo "Jobs: $JOBS"
echo "Clean: $CLEAN"
echo
case $BUILD_SYSTEM in
autotools)
echo "=== Using Autotools Build System ==="
if [ "$CLEAN" = true ]; then
echo "Cleaning autotools build artifacts..."
make dist-clean 2>/dev/null || true
fi
if [ ! -f "configure" ] || [ "$CLEAN" = true ] || { [ -f "$CONFIGURE_SRC" ] && [ "$CONFIGURE_SRC" -nt "configure" ]; }; then
echo "Running autogen.sh..."
bash ./autogen.sh
fi
if [ ! -f "Makefile" ]; then
echo "Running configure..."
bash ./configure
fi
echo "Building with make..."
make -j"$JOBS"
echo "Build complete! Binaries are in build/ directory"
;;
cmake)
echo "=== Using CMake Build System ==="
if [ "$CLEAN" = true ]; then
echo "Cleaning CMake build artifacts..."
rm -rf build
fi
echo "Creating build directory..."
mkdir -p build
cd build
echo "Running cmake..."
cmake ..
echo "Building with make or ninja..."
if command -v ninja >/dev/null 2>&1; then
ninja
else
make -j"$JOBS"
fi
cd ..
echo "Build complete! Binaries are in build/ directory"
;;
*)
echo "Unknown build system: $BUILD_SYSTEM"
exit 1
;;
esac
echo
echo "Available binaries:"
if [ -f "build/ua" ]; then
echo " build/ua"
fi
if [ -f "build/kua" ]; then
echo " build/kua"
fi
if [ -f "ua" ]; then
echo " ua (autotools build)"
fi
if [ -f "kua" ]; then
echo " kua (autotools build)"
fi