From 379e83140909b9dfcd3214ef1004d3338946e697 Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Wed, 11 Aug 2021 12:54:49 +0200 Subject: [PATCH] linux: gigevision kernel driver build setup It is just an empty driver for now :) --- drivers/linux-gv/Kbuild | 3 +++ drivers/linux-gv/arvgvkmod.c | 18 ++++++++++++++++++ drivers/linux-gv/meson.build | 13 +++++++++++++ drivers/meson.build | 12 ++++++++++++ drivers/mesonbuildkmod.sh | 7 +++++++ meson.build | 4 ++++ meson_options.txt | 2 ++ 7 files changed, 59 insertions(+) create mode 100644 drivers/linux-gv/Kbuild create mode 100644 drivers/linux-gv/arvgvkmod.c create mode 100644 drivers/linux-gv/meson.build create mode 100644 drivers/meson.build create mode 100755 drivers/mesonbuildkmod.sh diff --git a/drivers/linux-gv/Kbuild b/drivers/linux-gv/Kbuild new file mode 100644 index 000000000..9f4bb5e38 --- /dev/null +++ b/drivers/linux-gv/Kbuild @@ -0,0 +1,3 @@ +ccflags-y := $(MODULE_CFLAGS) +obj-m := aravis_gv.o +aravis_gv-y := $(patsubst $(src)/%.c,%.o,$(wildcard $(src)/*.c)) diff --git a/drivers/linux-gv/arvgvkmod.c b/drivers/linux-gv/arvgvkmod.c new file mode 100644 index 000000000..db1ae3245 --- /dev/null +++ b/drivers/linux-gv/arvgvkmod.c @@ -0,0 +1,18 @@ +#include + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Emmanuel Pacaud "); + +int +init_module(void) +{ + printk (KERN_ALERT "aravis: loaded\n"); + + return 0; +} + +void +cleanup_module(void) +{ + printk (KERN_ALERT "aravis: unloaded\n"); +} diff --git a/drivers/linux-gv/meson.build b/drivers/linux-gv/meson.build new file mode 100644 index 000000000..c6eec3bc6 --- /dev/null +++ b/drivers/linux-gv/meson.build @@ -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) + diff --git a/drivers/meson.build b/drivers/meson.build new file mode 100644 index 000000000..6256386c1 --- /dev/null +++ b/drivers/meson.build @@ -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 diff --git a/drivers/mesonbuildkmod.sh b/drivers/mesonbuildkmod.sh new file mode 100755 index 000000000..e85cf7afb --- /dev/null +++ b/drivers/mesonbuildkmod.sh @@ -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" diff --git a/meson.build b/meson.build index 299ee20b8..dae0dbb46 100644 --- a/meson.build +++ b/meson.build @@ -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)] diff --git a/meson_options.txt b/meson_options.txt index 02e1a2247..902d399f1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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)')