1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Jeremie Dimino, Jane Street Europe *
6 #* *
7 #* Copyright 2016 Jane Street Group LLC *
8 #* *
9 #* All rights reserved. This file is distributed under the terms of *
10 #* the GNU Lesser General Public License version 2.1, with the *
11 #* special exception on linking described in the file LICENSE. *
12 #* *
13 #**************************************************************************
14
15 TOPDIR = ../..
16
17 COMPILERLIBSDIR = $(TOPDIR)/compilerlibs
18
19 RUNTIME_VARIANT ?=
20 ASPPFLAGS ?=
21
22 include $(TOPDIR)/Makefile.tools
23
24 expect_MAIN=expect_test
25 expect_PROG=$(expect_MAIN)$(EXE)
26 expect_DIRS = parsing utils driver typing toplevel
27 expect_OCAMLFLAGS = $(addprefix -I $(TOPDIR)/,$(expect_DIRS))
28 expect_LIBS := $(addprefix $(COMPILERLIBSDIR)/,\
29 ocamlcommon ocamlbytecomp ocamltoplevel)
30
31 codegen_PROG = codegen$(EXE)
32 codegen_DIRS = parsing utils typing middle_end bytecomp lambda asmcomp
33 codegen_OCAMLFLAGS = $(addprefix -I $(TOPDIR)/, $(codegen_DIRS)) -w +40 -g
34
35 codegen_LIBS = $(addprefix $(COMPILERLIBSDIR)/,\
36 ocamlcommon ocamloptcomp)
37
38 codegen_OBJECTS = $(addsuffix .cmo,\
39 parsecmmaux parsecmm lexcmm codegen_main)
40
41 tools := $(expect_PROG)
42
43 ifeq "$(NATIVE_COMPILER)" "true"
44 tools += $(codegen_PROG)
45 ifneq "$(CCOMPTYPE)-$(ARCH)" "msvc-amd64"
46 # The asmgen tests are not ported to MSVC64 yet
47 # so do not compile any arch-specific module
48 tools += asmgen_$(ARCH).$(O)
49 endif
50 endif
51
52 all: $(tools)
53
54 $(expect_PROG): $(expect_LIBS:=.cma) $(expect_MAIN).cmo
55 $(OCAMLC) -linkall -o $@ $^
56
57 $(expect_PROG): COMPFLAGS = $(expect_OCAMLFLAGS)
58
59 $(codegen_PROG): COMPFLAGS = $(codegen_OCAMLFLAGS)
60
61 codegen_main.cmo: parsecmm.cmo
62
63 $(codegen_PROG): $(codegen_OBJECTS)
64 $(OCAMLC) -o $@ $(codegen_LIBS:=.cma) $^
65
66 parsecmm.mli parsecmm.ml: parsecmm.mly
67 $(OCAMLYACC) -q parsecmm.mly
68
69 lexcmm.ml: lexcmm.mll
70 $(OCAMLLEX) -q lexcmm.mll
71
72 parsecmmaux.cmo: parsecmmaux.cmi
73
74 lexcmm.cmo: lexcmm.cmi
75
76 parsecmm.cmo: parsecmm.cmi
77
78 asmgen_i386.obj: asmgen_i386nt.asm
79 @set -o pipefail ; \
80 $(ASM) $@ $^ | tail -n +2
81
82 %.cmi: %.mli
83 $(OCAMLC) -c $<
84
85 %.cmo: %.ml
86 $(OCAMLC) -c $<
87
88 %.cmx: %.ml
89 $(OCAMLOPT) -c $<
90
91 %.$(O): %.S
92 $(ASPP) $(ASPPFLAGS) -DSYS_$(SYSTEM) -DMODEL_$(MODEL) -o $@ $<
93
94 .PHONY: clean
95 clean:
96 rm -f *.cm* *.$(O)
97 rm -f $(tools)
98 rm -f parsecmm.ml parsecmm.mli lexcmm.ml
99