-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
102 lines (77 loc) · 3.24 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
102
BUILD_DIR = ./build
AS = nasm
CC = gcc
LD = gcc
AR = ar
LIB = -I include/
ASFLAGS = -f elf64
CFLAGS = -Wl,--no-as-needed -ldl -c -g $(LIB)
#OBJS = $(BUILD_DIR)/main.o $(BUILD_DIR)/assert.o $(BUILD_DIR)/task.o $(BUILD_DIR)/list.o \
$(BUILD_DIR)/analog_interrupt.o $(BUILD_DIR)/timer.o $(BUILD_DIR)/died_context_swap.o \
$(BUILD_DIR)/bitmap.o $(BUILD_DIR)/context_swap.o $(BUILD_DIR)/debug.o $(BUILD_DIR)/sync.o \
$(BUILD_DIR)/console.o $(BUILD_DIR)/ioqueue.o $(BUILD_DIR)/init.o
OBJS = $(BUILD_DIR)/hook.o $(BUILD_DIR)/assert.o $(BUILD_DIR)/task.o $(BUILD_DIR)/list.o \
$(BUILD_DIR)/analog_interrupt.o $(BUILD_DIR)/timer.o $(BUILD_DIR)/died_context_swap.o \
$(BUILD_DIR)/bitmap.o $(BUILD_DIR)/context_swap.o $(BUILD_DIR)/debug.o $(BUILD_DIR)/sync.o \
$(BUILD_DIR)/console.o $(BUILD_DIR)/ioqueue.o $(BUILD_DIR)/init.o $(BUILD_DIR)/get_reg.o
###### 编译 ######
# $(BUILD_DIR)/main.o: main.c include/task.h
# $(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/hook.o: hook.c include/task.h
# D_GNU_SOURCE 是必要的,因为RTLD_NEXT不是posix标准定义的
$(CC) $< $(CFLAGS) -D_GNU_SOURCE -export-dynamic -o $@
$(BUILD_DIR)/list.o: lib/list.c include/list.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/assert.o: lib/assert.c include/assert.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/task.o: task/task.c include/task.h \
include/list.h include/assert.h include/bitmap.h include/debug.h include/sync.h hook.c
$(CC) $(CFLAGS) $(BUILD_DIR)/hook.o $< -o $@
$(BUILD_DIR)/analog_interrupt.o: interrupt/analog_interrupt.c include/analog_interrupt.h \
include/set_ticker.h include/stdint.h include/assert.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/timer.o: interrupt/timer.c include/timer.h \
include/stdint.h include/task.h include/assert.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/bitmap.o: lib/bitmap.c include/bitmap.h \
include/stdint.h include/assert.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/debug.o: task/debug.c include/debug.h \
include/analog_interrupt.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/sync.o: task/sync.c include/sync.h \
include/stdint.h include/list.h include/analog_interrupt.h \
include/debug.h include/assert.h include/task.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/console.o: device/console.c include/console.h \
include/sync.h include/task.h include/ioqueue.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/ioqueue.o: device/ioqueue.c include/ioqueue.h \
include/analog_interrupt.h include/stdint.h include/debug.h include/assert.h \
include/console.h
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/init.o: task/init.c include/init.h \
include/task.h include/console.h include/ioqueue.h \
include/analog_interrupt.h
$(CC) $(CFLAGS) $< -o $@
###### 汇编文件 ######
$(BUILD_DIR)/died_context_swap.o: task/died_context_swap.asm
$(AS) $(ASFLAGS) $< -o $@
$(BUILD_DIR)/context_swap.o: task/context_swap.asm
$(AS) $(ASFLAGS) $< -o $@
$(BUILD_DIR)/get_reg.o: task/get_reg.asm
$(AS) $(ASFLAGS) $< -o $@
###### 生成库文件 ######
libtask.a: $(OBJS)
$(AR) rcs libtask.a $(OBJS)
###### 链接 ######
# main: $(OBJS)
# $(LD) $(^) -o $@
.PHONY: mk_dir clean all
mk_dir:
if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR);fi
clean:
# rm main && cd $(BUILD_DIR) && rm -f ./*
cd $(BUILD_DIR) && rm -rf ./*
build: libtask.a
all:mk_dir build