-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile-np
85 lines (60 loc) · 2.33 KB
/
Makefile-np
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
# This work is licensed under TURNSTONE OS Public License.
# Please read and understand latest version of Licence.
HOSTOS =$(shell uname -s)
MAKE = make
ifeq ($(HOSTOS),Darwin)
CC64 = x86_64-elf-gcc
OBJCOPY = x86_64-elf-objcopy
SEDNOBAK = sed -i ''
else
CC64 = gcc
OBJCOPY = objcopy
SEDNOBAK = sed -i
endif
DOCSGEN = doxygen
DOCSFILES = $(shell find . -type f -name \*.md)
DOCSCONF = docs.doxygen
INCLUDESDIR = includes
CCXXFLAGS += -std=gnu11 -O2 -nostdlib -nostdinc -ffreestanding -fno-builtin -c -I$(INCLUDESDIR) \
-Werror -Wall -Wextra -ffunction-sections -fdata-sections \
-mno-red-zone -fstack-protector-all -fno-omit-frame-pointer \
-Wshadow -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wmissing-prototypes -Wmissing-declarations \
-Wredundant-decls -Wnested-externs -Winline -Wno-long-long \
-Wstrict-prototypes \
-fPIC -fplt -mcmodel=large -fno-ident -fno-asynchronous-unwind-tables ${CCXXEXTRAFLAGS}
CXXTESTFLAGS= -D___TESTMODE=1
CC64FLAGS = -m64 -march=x86-64 -D___BITS=64 -msse4.2 $(CCXXFLAGS)
CC64INTFLAGS = -m64 -march=x86-64 -mgeneral-regs-only -D___BITS=64 $(CCXXFLAGS)
OBJDIR = output
ASOBJDIR = $(OBJDIR)/asm
CCOBJDIR = $(OBJDIR)/cc
DOCSOBJDIR = $(OBJDIR)/docs
ASSRCDIR = asm
CCSRCDIR = cc
LDSRCDIR = lds
CCGENDIR = cc-gen
INCLUDESGENDIR = includes-gen
CCGENSCRIPTSDIR = scripts/gen-cc
TMPDIR = tmp
CCGENSCRIPTS = $(shell find $(CCGENSCRIPTSDIR) -type f -name \*.sh)
GENCCSRCS = $(patsubst $(CCGENSCRIPTSDIR)/%.sh,$(CCGENDIR)/%.c,$(CCGENSCRIPTS))
GENCC64OBJS = $(patsubst $(CCGENSCRIPTSDIR)/%.sh,$(CCOBJDIR)/%.cc-gen.x86_64.o,$(CCGENSCRIPTS))
GENCC64ASMOUTS = $(patsubst $(CCGENSCRIPTSDIR)/%.sh,$(CCOBJDIR)/%.cc-gen.x86_64.s,$(CCGENSCRIPTS))
.NOTPARALLEL:
all: $(GENCC64OBJS)
asm: $(GENCC64ASMOUTS)
clean:
rm -fr $(CCGENDIR)/*
rm -f $(GENCC64OBJS)
$(CCGENDIR)/%.c: $(CCGENSCRIPTSDIR)/%.sh
if [[ ! -f $@ ]]; then $^ > $@; else $^ > $@.tmp; diff $@ $@.tmp 2>/dev/null && rm -f $@.tmp || mv $@.tmp $@; fi
$(CCOBJDIR)/%.cc-gen.x86_64.o: $(CCGENDIR)/%.c
$(CC64) $(CC64FLAGS) -o $@ $<
$(CCOBJDIR)/interrupt_handlers.cc-gen.x86_64.o: $(CCGENDIR)/interrupt_handlers.c
$(CC64) $(CC64INTFLAGS) -o $@ $<
$(CCOBJDIR)/%.cc-gen.x86_64.s: $(CCGENDIR)/%.c
$(CC64) $(CC64FLAGS) -S -o $@ $<
$(CCOBJDIR)/interrupt_handlers.cc-gen.x86_64.s: $(CCGENDIR)/interrupt_handlers.c
$(CC64) $(CC64INTFLAGS) -S -o $@ $<
print-%: ; @echo $* = $($*)