1#
2# Copyright 2016, NICTA
3#
4# This software may be distributed and modified according to the terms of
5# the GNU General Public License version 2. Note that NO WARRANTY is provided.
6# See "LICENSE_GPLv2.txt" for details.
7#
8# @TAG(NICTA_GPL)
9#
10
11#
12# Makefile for the BilbyFs module (bilbyfs.ko)
13#
14
15# Run `make OS=linux' or `make OS=sel4' or
16# export OS environment variable
17OS=linux
18
19# Comment/uncomment the following line to disable/enable debugging
20DEBUG = n
21
22OS_PATH=os/$(OS)
23EXTRA_CFLAGS += -I$(PWD) -I$(PWD)/$(OS_PATH) -fstack-usage
24
25ifeq ($(DEBUG),y)
26  EXTRA_CFLAGS += -g -DBILBYFS_DEBUG
27endif
28
29# Linux kernel build system requires that there is no .c file named
30# after the name of the resulting .ko file.
31# In our case we are not allowed to have a "bilbyfs.c" file
32#
33MODULE = bilbyfs
34
35ifeq ($(OS),linux)
36  OS_SPEC_FILES = $(OS_PATH)/wrapper.o
37endif
38
39ifeq ($(OS),sel4)
40  OS_SPEC_FILES = $(OS_PATH)/wrapper.o $(OS_PATH)/ubisim.o
41endif
42
43# call from kernel build system
44ifneq ($(KERNELRELEASE),)
45
46  obj-m	+= $(MODULE).o
47  $(MODULE)-objs := \
48	$(OS_SPEC_FILES) \
49	fsop.o \
50	packobj.o \
51	ostore.o \
52	wbuf.o \
53	rdx.o \
54	dentarr.o \
55	fsm.o \
56	idx.o \
57	rbt.o \
58	gim.o \
59	gc.o \
60	allocpool.o \
61	debug.o
62
63else
64
65  KERNELDIR ?= /lib/modules/$(shell uname -r)/build
66  PWD       := $(shell pwd)
67
68default:
69	$(MAKE) CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS)" -C $(KERNELDIR) M=$(PWD) modules
70clean:
71	$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
72
73endif
74
75