1#######################################################################
2# Makefile for ocaml test-suite
3#######################################################################
4
5LANGUAGE     = ocaml
6OCAMLP4WHERE =`$(COMPILETOOL) @CAMLP4@ -where`
7OCC          =$(COMPILETOOL) @OCAMLC@
8OCAMLPP      = -pp "camlp4o ./swigp4.cmo"
9VARIANT      = _static
10SCRIPTSUFFIX = _runme.ml
11
12srcdir       = @srcdir@
13top_srcdir   = @top_srcdir@
14top_builddir = @top_builddir@
15
16FAILING_CPP_TESTS = \
17allprotected \
18apply_signed_char \
19apply_strings \
20cpp_enum \
21default_constructor \
22director_binary_string \
23director_enum \
24director_primitives \
25director_redefined \
26director_string \
27enum_thorough \
28li_windows \
29member_pointer_const \
30preproc_constants \
31smart_pointer_inherit \
32
33FAILING_C_TESTS = \
34enums \
35preproc_constants_c \
36
37CPP_TEST_CASES += \
38	inout \
39
40C_TEST_CASES += \
41	multivalue \
42
43ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
44
45run_testcase = \
46	if [ -f $(srcdir)/$(ml_runme) ]; then \
47		if [ $(srcdir) != . ]; then \
48			cp $(srcdir)/$(ml_runme) $(ml_runme); \
49		fi ; \
50		$(OCC) $(OCAMLPP) -c $(ml_runme) && \
51		if [ -f $(top_srcdir)/Examples/test-suite/$*.list ]; then \
52			$(OCC) swig.cmo -custom -g -cc '$(CXX)' -o $*_runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./$*_runme; \
53		else \
54			$(OCC) swig.cmo -custom -g -cc '$(CXX)' -o $*_runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && $(RUNTOOL) ./$*_runme; \
55		fi ; \
56	fi ;
57
58include $(srcdir)/../common.mk
59
60# Overridden variables here
61SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
62
63# Custom tests - tests with additional commandline options
64# none!
65
66# Rules for the different types of tests
67%.cpptest:
68	$(setup)
69	+$(swig_and_compile_cpp)
70	$(run_testcase)
71
72%.ctest:
73	$(setup)
74	+$(swig_and_compile_c)
75	$(run_testcase)
76
77%.multicpptest:
78	+$(swig_and_compile_multi_cpp)
79	$(setup)
80	$(run_testcase)
81
82swig.cmi:
83	env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swig.mli
84	$(OCC) -c swig.mli
85swig.cmo:
86	env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swig.ml
87	$(OCC) -c swig.ml
88swigp4.cmi:
89	env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swigp4.ml
90	$(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml
91extra_objects: swig.cmi swig.cmo swigp4.cmi
92
93$(C_TEST_CASES:=.ctest): extra_objects
94$(CPP_TEST_CASES:=.cpptest): extra_objects
95$(MULTI_CPP_TEST_CASES:=.multicpptest): extra_objects
96
97# Clean
98%.clean:
99	@rm -f $*.ml $*.mli $*_runme;
100	@if test $(srcdir) != .; then rm -f $(ml_runme); fi
101
102clean:
103	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ocaml_clean
104	rm -f clientdata_prop_a.ml clientdata_prop_b.ml import_stl_a.ml import_stl_b.ml
105	rm -f imports_a.ml imports_b.ml mod_a.ml mod_b.ml multi_import_a.ml
106	rm -f multi_import_b.ml packageoption_a.ml packageoption_b.ml packageoption_c.ml
107