I'm trying to compile kernel module files for Android. The goal is then build nfs-utils, to get a NFS server working on my Pixel 7 phone.
I downloaded the AOSP project and built a kernel:
$ mkdir android-kernel && cd android-kernel/
$ repo init --depth=1 --manifest-url=https://android.googlesource.com/kernel/manifest --manifest-branch=android-gs-pantah-5.10-android13-qpr1
$ repo sync --current-branch --network-only --jobs=4
$ repo sync --current-branch --local-only --jobs=16
$ BUILD_CONFIG=aosp/build.config.gki.aarch64 build/build.sh
But how do I build a .ko file? I tried to build exportfs.ko, said to be required in Cross-compiling nfs-utils package for Android, but have no idea how to do it. (That question lists sunrpc.ko, lockd.ko, nfs.ko, exportfs.ko, nfsd.ko.)
After I built the kernel, android-kernel/out/android13-5.10/dist/modules.builtin suggests that it's bundled into the kernel.
I tried the following which produced no .ko files:
$ cd ~/android-kernel/out/android13-5.10/aosp/
$ make \
ARCH=arm64 \
CC=~/android-kernel/prebuilts/clang/host/linux-x86/clang-r450784e/bin/clang \
CROSS_COMPILE=~/android-kernel/aosp/scripts/dummy-tools/ \
M=~/android-kernel/aosp/fs/exportfs \
--directory=
all
I googled around lots. It seems like most sources are rather old and don't make use of AOSP. Without AOSP, I tried to load my phone's kernel config in /proc/config.gz and use that to build, but this gives heaps of new build options that I must pick.
If modules can be built without AOSP that is acceptable too.
Instead of running a kernel mode NFS server you could run a user space NFS server. See unfs3 on github.
This means you only have to cross-compile unfs3 (using the NDK) and not any kernel modules.