Enable native code compilation when ocamlopt is available.
[whenjobs.git] / tools / Makefile.am
index bbb5fa8..e7e4676 100644 (file)
@@ -39,6 +39,8 @@ OBJECTS = \
        whenproto_clnt.cmo \
        whenjobs.cmo
 
        whenproto_clnt.cmo \
        whenjobs.cmo
 
+XOBJECTS = $(OBJECTS:.cmo=.cmx)
+
 libdir.ml: Makefile
        rm -f $@ $@-t
        echo 'let libdir = "$(libdir)/$(PACKAGE_NAME)"' > $@-t
 libdir.ml: Makefile
        rm -f $@ $@-t
        echo 'let libdir = "$(libdir)/$(PACKAGE_NAME)"' > $@-t
@@ -50,9 +52,15 @@ whenproto_clnt.ml whenproto_clnt.mli: whenproto.x
 whenproto.x: ../lib/whenproto.x
        ln -f $< $@
 
 whenproto.x: ../lib/whenproto.x
        ln -f $< $@
 
+if HAVE_OCAMLOPT
+whenjobs: ../lib/whenlib.cmxa $(XOBJECTS)
+       $(OCAMLFIND) opt $(OCAMLCFLAGS) -ccopt -L../lib \
+         -linkpkg whenlib.cmxa $(XOBJECTS) -o $@
+else
 whenjobs: ../lib/whenlib.cma $(OBJECTS)
 whenjobs: ../lib/whenlib.cma $(OBJECTS)
-       $(OCAMLFIND) ocamlc -custom $(OCAMLCFLAGS) -ccopt -L../lib \
+       $(OCAMLFIND) c -custom $(OCAMLCFLAGS) -ccopt -L../lib \
          -linkpkg whenlib.cma $(OBJECTS) -o $@
          -linkpkg whenlib.cma $(OBJECTS) -o $@
+endif
 
 # Rules for all OCaml files.
 %.cmi: %.mli ../lib/whenlib.cma
 
 # Rules for all OCaml files.
 %.cmi: %.mli ../lib/whenlib.cma