Skip to content

Commit b48e87b

Browse files
committed
Build script for *.deb packages for x86-64 and ARM (hf).
1 parent f8d478d commit b48e87b

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

build.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
ARCHITECTURE=$1
4+
LIB_DIR=$2
5+
6+
VERSION="0.0.8"
7+
8+
PACKAGE_DIR="dist/diwa_${VERSION}_${ARCHITECTURE}"
9+
DEBIAN_DIR="${PACKAGE_DIR}/DEBIAN"
10+
11+
USR_DIR="${PACKAGE_DIR}/usr"
12+
INCLUDE_DIR="${USR_DIR}/src"
13+
BUILD_DIR="dist/build"
14+
SO_FILE="${BUILD_DIR}/libdiwa.so"
15+
16+
case "$ARCHITECTURE" in
17+
amd64)
18+
CROSS_COMPILE="g++ -fPIC"
19+
;;
20+
riscv64)
21+
CROSS_COMPILE="riscv64-linux-gnu-gcc"
22+
;;
23+
armhf)
24+
export PATH="/usr/lib/gcc/arm-none-eabi/13.2.1:$PATH"
25+
CROSS_COMPILE="arm-linux-gnueabihf-cpp"
26+
;;
27+
*)
28+
echo -e "\033[93m[-]\033[0m Unsupported architecture: $ARCHITECTURE"
29+
exit 1
30+
;;
31+
esac
32+
33+
mkdir -p "${DEBIAN_DIR}"
34+
mkdir -p "${INCLUDE_DIR}/diwa"
35+
mkdir -p "${USR_DIR}/lib/${LIB_DIR}"
36+
mkdir -p "${BUILD_DIR}"
37+
38+
echo -e "\033[92m[+]\033[0m Building shared library for ${ARCHITECTURE}..."
39+
${CROSS_COMPILE} -shared -o "${SO_FILE}" -Isrc src/*.cpp
40+
41+
cp -r src/diwa.h "${INCLUDE_DIR}/"
42+
cp "${SO_FILE}" "${USR_DIR}/lib/${LIB_DIR}/"
43+
44+
cat <<EOF > "${DEBIAN_DIR}/control"
45+
Package: diwa
46+
Version: ${VERSION}
47+
Section: libs
48+
Priority: optional
49+
Architecture: ${ARCHITECTURE}
50+
Depends: libc6 (>= 2.7)
51+
Maintainer: Nathanne Isip <[email protected]>
52+
Description: diwa - Complex Compute Core Engine Library
53+
diwa (Complex Compute Core Engine) is a framework, platform,
54+
library, and an engine for handling complex computational
55+
tasks involving matrices, vectors, and tensors.
56+
EOF
57+
58+
chmod 755 "${DEBIAN_DIR}"
59+
chmod 755 "${USR_DIR}"
60+
chmod 755 "${INCLUDE_DIR}"
61+
chmod 755 "${USR_DIR}/lib/${LIB_DIR}"
62+
63+
dpkg-deb --build "${PACKAGE_DIR}" > /dev/null
64+
65+
rm -rf "${PACKAGE_DIR}"
66+
rm -rf "${BUILD_DIR}"
67+
68+
echo -e "\033[92m[+]\033[0m Debian package for ${ARCHITECTURE} created successfully!"

0 commit comments

Comments
 (0)