Docker: using DSM toolchain

This commit is contained in:
Fabio Belavenuto
2022-07-22 11:41:59 -03:00
parent 690af5115d
commit 1b766e4974
3 changed files with 96 additions and 57 deletions

View File

@@ -2,6 +2,19 @@
set -e
function export-vars {
# Validate
if [ -z "${1}" ]; then
echo "Use: export-vars <platform>"
exit 1
fi
export CROSS_COMPILE="/opt/${1}/bin/x86_64-pc-linux-gnu-"
export CFLAGS="-I/opt/${1}/include"
export LDFLAGS="-I/opt/${1}/lib"
export LD_LIBRARY_PATH="/opt/${1}/lib"
export ARCH=x86_64
}
function compile-module {
# Validate
if [ -z "${1}" ]; then
@@ -21,7 +34,9 @@ function compile-module {
fi
echo "Compiling module for ${PLATFORM}-${KVER}..."
cp -R /input /tmp
make -C "/opt/${PLATFORM}" M="/tmp/input" ${PLATFORM^^}-Y=y ${PLATFORM^^}-M=m modules
export-vars ${PLATFORM}
make -C "/opt/${PLATFORM}/build" M="/tmp/input" \
${PLATFORM^^}-Y=y ${PLATFORM^^}-M=m modules
while read F; do
strip -g "${F}"
echo "Copying `basename ${F}`"
@@ -36,11 +51,13 @@ function compile-lkm {
exit 1
fi
cp -R /input /tmp
make -C "/tmp/input" LINUX_SRC="/opt/${PLATFORM}" dev-v7
export-vars ${PLATFORM}
export LINUX_SRC="/opt/${PLATFORM}/build"
make -C "/tmp/input" dev-v7
strip -g "/tmp/input/redpill.ko"
mv "/tmp/input/redpill.ko" "/output/redpill-dev.ko"
make -C "/tmp/input" LINUX_SRC="/opt/${PLATFORM}" clean
make -C "/tmp/input" LINUX_SRC="/opt/${PLATFORM}" prod-v7
make -C "/tmp/input" clean
make -C "/tmp/input" prod-v7
strip -g "/tmp/input/redpill.ko"
mv "/tmp/input/redpill.ko" "/output/redpill-prod.ko"
}
@@ -73,10 +90,10 @@ if [ $# -lt 1 ]; then
exit 1
fi
case $1 in
bash) shift; bash -l $@ ;;
bash) shift && bash -l $@ ;;
shell) export-vars $2 && shift 2 && bash -l $@ ;;
compile-module) compile-module $2 ;;
compile-lkm) compile-lkm $2 ;;
# compile-drivers) compile-drivers ;;
*) echo "Command not recognized: $1" ;;
esac