Enable native code compilation when ocamlopt is available.
[whenjobs.git] / lib / Makefile.am
index 76a2d26..747f074 100644 (file)
@@ -20,6 +20,10 @@ EXTRA_DIST = whenproto.x pa_when.ml $(SOURCES)
 libwhenjobsdir = $(libdir)/$(PACKAGE_NAME)
 libwhenjobs_SCRIPTS = whenlib.cma pa_when.cmo $(CMI_FILES)
 
+if HAVE_OCAMLOPT
+libwhenjobs_SCRIPTS += whenlib.cmxa
+endif
+
 OCAMLPACKAGES = -package unix,num,camlp4.lib,calendar,rpc
 
 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
@@ -47,7 +51,7 @@ SOURCES = \
 # In alphabetical order.
 CMI_FILES = \
        config.cmi \
-       whenexpr.cmi
+       whenexpr.cmi \
        whenfile.cmi \
        whenlock.cmi \
        whenproto_aux.cmi \
@@ -66,6 +70,8 @@ OBJECTS = \
        whentools.cmo \
        whenlock.cmo
 
+XOBJECTS = $(OBJECTS:.cmo=.cmx)
+
 # Library.
 noinst_LIBRARIES = liblibrary.a
 liblibrary_a_SOURCES = flock.c
@@ -74,6 +80,9 @@ liblibrary_a_CFLAGS = -I$(shell $(OCAMLC) -where)
 whenlib.cma: $(OBJECTS) liblibrary.a
        $(OCAMLFIND) c -a $(OCAMLCFLAGS) $(OBJECTS) -cclib -llibrary -o $@
 
+whenlib.cmxa: $(XOBJECTS) liblibrary.a
+       $(OCAMLFIND) opt -a $(OCAMLOPTFLAGS) $(XOBJECTS) -cclib -llibrary -o $@
+
 whenproto_aux.ml whenproto_aux.mli: whenproto.x
        $(OCAMLRPCGEN) -int int32 -hyper int64 -aux $<