-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
101 lines (74 loc) · 2.31 KB
/
Makefile
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
HERE=$(PWD)
LINUX=$(HERE)/../linux-2.6
force:
rm -f posix/lkl.a vfs.posix
make vfs.posix
all: vfs.posix vfs.apr vfs.nt net.linux
#vfs.ntk
include/asm:
-mkdir `dirname $@`
ln -s $(LINUX)/arch/lkl/include/asm include/asm
include/x86:
-mkdir `dirname $@`
ln -s $(LINUX)/arch/x86 include/x86
include/asm-generic:
-mkdir `dirname $@`
ln -s $(LINUX)/include/asm-generic include/asm-generic
include/linux:
-mkdir `dirname $@`
ln -s $(LINUX)/include/linux include/linux
INC=include/asm include/asm-generic include/x86 include/linux
CFLAGS=-Wall -g
ENVS=posix linux apr nt ntk
nt_CROSS=i586-mingw32msvc-
nt_EXTRA_CFLAGS=-gstabs+
ntk_CROSS=i586-mingw32msvc-
ntk_LD_FLAGS=-Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -nostartfiles \
-lntoskrnl -lhal -nostdlib -shared
ntk_EXTRA_CFLAGS=-gstabs+ -D_WIN32_WINNT=0x0500
posix_LD_FLAGS=-lpthread -rdynamic
linux_LD_FLAGS=-lpthread
#linux_CROSS=/opt/cegl-2.0/powerpc-750-linux-gnu/gcc-3.3.4-glibc-2.3.3/bin/powerpc-750-linux-gnu-
apr_EXTRA_CFLAGS:=`apr-1-config --cflags --cppflags --includes`
apr_LD_FLAGS:=`apr-1-config --link-ld --libs`
%/.config: %.config
mkdir -p $* && \
cp $< $@
%/vmlinux: %/.config
cd $(LINUX) && \
$(MAKE) O=$(HERE)/$* ARCH=lkl \
CROSS_COMPILE=$($*_CROSS) \
EXTRA_CFLAGS="$($*_EXTRA_CFLAGS) $(CFLAGS)" \
vmlinux
%/lkl.a: %/.config
cd $(LINUX) && \
$(MAKE) O=$(HERE)/$* ARCH=lkl \
CROSS_COMPILE=$($*_CROSS) \
EXTRA_CFLAGS="$($*_EXTRA_CFLAGS) $(CFLAGS)" \
lkl.a
define env_template
.PRECIOUS: $(1)/.config $(1)/vmlinux $(1)/lkl.a
%.$(1): %.c $(1)/vmlinux $(1)/lkl.a $(INC)
$($(1)_CROSS)gcc $$(CFLAGS) $($(1)_EXTRA_CFLAGS) -Iinclude -I$(1)/include $$*.c $(1)/vmlinux $(1)/lkl.a $($(1)_LD_FLAGS) -o $$@
endef
$(foreach env,$(ENVS),$(eval $(call env_template,$(env))))
bench.linux: bench.c bench*.h linux/vmlinux linux/lkl.a
$(linux_CROSS)gcc $(CFLAGS) $(linux_EXTRA_CFLAGS) -Iinclude -Ilinux/include bench.c linux/vmlinux linux/lkl.a $(linux_LD_FLAGS) -lm -o bench.linux
clean:
-rm -f $(patsubst %,*.%,$(ENVS))
clean-all: clean
-rm -rf apr linux posix nt ntk
-rm -f include/asm include/x86 include/asm-generic include/linux
-rmdir include
-rm -rf mnt disk
.PHONY:disk
disk:
rm -fr mnt disk
dd if=/dev/zero of=disk bs=4M count=10
mkfs.ext3 -F disk
mkdir mnt
sudo mount -o loop disk mnt
sudo cp -a /etc/ mnt/
sync
sync
sudo umount mnt