@@ -2,78 +2,93 @@ CROSS=i586-mingw32msvc-
2
2
CC =$(CROSS ) gcc
3
3
AS =$(CROSS ) as
4
4
DLLTOOL =$(CROSS ) dlltool
5
- HERE = $( PWD )
5
+ MKDIR =mkdir -p
6
6
7
+ HERE =$(PWD )
7
8
LKL_SOURCE =$(HERE ) /../linux-2.6
8
- LKL =lkl/vmlinux
9
+
9
10
10
11
SRCS =$(shell find $(1 ) -type f -name '* .c')
11
12
OBJS =$(patsubst % .c,% .o,$(call SRCS,$(1 ) ) )
12
13
DEPS =$(patsubst % .c,.deps/% .d,$(call SRCS,$(1 ) ) )
13
14
14
- INC =include/asm include/asm-generic include/x86 include/linux include/drivers
15
- MKDIR =mkdir -p
15
+
16
+ INC =include/asm include/asm-generic include/x86 include/linux
17
+ CFLAGS =-Iinclude -D_WIN32_WINNT=0x0500 -Wall -Wno-multichar
18
+
19
+
20
+ ntk_CROSS =i586-mingw32msvc-
21
+ ntk_LD_FLAGS =-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -nostartfiles \
22
+ -lntoskrnl -lhal -nostdlib -shared
23
+ ntk_EXTRA_CFLAGS =-gstabs+ -D_WIN32_WINNT=0x0500
24
+
16
25
17
26
all : lklvfs.sys
18
27
19
28
include/asm :
20
- -$(MKDIR ) ` dirname $@ ` || true
29
+ -$(MKDIR ) ` dirname $@ `
21
30
ln -s $(LKL_SOURCE ) /arch/lkl/include/asm include/asm
22
31
23
32
include/x86 :
24
- -$(MKDIR ) ` dirname $@ ` || true
33
+ -$(MKDIR ) ` dirname $@ `
25
34
ln -s $(LKL_SOURCE ) /arch/x86 include/x86
26
35
27
36
include/asm-generic :
28
- -$(MKDIR ) ` dirname $@ ` || true
37
+ -$(MKDIR ) ` dirname $@ `
29
38
ln -s $(LKL_SOURCE ) /include/asm-generic include/asm-generic
30
39
31
40
include/linux :
32
- -$(MKDIR ) ` dirname $@ ` || true
41
+ -$(MKDIR ) ` dirname $@ `
33
42
ln -s $(LKL_SOURCE ) /include/linux include/linux
34
43
35
- include/drivers :
36
- -$(MKDIR ) ` dirname $@ ` || true
37
- ln -s $( HERE ) /drivers/ include/drivers
44
+ % /.config : % .config
45
+ -$(MKDIR ) ` dirname $@ ` && \
46
+ cp $< $@
38
47
39
- lkl/.config : $(LKL_SOURCE )
40
- -$(MKDIR ) ` dirname $@ ` || true
41
- cp $^ /arch/lkl/defconfig $@
48
+ % /vmlinux : % /.config
49
+ cd $(LKL_SOURCE ) && \
50
+ $(MAKE ) O=$(HERE ) /$* ARCH=lkl \
51
+ CROSS_COMPILE=$($* _CROSS) \
52
+ EXTRA_CFLAGS=" $( $* _EXTRA_CFLAGS) $( CFLAGS) " \
53
+ vmlinux
42
54
43
- lkl/vmlinux : lkl /.config $( call SRCS,drivers) drivers/Makefile Makefile
55
+ % /lkl.a : % /.config
44
56
cd $(LKL_SOURCE ) && \
45
- $(MAKE ) O=$(HERE ) /lkl ARCH=lkl CROSS_COMPILE=i586-mingw32msvc- \
46
- LKL_DRIVERS=$(HERE ) /drivers/ \
47
- vmlinux
57
+ $(MAKE ) O=$(HERE ) /$* ARCH=lkl \
58
+ CROSS_COMPILE=$($* _CROSS) \
59
+ EXTRA_CFLAGS=" $( $* _EXTRA_CFLAGS) $( CFLAGS) " \
60
+ lkl.a
48
61
49
- CFLAGS =-Iinclude -D_WIN32_WINNT=0x0500 -Wall -Wno-multichar
50
62
51
63
lib/% .a : lib/% .def
52
64
$(DLLTOOL ) --as=$(AS ) -k --output-lib $@ --def $^
53
65
54
- LKLVFS_SRC = $(call OBJS,src) lib/libmingw-patch.a lkl /vmlinux
66
+ LKLVFS_SRC = $(call OBJS,src) lib/libmingw-patch.a ntk /vmlinux ntk/lkl.a
55
67
56
68
lklvfs.sys : $(INC ) $(LKLVFS_SRC )
57
- i586-mingw32msvc-gcc -Wall -s \
58
- $(LKLVFS_SRC ) -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 \
69
+ $(CC ) -Wall -s \
70
+ $(LKLVFS_SRC ) /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libgcc.a \
71
+ -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 \
59
72
-nostartfiles -Llib -lmingw-patch -lntoskrnl -lhal -nostdlib \
60
73
-shared -o $@
61
74
62
75
clean :
63
76
rm -rf .deps lklvfs.sys
64
- rm -f drivers/* .o drivers/.* .o.cmd drivers/built-in.o
65
77
rm -f src/* .o
66
78
67
79
clean-all : clean
68
- rm -f include/asm include/x86 \
69
- include/asm-generic include/linux $(call OBJS,src) lib/* .a
70
- rm -fr lkl
80
+ rm -f include/asm include/x86 include/asm-generic include/linux
81
+ rm -f $(call OBJS,src) lib/* .a
82
+ rm -fr ntk
83
+
84
+ TAGS : $(call SRCS,src) Makefile include/* .h
85
+ etags $^
71
86
72
- TAGS : $(call SRCS,src) $( call SRCS,drivers ) Makefile include/* .h
87
+ TAGS-all : $(call SRCS,src) Makefile include/* .h
73
88
cd $(LKL_SOURCE ) && \
74
- $(MAKE ) O=$(HERE ) /lkl ARCH=lkl CROSS_COMPILE=i586-mingw32msvc- TAGS
89
+ $(MAKE ) O=$(HERE ) /ntk ARCH=lkl CROSS_COMPILE=$( CROSS ) TAGS
75
90
etags -f TAGS.tmp $^
76
- cat lkl /TAGS TAGS.tmp > TAGS
91
+ cat ntk /TAGS TAGS.tmp > TAGS
77
92
rm TAGS.tmp
78
93
79
94
.deps/% .d : % .c
0 commit comments