2012-10-17 13:09:16 -07:00
|
|
|
#########################################################################
|
|
|
|
# #
|
|
|
|
# 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. #
|
|
|
|
# #
|
|
|
|
#########################################################################
|
|
|
|
|
2010-01-25 05:47:28 -08:00
|
|
|
CC=$(NATIVECC) $(NATIVECCCOMPOPTS)
|
|
|
|
FC=$(FORTAN_COMPILER)
|
2010-05-04 00:46:14 -07:00
|
|
|
CMO_FILES=$(MODULES:=.cmo)
|
|
|
|
CMX_FILES=$(MODULES:=.cmx)
|
|
|
|
CMA_FILES=$(LIBRARIES:=.cma)
|
|
|
|
CMXA_FILES=$(LIBRARIES:=.cmxa)
|
2015-07-15 07:50:04 -07:00
|
|
|
O_FILES=$(F_FILES:=.o) $(C_FILES:=.o)
|
2010-05-04 03:37:53 -07:00
|
|
|
|
2013-05-03 08:52:56 -07:00
|
|
|
CUSTOM_FLAG=`if [ -n "$(C_FILES)" ]; then echo '-custom'; fi`
|
2010-05-04 03:37:53 -07:00
|
|
|
ADD_CFLAGS+=$(CUSTOM_FLAG)
|
2013-12-03 06:42:23 -08:00
|
|
|
MYRUNTIME=`if [ -z "$(C_FILES)$(CUSTOM)" ]; then echo '$(OCAMLRUN)'; fi`
|
2015-07-15 07:50:04 -07:00
|
|
|
FORTRAN_LIB=`if [ -n "$(F_FILES)" ]; then echo $(FORTRAN_LIBRARY); fi`
|
2010-05-04 03:37:53 -07:00
|
|
|
ADD_CFLAGS+=$(FORTRAN_LIB)
|
|
|
|
ADD_OPTFLAGS+=$(FORTRAN_LIB)
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2015-07-15 07:50:04 -07:00
|
|
|
C_INCLUDES+=-I $(CTOPDIR)/byterun -I$(CTOPDIR)/otherlibs/bigarray
|
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: check
|
2010-05-05 02:45:49 -07:00
|
|
|
check:
|
2013-05-03 08:52:56 -07:00
|
|
|
@if [ -n "$(FORTRAN_COMPILER)" -o -z "$(F_FILES)" ]; then \
|
2013-05-17 05:03:58 -07:00
|
|
|
$(SET_LD_PATH) $(MAKE) run-all; \
|
2013-05-03 08:52:56 -07:00
|
|
|
fi
|
2010-05-05 02:45:49 -07:00
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: run-all
|
2010-01-25 05:47:28 -08:00
|
|
|
run-all:
|
|
|
|
@for file in $(C_FILES); do \
|
2015-07-15 07:50:04 -07:00
|
|
|
$(CC) $(C_INCLUDES) -c $$file.c; \
|
2010-01-25 05:47:28 -08:00
|
|
|
done;
|
|
|
|
@for file in $(F_FILES); do \
|
2015-07-15 07:50:04 -07:00
|
|
|
$(FORTRAN_COMPILER) -c $$file.f; \
|
2010-01-25 05:47:28 -08:00
|
|
|
done;
|
|
|
|
@for file in *.ml; do \
|
2013-04-29 10:02:29 -07:00
|
|
|
if [ -f `basename $$file ml`precheck ]; then \
|
2013-05-03 08:52:56 -07:00
|
|
|
CANKILL=$(CANKILL) sh `basename $$file ml`precheck || continue; \
|
|
|
|
fi; \
|
2010-03-17 02:11:27 -07:00
|
|
|
printf " ... testing '$$file':"; \
|
2013-11-29 05:04:38 -08:00
|
|
|
$(MAKE) run-file DESC=ocamlc COMP='$(OCAMLC)' \
|
2013-05-16 08:20:48 -07:00
|
|
|
RUNTIME='$(MYRUNTIME)' \
|
2013-05-14 10:05:21 -07:00
|
|
|
COMPFLAGS='-w a $(ADD_COMPFLAGS) $(ADD_CFLAGS) $(O_FILES) \
|
|
|
|
$(CMA_FILES) -I $(OTOPDIR)/testsuite/lib \
|
|
|
|
$(CMO_FILES)' \
|
|
|
|
FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS) \
|
|
|
|
&& \
|
2013-05-14 11:34:30 -07:00
|
|
|
if $(BYTECODE_ONLY); then : ; else \
|
2013-11-29 05:04:38 -08:00
|
|
|
$(MAKE) run-file DESC=ocamlopt COMP='$(OCAMLOPT)' \
|
2013-05-16 08:20:48 -07:00
|
|
|
RUNTIME= \
|
|
|
|
COMPFLAGS='-w a $(ADD_COMPFLAGS) $(ADD_OPTFLAGS) \
|
|
|
|
$(O_FILES) $(CMXA_FILES) \
|
|
|
|
-I $(OTOPDIR)/testsuite/lib $(CMX_FILES)' \
|
2013-05-14 10:05:21 -07:00
|
|
|
FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS); \
|
|
|
|
fi \
|
|
|
|
&& \
|
|
|
|
if [ -n "$(UNSAFE)" ]; then \
|
2013-11-29 05:04:38 -08:00
|
|
|
$(MAKE) run-file DESC=ocamlc-unsafe COMP='$(OCAMLC)' \
|
2013-05-16 08:20:48 -07:00
|
|
|
RUNTIME='$(MYRUNTIME)' \
|
2013-05-14 10:05:21 -07:00
|
|
|
COMPFLAGS='-w a -unsafe $(ADD_COMPFLAGS) $(ADD_CFLAGS) \
|
|
|
|
$(O_FILES) $(CMA_FILES) \
|
|
|
|
-I $(OTOPDIR)/testsuite/lib $(CMO_FILES)' \
|
|
|
|
FILE=$$file \
|
|
|
|
&& \
|
2013-05-14 11:34:30 -07:00
|
|
|
if $(BYTECODE_ONLY); then : ; else \
|
2013-11-29 05:04:38 -08:00
|
|
|
$(MAKE) run-file DESC=ocamlopt-unsafe COMP='$(OCAMLOPT)' \
|
2013-05-16 08:20:48 -07:00
|
|
|
RUNTIME= \
|
|
|
|
COMPFLAGS='-w a -unsafe $(ADD_COMPFLAGS) $(ADD_OPTFLAGS)\
|
|
|
|
$(O_FILES) $(CMXA_FILES) \
|
|
|
|
-I $(OTOPDIR)/testsuite/lib $(CMX_FILES)' \
|
2013-05-14 10:05:21 -07:00
|
|
|
FILE=$$file; \
|
2013-05-03 08:52:56 -07:00
|
|
|
fi; \
|
|
|
|
fi \
|
|
|
|
&& echo " => passed" || echo " => failed"; \
|
|
|
|
done
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: run-file
|
2010-01-25 05:47:28 -08:00
|
|
|
run-file:
|
2010-03-17 02:11:27 -07:00
|
|
|
@printf " $(DESC)"
|
2012-07-27 04:31:21 -07:00
|
|
|
@rm -f program program.exe
|
2013-04-29 10:02:29 -07:00
|
|
|
@$(COMP) $(COMPFLAGS) $(FILE) -o program$(EXE)
|
2013-05-03 08:52:56 -07:00
|
|
|
@F="`basename $(FILE) .ml`"; \
|
|
|
|
if [ -f $$F.runner ]; then \
|
2013-05-16 08:20:48 -07:00
|
|
|
RUNTIME="$(RUNTIME)" sh $$F.runner; \
|
2010-01-28 07:42:08 -08:00
|
|
|
else \
|
2013-05-16 08:20:48 -07:00
|
|
|
$(RUNTIME) ./program$(EXE) $(PROGRAM_ARGS) >$$F.result; \
|
2013-05-03 08:52:56 -07:00
|
|
|
fi \
|
|
|
|
&& \
|
|
|
|
if [ -f $$F.checker ]; then \
|
2013-05-07 02:39:38 -07:00
|
|
|
DIFF="$(DIFF)" SORT="$(SORT)" sh $$F.checker; \
|
2010-01-28 07:42:08 -08:00
|
|
|
else \
|
2013-05-03 08:52:56 -07:00
|
|
|
$(DIFF) $$F.reference $$F.result >/dev/null; \
|
|
|
|
fi
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: promote
|
2011-06-15 05:14:14 -07:00
|
|
|
promote: defaultpromote
|
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: clean
|
2010-01-25 05:47:28 -08:00
|
|
|
clean: defaultclean
|
2013-04-29 10:02:29 -07:00
|
|
|
@rm -f *.result program program.exe
|