######################################################################### # # # OCaml # # # # Xavier Clerc, SED, INRIA Rocquencourt # # # # Copyright 2010 Institut National de Recherche en Informatique et # # en Automatique. All rights reserved. This file is distributed # # under the terms of the Q Public License version 1.0. # # # ######################################################################### CC=$(NATIVECC) $(NATIVECCCOMPOPTS) FC=$(FORTAN_COMPILER) CMO_FILES=$(MODULES:=.cmo) CMX_FILES=$(MODULES:=.cmx) CMA_FILES=$(LIBRARIES:=.cma) CMXA_FILES=$(LIBRARIES:=.cmxa) O_FILES=$(C_FILES:=.o) CUSTOM_FLAG=`if [ -n "$(C_FILES)" ]; then echo '-custom'; fi` ADD_CFLAGS+=$(CUSTOM_FLAG) MYRUNTIME=`if [ -z "$(C_FILES)$(CUSTOM)" ]; then echo '$(OCAMLRUN)'; fi` FORTRAN_LIB=`if [ -n "$(F_FILES)" ]; then echo '$(FORTRAN_LIBRARY)'; fi` ADD_CFLAGS+=$(FORTRAN_LIB) ADD_OPTFLAGS+=$(FORTRAN_LIB) .PHONY: check check: @if [ -n "$(FORTRAN_COMPILER)" -o -z "$(F_FILES)" ]; then \ $(SET_LD_PATH) $(MAKE) run-all; \ fi .PHONY: run-all run-all: @for file in $(C_FILES); do \ $(CC) -c -I$(PREFIX)/lib/ocaml/caml $$file.c; \ done; @for file in $(F_FILES); do \ $(FORTRAN_COMPILER) -c -I$(PREFIX)/lib/ocaml/caml $$file.f; \ done; @for file in *.ml; do \ if [ -f `basename $$file ml`precheck ]; then \ CANKILL=$(CANKILL) sh `basename $$file ml`precheck || continue; \ fi; \ printf " ... testing '$$file':"; \ $(MAKE) run-file DESC=ocamlc COMP='$(OCAMLC)' \ RUNTIME='$(MYRUNTIME)' \ COMPFLAGS='-w a $(ADD_COMPFLAGS) $(ADD_CFLAGS) $(O_FILES) \ $(CMA_FILES) -I $(OTOPDIR)/testsuite/lib \ $(CMO_FILES)' \ FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS) \ && \ if $(BYTECODE_ONLY); then : ; else \ $(MAKE) run-file DESC=ocamlopt COMP='$(OCAMLOPT)' \ RUNTIME= \ COMPFLAGS='-w a $(ADD_COMPFLAGS) $(ADD_OPTFLAGS) \ $(O_FILES) $(CMXA_FILES) \ -I $(OTOPDIR)/testsuite/lib $(CMX_FILES)' \ FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS); \ fi \ && \ if [ -n "$(UNSAFE)" ]; then \ $(MAKE) run-file DESC=ocamlc-unsafe COMP='$(OCAMLC)' \ RUNTIME='$(MYRUNTIME)' \ COMPFLAGS='-w a -unsafe $(ADD_COMPFLAGS) $(ADD_CFLAGS) \ $(O_FILES) $(CMA_FILES) \ -I $(OTOPDIR)/testsuite/lib $(CMO_FILES)' \ FILE=$$file \ && \ if $(BYTECODE_ONLY); then : ; else \ $(MAKE) run-file DESC=ocamlopt-unsafe COMP='$(OCAMLOPT)' \ RUNTIME= \ COMPFLAGS='-w a -unsafe $(ADD_COMPFLAGS) $(ADD_OPTFLAGS)\ $(O_FILES) $(CMXA_FILES) \ -I $(OTOPDIR)/testsuite/lib $(CMX_FILES)' \ FILE=$$file; \ fi; \ fi \ && echo " => passed" || echo " => failed"; \ done .PHONY: run-file run-file: @printf " $(DESC)" @rm -f program program.exe @$(COMP) $(COMPFLAGS) $(FILE) -o program$(EXE) @F="`basename $(FILE) .ml`"; \ if [ -f $$F.runner ]; then \ RUNTIME="$(RUNTIME)" sh $$F.runner; \ else \ $(RUNTIME) ./program$(EXE) $(PROGRAM_ARGS) >$$F.result; \ fi \ && \ if [ -f $$F.checker ]; then \ DIFF="$(DIFF)" SORT="$(SORT)" sh $$F.checker; \ else \ $(DIFF) $$F.reference $$F.result >/dev/null; \ fi .PHONY: promote promote: defaultpromote .PHONY: clean clean: defaultclean @rm -f *.result program program.exe