Skip to content

Commit

Permalink
linux: gigevision kernel driver build setup
Browse files Browse the repository at this point in the history
It is just an empty driver for now :)
  • Loading branch information
EmmanuelP committed Aug 11, 2021
1 parent 25c104a commit 379e831
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/linux-gv/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ccflags-y := $(MODULE_CFLAGS)
obj-m := aravis_gv.o
aravis_gv-y := $(patsubst $(src)/%.c,%.o,$(wildcard $(src)/*.c))
18 changes: 18 additions & 0 deletions drivers/linux-gv/arvgvkmod.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <linux/module.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Emmanuel Pacaud <[email protected]>");

int
init_module(void)
{
printk (KERN_ALERT "aravis: loaded\n");

return 0;
}

void
cleanup_module(void)
{
printk (KERN_ALERT "aravis: unloaded\n");
}
13 changes: 13 additions & 0 deletions drivers/linux-gv/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gv_mkfile = custom_target('gv_makefile', output:'Makefile', command:['touch', '@OUTPUT@'])

gv_sources = files([
'arvgvkmod.c'
])

custom_target ('gv_kmod',input: gv_sources, output: 'aravis_gv.ko', command:[
'make', '-j4', '-C', kernel_build_dir,
'M='+join_paths(meson.current_build_dir()),
'src='+join_paths(meson.current_source_dir()),
'MODULE_CFLAGS=-I'+meson.current_source_dir(),
'modules'], depends:gv_mkfile, build_by_default:true)

12 changes: 12 additions & 0 deletions drivers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if host_machine.system()=='linux'
kernel_version = run_command('uname', '-r').stdout().strip()
kernel_build_dir = join_paths('/', 'lib', 'modules', kernel_version, 'build')

# test running make in kernel directory, using "make kernelversion"
make_returncode = run_command('make', '-sC', kernel_build_dir, 'kernelversion').returncode()
if make_returncode != 0
error('Cannot compile kernel modules as requested - are kernel headers installed?')
endif

subdir('linux-gv')
endif
7 changes: 7 additions & 0 deletions drivers/mesonbuildkmod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir -p "$2/drivers/kmod.dir"
cp -Rf "$1/drivers/"* "$2/drivers/kmod.dir"
rm -f "$2/drivers/kmod.dir/meson.build" "$2/drivers/kmod.dir/mesonbuild.sh"
cd "$2/drivers/kmod.dir"
sed -i -e "s|\$(src)|$1/drivers|" "$2/drivers/kmod.dir/Kbuild"
make
mv "aravis_gv.ko" "$2/drivers"
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ viewer_deps = aravis_dependencies + [dependency ('gtk+-3.0', version: '>=3.12',
subdir ('po', if_found: viewer_deps)
subdir ('viewer', if_found: viewer_deps)

if get_option('drivers')
subdir('drivers')
endif

gst_option = get_option ('gst-plugin')
gst_deps = aravis_dependencies + [dependency ('gstreamer-base-1.0', required: gst_option),
dependency ('gstreamer-app-1.0', required: gst_option)]
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ option('packet-socket', type: 'feature', value: 'auto', description : 'Enable pa
option('tests', type: 'boolean', value: true, description: 'Build tests')
option('fast-heartbeat', type: 'boolean', value: false, description: 'Enable faster heartbeat rate')

option('drivers', type: 'boolean', value: false, description: 'Build linux driver')

# Documentation and introspection

option('documentation', type: 'feature', value: 'auto', description: 'Build API reference (requires gtk-doc and xlstproc)')
Expand Down

0 comments on commit 379e831

Please sign in to comment.