From 85eb771fa527e2760492f087cce007a504ae36be Mon Sep 17 00:00:00 2001 From: Valentin Lechner Date: Tue, 19 Nov 2019 15:20:53 +0100 Subject: [PATCH] Update Makefile, Adding more fileext to .gitignorey --- .gitignore | 12 ++++++++++-- 8008135.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- Makefile | 31 +++++-------------------------- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 98b2346..364a1fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,15 @@ + *.anjuta* + +*.mod.* +8008135 *.out *.a *.ko *.o -*.*~ -8008135 + +*~ +*.symvers +*.order +.tmp_versions/ +*.cmd diff --git a/8008135.c b/8008135.c index ac6725b..1778941 100644 --- a/8008135.c +++ b/8008135.c @@ -17,10 +17,47 @@ * with this program. If not, see . */ -#include -int main() -{ - printf("Hello world\n"); - return (0); +/**** Includes *************************************************************** +*******************************************************************************/ +#include +#include +#include + + +/**** Modinfo **************************************************************** +*******************************************************************************/ + +MODULE_LICENSE("GPLv3"); +MODULE_AUTHOR("JanKoernerEnterprises"); +MODULE_DESCRIPTION("8008135"); +MODULE_VERSION("0.1"); + +/**** var ******************************************************************** +*******************************************************************************/ +static char *name = "8008135"; + + +/*** FUNCTION **************************************************************** +* NAME: init_8008135 +* DESCRIPTION: initializing Kernel Module +* PARAMETERS: - +* RETURNS: int +*******************************************************************************/ +static int __init init_8008135(void) { + printk(KERN_INFO "Loading %s into Kernel", name); + return 0; +} + +/*** FUNCTION **************************************************************** +* NAME: exit_8008135 +* DESCRIPTION: unloading Kernel Module +* PARAMETERS: - +* RETURNS: - +*******************************************************************************/ +static void __exit exit_8008135(void) { + printk(KERN_INFO "Unloading %s from Kernel", name); } +// Setting pointers to init-/exit-functions +module_init(init_8008135); +module_exit(exit_8008135); diff --git a/Makefile b/Makefile index dad9fa4..a5507a8 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,9 @@ +obj-m+=8008135.o -## Created by Anjuta - -CC = gcc -CFLAGS = -g -Wall -OBJECTS = 8008135.o -INCFLAGS = -LDFLAGS = -Wl,-rpath,/usr/local/lib -LIBS = - -all: 8008135 - -8008135: $(OBJECTS) - $(CC) -o 8008135 $(OBJECTS) $(LDFLAGS) $(LIBS) - -.SUFFIXES: -.SUFFIXES: .c .cc .C .cpp .o - -.c.o : - $(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS) - -count: - wc *.c *.cc *.C *.cpp *.h *.hpp +all: + make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules clean: - rm -f *.o + make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean + -.PHONY: all -.PHONY: count -.PHONY: clean