1#**************************************************************************
2#*                                                                        *
3#*                                OCaml                                   *
4#*                                                                        *
5#*            Damien Doligez, EPI Gallium, INRIA Rocquencourt             *
6#*                                                                        *
7#*   Copyright 2013 Institut National de Recherche en Informatique et     *
8#*     en Automatique.                                                    *
9#*                                                                        *
10#*   All rights reserved.  This file is distributed under the terms of    *
11#*   the GNU Lesser General Public License version 2.1, with the          *
12#*   special exception on linking described in the file LICENSE.          *
13#*                                                                        *
14#**************************************************************************
15
16BASEDIR=../../..
17ADD_COMPFLAGS=-g -custom
18LD_PATH=$(TOPDIR)/otherlibs/$(UNIXLIBVAR)unix
19
20.PHONY: default
21default:
22	@if ! $(SUPPORTS_SHARED_LIBRARIES); then \
23	  echo 'skipped (shared libraries not available)'; \
24	else \
25	  $(MAKE) compile; \
26	  $(SET_LD_PATH) OCAMLLIB=. $(MAKE) run; \
27	fi
28
29.PHONY: compile
30compile: $(ML_FILES) $(CMO_FILES)
31	@rm -f c$(EXE)
32	@$(OCAMLC) $(ADD_COMPFLAGS) -c a.ml -for-pack foo
33	@$(OCAMLC) $(ADD_COMPFLAGS) a.cmo -pack -o foo.cmo
34	@$(OCAMLC) $(ADD_COMPFLAGS) -c b.ml
35	@$(OCAMLC) $(ADD_COMPFLAGS) foo.cmo b.cmo -o c$(EXE)
36	@mkdir -p compiler-libs
37	@cp $(TOPDIR)/toplevel/topdirs.cmi compiler-libs/
38
39.PHONY: run
40run:
41	@printf " ... testing with ocamlc"
42	@rm -f noev.result
43	@echo 'source input_script' | \
44	 $(OCAMLRUN) `$(CYGPATH) $(TOPDIR)/debugger/ocamldebug$(EXE)` \
45	             c$(EXE) >noev.raw.result 2>&1 \
46	 && sed -e '/Debugger version/d' -e '/^Time:/d' \
47	        -e '/Breakpoint [0-9]* at [0-9]*:/d' -e '$$d' \
48	        noev.raw.result >noev.result \
49	 && $(DIFF) noev.reference noev.result >/dev/null \
50	 && echo " => passed" || echo " => failed"
51
52.PHONY: promote
53promote: defaultpromote
54
55.PHONY: clean
56clean: defaultclean
57	@rm -f *.result *.cm* c$(EXE)
58	@rm -rf compiler-libs
59
60include $(BASEDIR)/makefiles/Makefile.common
61