Skip to content

Commit 44da705

Browse files
committed
linux: gigevision kernel driver build setup
It is just an empty driver for now :)
1 parent 13ad826 commit 44da705

7 files changed

Lines changed: 59 additions & 0 deletions

File tree

drivers/linux-gv/Kbuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ccflags-y := $(MODULE_CFLAGS)
2+
obj-m := aravis_gv.o
3+
aravis_gv-y := $(patsubst $(src)/%.c,%.o,$(wildcard $(src)/*.c))

drivers/linux-gv/arvgvkmod.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <linux/module.h>
2+
3+
MODULE_LICENSE("GPL");
4+
MODULE_AUTHOR("Emmanuel Pacaud <emmanuel@gnome.org>");
5+
6+
int
7+
init_module(void)
8+
{
9+
printk (KERN_ALERT "aravis: loaded\n");
10+
11+
return 0;
12+
}
13+
14+
void
15+
cleanup_module(void)
16+
{
17+
printk (KERN_ALERT "aravis: unloaded\n");
18+
}

drivers/linux-gv/meson.build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
gv_mkfile = custom_target('gv_makefile', output:'Makefile', command:['touch', '@OUTPUT@'])
2+
3+
gv_sources = files([
4+
'arvgvkmod.c'
5+
])
6+
7+
custom_target ('gv_kmod',input: gv_sources, output: 'aravis_gv.ko', command:[
8+
'make', '-j4', '-C', kernel_build_dir,
9+
'M='+join_paths(meson.current_build_dir()),
10+
'src='+join_paths(meson.current_source_dir()),
11+
'MODULE_CFLAGS=-I'+meson.current_source_dir(),
12+
'modules'], depends:gv_mkfile, build_by_default:true)
13+

drivers/meson.build

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if host_machine.system()=='linux'
2+
kernel_version = run_command('uname', '-r').stdout().strip()
3+
kernel_build_dir = join_paths('/', 'lib', 'modules', kernel_version, 'build')
4+
5+
# test running make in kernel directory, using "make kernelversion"
6+
make_returncode = run_command('make', '-sC', kernel_build_dir, 'kernelversion').returncode()
7+
if make_returncode != 0
8+
error('Cannot compile kernel modules as requested - are kernel headers installed?')
9+
endif
10+
11+
subdir('linux-gv')
12+
endif

drivers/mesonbuildkmod.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mkdir -p "$2/drivers/kmod.dir"
2+
cp -Rf "$1/drivers/"* "$2/drivers/kmod.dir"
3+
rm -f "$2/drivers/kmod.dir/meson.build" "$2/drivers/kmod.dir/mesonbuild.sh"
4+
cd "$2/drivers/kmod.dir"
5+
sed -i -e "s|\$(src)|$1/drivers|" "$2/drivers/kmod.dir/Kbuild"
6+
make
7+
mv "aravis_gv.ko" "$2/drivers"

meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ viewer_deps = aravis_dependencies + [dependency ('gtk+-3.0', version: '>=3.12',
9191
subdir ('po', if_found: viewer_deps)
9292
subdir ('viewer', if_found: viewer_deps)
9393

94+
if get_option('drivers')
95+
subdir('drivers')
96+
endif
97+
9498
gst_option = get_option ('gst-plugin')
9599
gst_deps = aravis_dependencies + [dependency ('gstreamer-base-1.0', required: gst_option),
96100
dependency ('gstreamer-app-1.0', required: gst_option)]

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ option('packet-socket', type: 'feature', value: 'auto', description : 'Enable pa
88
option('tests', type: 'boolean', value: true, description: 'Build tests')
99
option('fast-heartbeat', type: 'boolean', value: false, description: 'Enable faster heartbeat rate')
1010

11+
option('drivers', type: 'boolean', value: false, description: 'Build linux driver')
12+
1113
# Documentation and introspection
1214

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

0 commit comments

Comments
 (0)