| # Give user a chance to cross-compile this module on other kernels |
| |
| ifeq ($(CC),cc) |
| CC = gcc |
| endif |
| LD = ld |
| |
| CFLAGS += -Wall -D_KERNEL -O1 |
| |
| ifdef KERNEL_RELEASE |
| ifdef ARCH |
| CFLAGS += -Ikfreebsd/$(KERNEL_RELEASE) -Ikfreebsd/$(KERNEL_RELEASE)/$(ARCH) |
| else |
| $(error ARCH must be also defined when defining KERNEL_RELEASE) |
| endif |
| else |
| #KERNEL_NAME = $(shell uname -s) |
| #ifeq ($(shell uname -s),FreeBSD) |
| ifeq ($(findstring FreeBSD,$(shell uname -s)),FreeBSD) |
| #KERNEL_RELEASE = $(shell uname -r | sed 's/\..+//') |
| KERNEL_RELEASE = $(shell uname -r | grep -Eo '^[0-9]+') |
| else |
| $(error KERNEL_RELEASE undefined and current running kernel is not kFreeBSD) |
| endif |
| endif |
| |
| ifeq ($(shell [ $(KERNEL_RELEASE) -lt 10 ] && echo 1),1) |
| LDFLAGS += --shared |
| else |
| LDFLAGS += -r |
| endif |
| LDFLAGS += -d --warn-common |
| |
| myfault.ko: myfault.o |
| $(LD) $(LDFLAGS) $^ -o $@ |
| |
| myfault.o: myfault.c |
| $(CC) $(CFLAGS) -c $^ -o $@ |
| |
| clean: |
| rm -f myfault.ko myfault.o |