Bump version to 0.3.5next
[archipelago] / xseg / sys / kernel / Makefile
1 # Copyright 2012 GRNET S.A. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or
4 # without modification, are permitted provided that the following
5 # conditions are met:
6 #
7 #   1. Redistributions of source code must retain the above
8 #      copyright notice, this list of conditions and the following
9 #      disclaimer.
10 #
11 #   2. Redistributions in binary form must reproduce the above
12 #      copyright notice, this list of conditions and the following
13 #      disclaimer in the documentation and/or other materials
14 #      provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29 # The views and conclusions contained in the software and
30 # documentation are those of the authors and should not be
31 # interpreted as representing official policies, either expressed
32 # or implied, of GRNET S.A.
33 #
34
35 .PHONY: clean default install install-src
36
37 include $(XSEG_HOME)/base.mk
38
39 ifeq (,$(KVER))
40 KVER := $(shell uname -r)
41 endif
42
43 FILES="Makefile"
44 FILES+=$(shell ls *.h)
45 FILES+=$(shell ls *.c)
46
47 SUBDIR:=$(subst $(XSEG_HOME),,$(CURDIR))
48
49 KDIR := /lib/modules/$(KVER)/build
50 PWD := $(shell pwd)
51 EXTRA_CFLAGS += -g -I$(BASE) -I$(BASE)/sys/kernel -DVAL_OVERLOAD
52 LIBDIR=$(BASE)/lib/kernel
53
54 xseg-objs := xsegmod.o
55 xseg-objs += $(addsuffix .k.o, $(XTYPES))
56 xseg-objs += xseg.k.o
57 obj-m += xseg.o segdev.o
58
59 DEPENDENCIES = $(addsuffix .k.c, $(XTYPES))
60 DEPENDENCIES += xseg.k.c
61
62 default: $(DEPENDENCIES)
63         $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) V=$(V) modules
64         cp -vaf xseg.ko segdev.ko $(LIBDIR)
65
66 xq.k.c: $(BASE)/xtypes/xq.c $(BASE)/xtypes/xq.h
67         ln -sf $< $@
68
69 xpool.k.c: $(BASE)/xtypes/xpool.c $(BASE)/xtypes/xpool.h
70         ln -sf $< $@
71
72 xhash.k.c: $(BASE)/xtypes/xhash.c $(BASE)/xtypes/xhash.h
73         ln -sf $< $@
74
75 xheap.k.c: $(BASE)/xtypes/xheap.c $(BASE)/xtypes/xheap.h
76         ln -sf $< $@
77
78 xobj.k.c: $(BASE)/xtypes/xobj.c $(BASE)/xtypes/xobj.h
79         ln -sf $< $@
80
81 xworkq.k.c: $(BASE)/xtypes/xworkq.c $(BASE)/xtypes/xworkq.h
82         ln -sf $< $@
83
84 xwaitq.k.c: $(BASE)/xtypes/xwaitq.c $(BASE)/xtypes/xwaitq.h
85         ln -sf $< $@
86
87 xbinheap.k.c: $(BASE)/xtypes/xbinheap.c $(BASE)/xtypes/xbinheap.h
88         ln -sf $< $@
89
90 xcache.k.c: $(BASE)/xtypes/xcache.c $(BASE)/xtypes/xcache.h
91         ln -sf $< $@
92
93 xseg.k.c: $(BASE)/xseg/xseg.c $(BASE)/xseg/xseg.h
94         ln -sf $< $@
95
96 install:
97         install -d $(DESTDIR)$(moduledir)
98         install -o 0 -g 0 -m 644 -t $(DESTDIR)$(moduledir) xseg.ko
99         install -o 0 -g 0 -m 644 -t $(DESTDIR)$(moduledir) segdev.ko
100
101 install-src:
102         install -d $(DESTDIR)$(srcdir)$(SUBDIR)
103         @for f in $(FILES); do \
104                 install -o 0 -g 0 -m 644 -t $(DESTDIR)$(srcdir)$(SUBDIR) $$f ; \
105         done
106
107 clean:
108         rm -f $(DEPENDENCIES)
109         make -C /lib/modules/$(KVER)/build M=$(PWD) V=$(V) clean