summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: aced26ef3aa15deee15d727389f05d1dd97f6c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Makfile assignments:
#  := value at right is expanded and assigned at declaration time
#   = value at right is expanded only when it is used, hence it is a reference
#  ?= value at right is assigned only if the variable doesn't have a value
#

# run following to compile with debug options
# $ DEBUG=1 make
ifneq ($(DEBUG),)
  DEBUG_FLAGS = -O0 -g -DHELLO_DEBUG
endif

# see Documentation/kbuild/makefiles.txt
EXTRA_CFLAGS += $(DEBUG_FLAGS)

ifneq ($(KERNELRELEASE),)
# call from kernel build system

# objects that are part of hello module (hello.o)
#hello-objs += main.o debug.o
hello-y += main.o debug.o

# .ko module to be created
obj-m := hello.o

# normal makefile, not kbuild
else

KERNELDIR ?= /lib/modules/$(shell uname -r)/build

# '-C' changes the dir
# '-M' causes the the kernel's toplevel Makefile to move back into this dir
#      before trying to build 'modules' target
#      and it informs kbuild that an external module is being built
all:
	make -C $(KERNELDIR) KCPPFLAGS="-I$(CURDIR)" M=$(PWD) modules

endif

kclean:
	make -C $(KERNELDIR) M=$(PWD) clean

# if above gives perm problem for normal user, try this
kcleanu:
	make -C $(KERNELDIR) SUBDIRS=$(CURDIR) clean

clean:
	@rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions Module.symvers modules.order