-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (102 loc) · 3.5 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
.POSIX:
all:
include config.mk
include makefiles/$(PLATFORM).$(ARCH).mk
all: $(BINOUT)/hare $(BINOUT)/haredoc docs
HARE_DEFINES = \
-D PLATFORM:str='"$(PLATFORM)"' \
-D ARCH:str='"$(ARCH)"' \
-D VERSION:str="\"$(VERSION)\"" \
-D HAREPATH:str='"$(HAREPATH)"' \
-D AARCH64_AS:str='"$(AARCH64_AS)"' \
-D AARCH64_CC:str='"$(AARCH64_CC)"' \
-D AARCH64_LD:str='"$(AARCH64_LD)"' \
-D RISCV64_AS:str='"$(RISCV64_AS)"' \
-D RISCV64_CC:str='"$(RISCV64_CC)"' \
-D RISCV64_LD:str='"$(RISCV64_LD)"' \
-D X86_64_AS:str='"$(X86_64_AS)"' \
-D X86_64_CC:str='"$(X86_64_CC)"' \
-D X86_64_LD:str='"$(X86_64_LD)"'
.SUFFIXES:
.SUFFIXES: .ha .ssa .td .s .o .scd
.ssa.td:
@cmp -s '$@' '$@.tmp' 2>/dev/null || cp '$@.tmp' '$@'
.ssa.s:
@printf 'QBE\t%s\n' '$@'
@$(QBE) $(QBEFLAGS) -o '$@' '$<'
.s.o:
@printf 'AS\t%s\n' '$@'
@$(AS) $(ASFLAGS) -o '$@' '$<'
.scd:
@printf 'SCDOC\t%s\n' '$@'
@$(SCDOC) < '$<' > '$@'
$(BINOUT)/hare: $(OBJS)
@mkdir -p -- "$(BINOUT)"
@printf 'LD\t%s\n' "$@"
@$(LD) $(LDLINKFLAGS) -T $(RTSCRIPT) -o $@ $(OBJS)
HARE_BUILD_ENV = HAREPATH=. HAREC="$(HAREC)" QBE="$(QBE)" AS="$(AS)" \
LD="$(LD)" HAREFLAGS="$(HAREFLAGS)" HARECFLAGS="$(HARECFLAGS)" \
QBEFLAGS="$(QBEFLAGS)" ASFLAGS="$(ASFLAGS)" LDLINKFLAGS="$(LDLINKFLAGS)"
$(BINOUT)/harec2: $(BINOUT)/hare
@printf 'HARE\t%s\n' "$@"
@env $(HARE_BUILD_ENV) \
$(BINOUT)/hare build $(HARE_DEFINES) -o $(BINOUT)/harec2 cmd/harec
$(BINOUT)/haredoc: $(BINOUT)/hare
@mkdir -p $(BINOUT)
@printf 'HARE\t%s\n' "$@"
@env $(HARE_BUILD_ENV) \
$(BINOUT)/hare build $(HARE_DEFINES) -o $(BINOUT)/haredoc ./cmd/haredoc
docs/html: $(BINOUT)/haredoc
mkdir -p docs/html
$(BINOUT)/haredoc -Fhtml > docs/html/index.html
for d in $$(scripts/moddirs); do \
find $$d -type d | sed -E '/(\+|-)/d'; \
done \
| while read path; do \
mod=$$(echo $$path | sed -E 's@/@::@g'); \
echo $$mod; \
mkdir -p docs/html/$$path; \
$(BINOUT)/haredoc -Fhtml $$mod > docs/html/$$path/index.html; \
done
docs: \
docs/hare.1 \
docs/hare-build.1 \
docs/hare-cache.1 \
docs/hare-deps.1 \
docs/haredoc.1 \
docs/hare-run.1 \
docs/hare-test.1 \
docs/haredoc.5 \
docs/hare-module.5
MAN1 = hare hare-build hare-cache hare-deps haredoc hare-run hare-test
MAN5 = haredoc hare-module
bootstrap:
@BINOUT=$(BINOUT) ./scripts/genbootstrap
clean:
rm -rf -- '$(HARECACHE)' '$(BINOUT)' docs/*.1 docs/*.5 docs/html
check: $(BINOUT)/hare
@env HAREPATH=. HAREC='$(HAREC)' QBE='$(QBE)' AS='$(AS)' LD='$(LD)' \
HAREFLAGS='$(HAREFLAGS)' HARECFLAGS='$(HARECFLAGS)' \
QBEFLAGS='$(QBEFLAGS)' ASFLAGS='$(ASFLAGS)' \
LDLINKFLAGS='$(LDLINKFLAGS)' '$(BINOUT)/hare' test
install: install-cmd install-mods
install-cmd:
mkdir -p -- \
'$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1' \
'$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man5'
install -m755 '$(BINOUT)/hare' '$(DESTDIR)$(BINDIR)/hare'
install -m755 '$(BINOUT)/haredoc' '$(DESTDIR)$(BINDIR)/haredoc'
for i in $(MAN1); do install -m644 docs/$$i.1 '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done
for i in $(MAN5); do install -m644 docs/$$i.5 '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done
install-mods:
rm -rf -- '$(DESTDIR)$(STDLIB)'
mkdir -p -- '$(DESTDIR)$(STDLIB)'
cp -R -- $$(scripts/moddirs) '$(DESTDIR)$(STDLIB)'
uninstall:
rm -- '$(DESTDIR)$(BINDIR)/hare'
rm -- '$(DESTDIR)$(BINDIR)/haredoc'
for i in $(MAN1); do rm -- '$(DESTDIR)$(MANDIR)'/man1/$$i.1; done
for i in $(MAN5); do rm -- '$(DESTDIR)$(MANDIR)'/man5/$$i.5; done
rm -r -- '$(DESTDIR)$(STDLIB)'
.PHONY: all $(BINOUT)/harec2 $(BINOUT)/haredoc bootstrap clean check docs \
docs/html install start uninstall