Skip to content

Commit f11065f

Browse files
committed
update Makefile to new lkl
1 parent 8e69e65 commit f11065f

File tree

1 file changed

+44
-29
lines changed

1 file changed

+44
-29
lines changed

Makefile

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,93 @@ CROSS=i586-mingw32msvc-
22
CC=$(CROSS)gcc
33
AS=$(CROSS)as
44
DLLTOOL=$(CROSS)dlltool
5-
HERE=$(PWD)
5+
MKDIR=mkdir -p
66

7+
HERE=$(PWD)
78
LKL_SOURCE=$(HERE)/../linux-2.6
8-
LKL=lkl/vmlinux
9+
910

1011
SRCS=$(shell find $(1) -type f -name '*.c')
1112
OBJS=$(patsubst %.c,%.o,$(call SRCS,$(1)))
1213
DEPS=$(patsubst %.c,.deps/%.d,$(call SRCS,$(1)))
1314

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+
1625

1726
all: lklvfs.sys
1827

1928
include/asm:
20-
-$(MKDIR) `dirname $@` || true
29+
-$(MKDIR) `dirname $@`
2130
ln -s $(LKL_SOURCE)/arch/lkl/include/asm include/asm
2231

2332
include/x86:
24-
-$(MKDIR) `dirname $@` || true
33+
-$(MKDIR) `dirname $@`
2534
ln -s $(LKL_SOURCE)/arch/x86 include/x86
2635

2736
include/asm-generic:
28-
-$(MKDIR) `dirname $@` || true
37+
-$(MKDIR) `dirname $@`
2938
ln -s $(LKL_SOURCE)/include/asm-generic include/asm-generic
3039

3140
include/linux:
32-
-$(MKDIR) `dirname $@` || true
41+
-$(MKDIR) `dirname $@`
3342
ln -s $(LKL_SOURCE)/include/linux include/linux
3443

35-
include/drivers:
36-
-$(MKDIR) `dirname $@` || true
37-
ln -s $(HERE)/drivers/ include/drivers
44+
%/.config: %.config
45+
-$(MKDIR) `dirname $@` && \
46+
cp $< $@
3847

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
4254

43-
lkl/vmlinux: lkl/.config $(call SRCS,drivers) drivers/Makefile Makefile
55+
%/lkl.a: %/.config
4456
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
4861

49-
CFLAGS=-Iinclude -D_WIN32_WINNT=0x0500 -Wall -Wno-multichar
5062

5163
lib/%.a: lib/%.def
5264
$(DLLTOOL) --as=$(AS) -k --output-lib $@ --def $^
5365

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
5567

5668
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 \
5972
-nostartfiles -Llib -lmingw-patch -lntoskrnl -lhal -nostdlib \
6073
-shared -o $@
6174

6275
clean:
6376
rm -rf .deps lklvfs.sys
64-
rm -f drivers/*.o drivers/.*.o.cmd drivers/built-in.o
6577
rm -f src/*.o
6678

6779
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 $^
7186

72-
TAGS: $(call SRCS,src) $(call SRCS,drivers) Makefile include/*.h
87+
TAGS-all: $(call SRCS,src) Makefile include/*.h
7388
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
7590
etags -f TAGS.tmp $^
76-
cat lkl/TAGS TAGS.tmp > TAGS
91+
cat ntk/TAGS TAGS.tmp > TAGS
7792
rm TAGS.tmp
7893

7994
.deps/%.d: %.c

0 commit comments

Comments
 (0)