######################################################################### # # # 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 [ -z "$(C_FILES)" ]; then true; else echo '-custom'; fi` ADD_CFLAGS+=$(CUSTOM_FLAG) FORTRAN_LIB=`if [ -z "$(F_FILES)" ]; then true; else echo '$(FORTRAN_LIBRARY)'; fi` ADD_CFLAGS+=$(FORTRAN_LIB) ADD_OPTFLAGS+=$(FORTRAN_LIB) check: @if [ -n "$(FORTRAN_COMPILER)" -o -z "$(F_FILES)" ]; then $(MAKE) run-all; fi 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)' COMPFLAGS='$(ADD_COMPFLAGS) $(ADD_CFLAGS) $(O_FILES) -w a $(CMA_FILES) -I $(TTOP)/testsuite/lib $(CMO_FILES)' FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS) && \ if [ -z "$(BYTECODE_ONLY)" ]; then \ $(MAKE) run-file DESC=ocamlopt COMP='$(OCAMLOPT)' COMPFLAGS='$(ADD_COMPFLAGS) $(ADD_OPTFLAGS) $(O_FILES) -w a $(CMXA_FILES) -I $(TTOP)/testsuite/lib $(CMX_FILES)' FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS); \ fi && \ if [ ! -z $(UNSAFE) ]; then \ $(MAKE) run-file DESC=ocamlc-unsafe COMP='$(OCAMLC)' COMPFLAGS='-w a -unsafe -I $(TTOP)/testsuite/lib $(CMO_FILES)' FILE=$$file && \ if [ -z "$(BYTECODE_ONLY)" ]; then \ $(MAKE) run-file DESC=ocamlopt-unsafe COMP='$(OCAMLOPT)' COMPFLAGS='-w a -unsafe -I $(TTOP)/testsuite/lib $(CMX_FILES)' FILE=$$file; \ fi; \ fi && \ echo " => passed"; \ done; run-file: @printf " $(DESC)" @rm -f program program.exe @$(COMP) $(COMPFLAGS) $(FILE) -o program$(EXE) @if [ -f `basename $(FILE) ml`runner ]; then \ sh `basename $(FILE) ml`runner; \ else \ ./program$(EXE) $(PROGRAM_ARGS) > `basename $(FILE) ml`result; \ fi || (echo " => failed" && exit 1) @if [ -f `basename $(FILE) ml`checker ]; then \ DIFF="$(DIFF)" sh `basename $(FILE) ml`checker; \ else \ $(DIFF) `basename $(FILE) ml`reference `basename $(FILE) ml`result > /dev/null; \ fi || (echo " => failed" && exit 1) promote: defaultpromote clean: defaultclean @rm -f *.result program program.exe