summaryrefslogtreecommitdiff
path: root/arm/Makefile
blob: 18eba3931a69b13d1e0a7242acdfbb8f38b1ba3c (plain)
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
BUILDDIR=./build

SAIL=../sail
ifeq ("$(wildcard $(SAIL))","")
  $(warning can not find Sail)
endif

LEM=../../lem/lem
ifeq ("$(wildcard $(LEM))","")
  $(warning can not find Lem)
endif

LEMINTERPDIR=../src/lem_interp/

# the order of the files is important
SOURCES=armV8.h.sail\
  armV8_A64_sys_regs.sail\
  armV8_A64_special_purpose_regs.sail\
  armV8_A32_sys_regs.sail\
  armV8_pstate.sail\
  armV8_lib.h.sail\
  armV8_common_lib.sail\
  armV8_A64_lib.sail\
  armV8.sail

all: $(BUILDDIR)/armv8.ml

clean:
	rm -rf $(BUILDDIR)

ocaml: $(BUILDDIR)/armv8_embed.ml

.PHONY: all clean ocaml

$(BUILDDIR):
	mkdir -p $@

$(BUILDDIR)/armv8.lem: $(SOURCES) | $(BUILDDIR)
	$(SAIL) -lem_ast $(SOURCES) -o $(basename $@)
#	sail generates the .lem file in pwd
	mv $(notdir $@) $@

$(BUILDDIR)/armv8.ml: $(BUILDDIR)/armv8.lem
	$(LEM) -ocaml -lib $(LEMINTERPDIR) $<

$(BUILDDIR)/armv8_embed.ml: $(SOURCES) | $(BUILDDIR)
	$(SAIL) -ocaml $(SOURCES) -o $(basename $@)
#	sail generates the .lem file in pwd
	mv $(notdir $@) $@


######################################################################
ETCDIR=../etc

apply_header:
	-chmod u+w *.sail
	headache -c $(ETCDIR)/headache_config -h $(ETCDIR)/arm_header *.sail
	chmod a-w *.sail

.PHONY: apply_header

######################################################################
IDLARM=../../../rsem/idlarm

pull_from_idlarm:
	svn up $(IDLARM)
	$(MAKE) -C $(IDLARM)
	-chmod u+w *.sail
	rm -f *.sail
	cp -a $(IDLARM)/build/*.sail ./
	chmod a-w *.sail
	$(MAKE) apply_header