-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (54 loc) · 1.35 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
include util.mk
FRONT_ARCH ?= mips32
BACK_ARCH ?= $(shell uname -m)
DEBUG ?= 1
STRIP ?= 0
c_flags := \
-std=c11 -Wall -Werror \
-O2 -ggdb \
-Isrc/include \
-fno-asynchronous-unwind-tables \
-fno-math-errno \
-D_DEFAULT_SOURCE \
-DBACK_ARCH_$(call uppercase,$(BACK_ARCH)) \
-DFRONT_ARCH_$(call uppercase,$(FRONT_ARCH)) \
s_source :=
c_source := \
src/elf.c \
src/main.c \
src/mm.c \
src/signal.c \
src/syscall.c
ifeq ($(DEBUG),1)
c_flags += -DDEBUG
c_source += src/debug.c
endif
include src/syscalls/Makefile
include src/frontend/$(FRONT_ARCH)/Makefile
include src/backend/$(BACK_ARCH)/Makefile
s_objects := $(patsubst %.S,%.o,$(s_source))
c_objects := $(patsubst %.c,%.o,$(c_source))
objects := $(s_objects) $(c_objects)
depfiles := $(patsubst %.o,%.d,$(objects))
.PHONY: all
all: hoodwink
.PHONY: clean
clean:
rm -f hoodwink hoodwink.elf $(objects) $(depfiles)
ifeq ($(STRIP),1)
hoodwink: hoodwink.elf
rm -f $@
strip -s -R .comment -R .note.gnu.build-id -o $@ $<
else
hoodwink: hoodwink.elf
ln -sf $< $@
endif
hoodwink.elf: $(objects) Makefile
$(CC) $(c_flags) $(CFLAGS) -o $@ -nostdlib -static $(objects)
%.o: %.c Makefile
$(CC) $(c_flags) $(CFLAGS) -o $@ -c $<
$(CC) $(c_flags) $(CFLAGS) -MM -MT $@ -c $< >$*.d
%.o: %.S Makefile
$(CC) $(c_flags) $(CFLAGS) -o $@ -c $<
$(CC) $(c_flags) $(CFLAGS) -MM -MT $@ -c $< >$*.d
-include $(depfiles)