ocaml/testsuite/makefiles/Makefile.one

61 lines
2.6 KiB
Makefile

#########################################################################
# #
# 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. #
# #
#########################################################################
CMI_FILES=$(MODULES:=.cmi)
CMO_FILES=$(MODULES:=.cmo)
CMX_FILES=$(MODULES:=.cmx)
CMA_FILES=$(LIBRARIES:=.cma)
CMXA_FILES=$(LIBRARIES:=.cmxa)
ML_LEX_FILES=$(LEX_MODULES:=.ml)
ML_YACC_FILES=$(YACC_MODULES:=.ml)
MLI_YACC_FILES=$(YACC_MODULES:=.mli)
ML_FILES=$(ML_LEX_FILES) $(ML_YACC_FILES)
O_FILES=$(C_FILES:=.o)
ADD_CMO_FILES=$(ADD_MODULES:=.cmo)
ADD_CMX_FILES=$(ADD_MODULES:=.cmx)
GENERATED_SOURCES=$(ML_LEX_FILES) $(ML_YACC_FILES) $(MLI_YACC_FILES)
CUSTOM_FLAG=`if [ -z "$(C_FILES)" ]; then true; else echo '-custom'; fi`
ADD_CFLAGS+=$(CUSTOM_FLAG)
default: compile run
compile: $(ML_FILES) $(CMO_FILES) $(MAIN_MODULE).cmo
@for file in $(C_FILES); do \
$(NATIVECC) $(NATIVECCCOMPOPTS) -c -I$(TOPDIR)/byterun $$file.c; \
done;
@rm -f program.byte program.byte.exe
@$(OCAMLC) $(ADD_COMPFLAGS) $(ADD_CFLAGS) -o program.byte $(O_FILES) $(CMA_FILES) $(CMO_FILES) $(ADD_CMO_FILES) $(MAIN_MODULE).cmo
@if [ -z "$(BYTECODE_ONLY)" ]; then \
rm -f program.native program.native.exe; \
$(MAKE) $(CMX_FILES) $(MAIN_MODULE).cmx; \
$(OCAMLOPT) $(ADD_COMPFLAGS) -o program.native $(O_FILES) $(CMXA_FILES) $(CMX_FILES) $(ADD_CMX_FILES) $(MAIN_MODULE).cmx; \
fi
run:
@printf " ... testing with ocamlc"
@./program.byte $(EXEC_ARGS) > $(MAIN_MODULE).result || (echo " => failed" && exit 1)
@$(DIFF) $(MAIN_MODULE).reference $(MAIN_MODULE).result > /dev/null || (echo " => failed" && exit 1)
@if [ -z "$(BYTECODE_ONLY)" ]; then \
printf " ocamlopt"; \
./program.native $(EXEC_ARGS) > $(MAIN_MODULE).result || (echo " => failed" && exit 1); \
$(DIFF) $(MAIN_MODULE).reference $(MAIN_MODULE).result > /dev/null || (echo " => failed" && exit 1); \
fi
@echo " => passed"
promote: defaultpromote
clean: defaultclean
@rm -f *.result ./program.* $(GENERATED_SOURCES) $(O_FILES) \
$(TEST_TEMP_FILES)