forked from keyz/p423-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (65 loc) · 2.13 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
#----------------------------------------------------------------------
# File Makefile
# Written by Chris Frisz
#
# Created 10 Jan 2012
#
# This Makefile is intended for use with CSCI-P423 and runs the the
# load_and_test.ss file. It may be extended to do other things as you
# may need.
#----------------------------------------------------------------------
#-- Variables --#
SC=$(shell which scheme 2> /dev/null)
ifeq ($(SC),)
SC=petite
endif
HS=ghc
# HS_FLAGS=-v0
HS_FLAGS=
SCRIPT_DIR=scripts
SC_FILE=load_and_test.ss
HS_FILE=LoadAndTest.hs
CG_FILE=compile_grammars.ss
SRC_GRAMMAR=source-grammar.ss
HS_EXE=$(HS_FILE:.hs=.exe)
#-- Rules --#
# The main point of this file is to run the tests
all : grammars
grammars : Framework/GenGrammars
Framework/GenGrammars: $(SRC_GRAMMAR) GrammarCompiler
@mkdir -p Framework/GenGrammars
@mkdir -p FrameworkHs/GenGrammars
$(SC) --script $(SCRIPT_DIR)/$(CG_FILE) "$(SRC_GRAMMAR)"
scheme : grammars
$(SC) $(SCRIPT_DIR)/$(SC_FILE)
scheme-test:
echo '(import (Framework testing)) (exit (if (test-all) 0 1))' | scheme
scheme-xml:
@echo '(begin (import (Framework testing)) (exit (if (test-all-xml) 0 1)))' | $(SC) -q
# Run the tests straight away:
haskell: haskell-test
haskell-test: grammars build-haskell
./$(HS_EXE)
build-haskell:
$(HS) --make -o $(HS_EXE) $(HS_FLAGS) $(SCRIPT_DIR)/$(HS_FILE)
# Load up the compiler interactively so as to run the tests:
haskell-interactive : grammars
$(HS) --interactive $(HS_FLAGS) $(SCRIPT_DIR)/$(HS_FILE)
# Test both backends:
test:
$(MAKE) clean
$(MAKE) grammars
# RRN: This cannot be interactive and needs to get the exit code right:
$(MAKE) scheme-test
# RRN: It can be faster to run interpreted rather than compile:
# (But I'm having problems with that on SOIC machines.)
# runghc $(SCRIPT_DIR)/$(HS_FILE)
$(MAKE) haskell
clean :
rm -f t.s t $(HS_EXE)
rm -rf Framework{,Hs}/GenGrammars
find FrameworkHs -name "*.o" -exec rm -f {} \;
find FrameworkHs -name "*.hi" -exec rm -f {} \;
find CompilerHs -name "*.o" -exec rm -f {} \;
find CompilerHs -name "*.hi" -exec rm -f {} \;
.PHONY: scheme haskell grammars clean test test-scheme test-haskell