37 lines
1.5 KiB
Makefile
37 lines
1.5 KiB
Makefile
# $Id$
|
|
|
|
CMI_FILES=$(patsubst %,%.cmi,$(MODULES))
|
|
CMO_FILES=$(patsubst %,%.cmo,$(MODULES))
|
|
CMX_FILES=$(patsubst %,%.cmx,$(MODULES))
|
|
CMA_FILES=$(patsubst %,%.cma,$(LIBRARIES))
|
|
CMXA_FILES=$(patsubst %,%.cmxa,$(LIBRARIES))
|
|
ML_FILES=$(patsubst %,%.ml,$(LEX_MODULES) $(YACC_MODULES))
|
|
O_FILES=$(patsubst %,%.$(O),$(C_FILES))
|
|
|
|
GENERATED_SOURCES=$(patsubst %,%.ml,$(LEX_MODULES)) $(patsubst %,%.ml,$(YACC_MODULES)) $(patsubst %,%.mli,$(YACC_MODULES))
|
|
|
|
ifdef C_FILES
|
|
ADD_CFLAGS+=-custom
|
|
endif
|
|
|
|
default: compile run
|
|
|
|
compile: $(ML_FILES) $(CMO_FILES) $(CMX_FILES) $(MAIN_MODULE).cmo $(MAIN_MODULE).cmx
|
|
@for file in $(C_FILES); do \
|
|
$(NATIVECC) $(NATIVECCCOMPOPTS) -c -I$(TOPDIR)/byterun $$file.c; \
|
|
done;
|
|
@$(OCAMLC) $(ADD_COMPFLAGS) $(ADD_CFLAGS) -o program.byte $(O_FILES) $(CMA_FILES) $(CMO_FILES) $(patsubst %,%.cmo,$(ADD_MODULES)) $(MAIN_MODULE).cmo
|
|
@$(OCAMLOPT) $(ADD_COMPFLAGS) -o program.native $(O_FILES) $(CMXA_FILES) $(CMX_FILES) $(patsubst %,%.cmx,$(ADD_MODULES)) $(MAIN_MODULE).cmx
|
|
|
|
run:
|
|
@echo -n " ... testing with ocamlc"
|
|
@./program.byte $(EXEC_ARGS) > $(MAIN_MODULE).result || (echo " => failed" && exit 1)
|
|
@diff -q $(MAIN_MODULE).reference $(MAIN_MODULE).result > /dev/null || (echo " => failed" && exit 1)
|
|
@echo -n " ocamlopt"
|
|
@./program.native $(EXEC_ARGS) > $(MAIN_MODULE).result || (echo " => failed" && exit 1)
|
|
@diff -q $(MAIN_MODULE).reference $(MAIN_MODULE).result > /dev/null || (echo " => failed" && exit 1)
|
|
@echo " => passed"
|
|
|
|
clean: defaultclean
|
|
@rm -f *.result ./program.* $(GENERATED_SOURCES) $(O_FILES)
|