-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
83 lines (64 loc) · 1.67 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
######################################################
COURSE=cs131f
ORG=ucsd-cse131-fa18
ASGN=03
COMPILER=cobra
EXT=cobra
######################################################
COMPILEREXEC=stack exec -- $(COMPILER)
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
FORMAT=aout
else
ifeq ($(UNAME), Darwin)
FORMAT=macho
else
ifeq ($(UNAME), CYGWIN_NT-10.0)
FORMAT=win
WINSTUFF=-target i686-pc-mingw32
endif
endif
endif
.PHONY: test bin build clean distclean turnin \
$(ASMS) $(OBJS) $(RUNS) $(RESULTS)
test: clean
stack test
bin:
stack install
build:
stack build
tests/output/%.result: tests/output/%.run FORCE
$< > $@
tests/output/%.run: tests/output/%.o c-bits/main.c FORCE
clang $(WINSTUFF) -g -m32 -mstackrealign -o $@ c-bits/main.c $<
tests/output/%.o: tests/output/%.s FORCE
nasm -f $(FORMAT) -o $@ $<
tests/output/%.s: tests/input/%.$(EXT) FORCE
$(COMPILEREXEC) $< > $@
clean:
rm -rf tests/output/*.o tests/output/*.s tests/output/*.dSYM tests/output/*.run tests/output/*.log tests/output/*.result
distclean: clean
stack clean
rm -rf .stack-work
tags:
hasktags -x -c lib/
turnin:
git commit -a -m "turnin"
git push origin master
upstream:
git remote add upstream [email protected]:$(ORG)/$(ASGN)-$(COMPILER).git
update:
git pull upstream master
# aliases
INPUTS := $(patsubst tests/input/%.$(EXT),%,$(wildcard tests/input/*.$(EXT)))
ASMS := $(patsubst %,%-s,$(INPUTS))
OBJS := $(patsubst %,%-o,$(INPUTS))
RUNS := $(patsubst %,%-run,$(INPUTS))
RESULTS := $(patsubst %,%-result,$(INPUTS))
$(ASMS): %-s: tests/output/%.s
cat $<
$(OBJS): %-o: tests/output/%.o
$(RUNS): %-run: tests/output/%.run
$(RESULTS): %-result: tests/output/%.result
cat $<
FORCE: