blob: 87240c43c63bdfc9d3641dc9420ef2f006154217 [file] [log] [blame] [raw]
# Give user a chance to cross-compile this module on other kernels
# This script assume you has defined correct CC, LD, CFLAGS and LDFLAGS
# to build the module that match the ARCH
ifeq ($(CC),cc)
CC = gcc
endif
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