-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (47 loc) · 1.59 KB
/
Makefile
File metadata and controls
68 lines (47 loc) · 1.59 KB
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
.PHONY: clean sys_call_clean std_lib_clean string_clean stdio_clean unistd_clean assert_clean
SYSCALL_PATH := ${SYSCALL_PATH}
STDLIB_PATH := ${STDLIB_PATH}
STRING_PATH := ${STRING_PATH}
STDIO_PATH := ${STDIO_PATH}
UNISTD_PATH := ${UNISTD_PATH}
ASSERT_PATH := ${ASSERT_PATH}
all: dynamic
out := test.o
entry := entry.o
base: _syscall _unistd _string _stdlib _stdio _assert
static: base $(entry) $(out)
ld -e tcrt_entry -o test $(out) $(entry) $(STDLIB_PATH)/libstdlib.a $(STDIO_PATH)/libstdio.a $(STRING_PATH)/libstring.a $(SYSCALL_PATH)/libsyscall.a $(UNISTD_PATH)/libunistd.a $(ASSERT_PATH)/libassert.a
dynamic: base $(entry) $(out)
gcc -Wl,-etcrt_entry -o test -nostdlib -fno-builtin -fno-stack-protector $(out) $(entry) -L$(STDLIB_PATH) -lstdlib -L$(SYSCALL_PATH) -lsyscall -L$(STRING_PATH) -lstring -L$(STDIO_PATH) -lstdio -L$(UNISTD_PATH) -lunistd -L$(ASSERT_PATH) -lassert
_syscall:
make -C $(SYSCALL_PATH)
_stdlib:
make -C $(STDLIB_PATH)
_string:
make -C $(STRING_PATH)
_stdio:
make -C $(STDIO_PATH)
_unistd:
make -C $(UNISTD_PATH)
_assert:
make -C $(ASSERT_PATH)
%.o: %.c
gcc -c -g3 -fPIC -nostdlib -fno-builtin -fno-stack-protector $<
gdb: dynamic
gdb -q -args ./test test
gdb_static: static
gdb -q -args ./test test
clean: syscall_clean stdlib_clean string_clean stdio_clean unistd_clean assert_clean
rm -rf *.o test
syscall_clean:
make -C $(SYSCALL_PATH) clean
stdlib_clean:
make -C $(STDLIB_PATH) clean
string_clean:
make -C $(STRING_PATH) clean
stdio_clean:
make -C $(STDIO_PATH) clean
unistd_clean:
make -C $(UNISTD_PATH) clean
assert_clean:
make -C $(ASSERT_PATH) clean