2
2
# parameters #
3
3
# #############
4
4
5
+ # fill in the name of the module
6
+ name: =kcpp
5
7
# fill in the object files which are part of the module
6
- obj-m: =kcpp .o
7
- kcpp -objs: =top.o ser_mem.o ser_print.o
8
+ obj-m: =$( name ) .o
9
+ $(name) -objs: =top.o ser_mem.o ser_print.o ser_empty .o
8
10
# fill in any extra compiler flags
9
11
EXTRA_CFLAGS+ =-Werror -I.
10
- # fill in the name of the module
11
- name: =kcpp
12
12
# fill in the name of the genrated ko file
13
13
ko-m: =$(name ) .ko
14
14
# fill in the version of the kernel for which you want the module compiled to
@@ -41,21 +41,26 @@ C_OBJECTS:=$(addsuffix .o,$(basename $(C_SOURCES)))
41
41
42
42
# this rule was also taken from running with V=1
43
43
$(ko-m ) : top.o top.mod.o $(CC_OBJECTS ) checkpatch
44
- $(Q ) ld -r -m elf_i386 --build-id -o $(ko-m ) $(C_OBJECTS ) kcpp.mod.o $(CC_OBJECTS )
44
+ $(info doing [$@ ])
45
+ $(Q ) ld -r -m elf_i386 --build-id -o $(ko-m ) $(C_OBJECTS ) $(name ) .mod.o $(CC_OBJECTS )
45
46
# how was this monstrosity created?
46
47
# I ran the build with V=1 and registered the command to compile via gcc.
47
48
# picked the same version g++ and gave it the entire flag set (especially the -f stuff).
48
49
# removed all -D, preprocessor and
49
50
# -ffreestanding -Wno-pointer-sign -Wdeclaration-after-statement
50
51
# -Werror-implicit-function-declaration -Wstrict-prototypes
51
52
# which are not relevant to C++ (the compiler told me so!)
53
+ # trying to add -fno-exceptions
52
54
% .o : % .cc
53
- $(Q ) g++ -nostdinc -Wall -Wundef -Wno-trigraphs -fno-strict-aliasing -fno-common -Os -fno-stack-protector -m32 -msoft-float -mregparm=3 -freg-struct-return -mpreferred-stack-boundary=2 -march=i686 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fomit-frame-pointer -Werror -c -o $@ $<
55
+ $(info doing [$@ ])
56
+ $(Q ) g++ -nostdinc -Wall -Wundef -Wno-trigraphs -fno-strict-aliasing -fno-common -fno-delete-null-pointer-checks -O2 -m32 -msoft-float -mregparm=3 -freg-struct-return -fno-pic -mpreferred-stack-boundary=2 -march=i686 -mtune=generic -maccumulate-outgoing-args -Wa,-mtune=generic32 -ffreestanding -fstack-protector -pipe -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-overflow -fconserve-stack -fno-exceptions -Werror -c -o $@ $<
54
57
top.o top.mod.o : top.c
58
+ $(info doing [$@ ])
55
59
$(Q )$(MAKE ) -C $(KDIR ) M=$(CURDIR ) V=$(V ) modules
56
60
$(Q ) -rm -f top.ko
57
61
.PHONY : modules
58
62
modules :
63
+ $(info doing [$@ ])
59
64
$(Q )$(MAKE ) -C $(KDIR ) M=$(CURDIR ) V=$(V ) modules
60
65
.PHONY : modules_install
61
66
modules_install :
@@ -65,36 +70,47 @@ clean:
65
70
$(Q )$(MAKE ) -C $(KDIR ) M=$(CURDIR ) V=$(V ) clean
66
71
.PHONY : help
67
72
help :
73
+ $(info doing [$@ ])
68
74
$(Q )$(MAKE ) -C $(KDIR ) M=$(CURDIR ) V=$(V ) help
69
75
.PHONY : insmod
70
76
insmod :
77
+ $(info doing [$@ ])
71
78
$(Q ) sudo insmod $(ko-m )
72
79
.PHONY : lsmod
73
80
lsmod :
81
+ $(info doing [$@ ])
74
82
$(Q ) sudo lsmod | grep $(name )
75
83
.PHONY : rmmod
76
84
rmmod :
85
+ $(info doing [$@ ])
77
86
$(Q ) sudo rmmod $(name )
78
87
.PHONY : modinfo
79
88
modinfo :
89
+ $(info doing [$@ ])
80
90
$(Q ) sudo modinfo $(ko-m )
81
91
.PHONY : last
82
92
last :
93
+ $(info doing [$@ ])
83
94
$(Q ) sudo tail /var/log/kern.log
84
95
.PHONY : log
85
96
log :
97
+ $(info doing [$@ ])
86
98
$(Q ) sudo tail -f /var/log/kern.log
87
99
.PHONY : cleanlog
88
100
cleanlog :
101
+ $(info doing [$@ ])
89
102
$(Q ) sudo dmesg -c > /dev/null
90
103
.PHONY : halt
91
104
halt :
105
+ $(info doing [$@ ])
92
106
$(Q ) sudo halt
93
107
.PHONY : reboot
94
108
reboot :
109
+ $(info doing [$@ ])
95
110
$(Q ) sudo reboot
96
111
.PHONY : tips
97
112
tips :
113
+ $(info doing [$@ ])
98
114
$(Q ) echo " do make V=1 [target] to see more of what is going on"
99
115
$(Q ) echo
100
116
$(Q ) echo " in order for the operational targets to work you need to"
@@ -108,6 +124,9 @@ tips:
108
124
$(Q ) echo " or edit the file and permanently change the version"
109
125
.PHONY : debug
110
126
debug :
127
+ $(info doing [$@ ])
128
+ $(info name is $(name ) )
129
+ $(info ko-m is $(ko-m ) )
111
130
$(info V is $(V ) )
112
131
$(info CURDIR is $(CURDIR ) )
113
132
$(info KVER is $(KVER ) )
@@ -123,3 +142,7 @@ checkpatch:
123
142
$(Q ) scripts/wrapper.py ~ /install/linux-3.6.3/scripts/checkpatch.pl --file top.c --root ~ /install/linux-3.6.3
124
143
$(Q ) scripts/wrapper.py ~ /install/linux-3.6.3/scripts/checkpatch.pl --file ser_mem.c --root ~ /install/linux-3.6.3
125
144
$(Q ) scripts/wrapper.py ~ /install/linux-3.6.3/scripts/checkpatch.pl --file ser_print.c --root ~ /install/linux-3.6.3
145
+ test_stress_insmod_rmmod : $(ko-m )
146
+ $(info doing [$@ ])
147
+ -sudo rmmod $(name )
148
+ ./scripts/test_stress_insmod_rmmod.pl $(ko-m ) 1000
0 commit comments