# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX
+OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX -I +camlp4 -I ../generator-lib
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
PP = -pp '$(CAMLP4O) ../generator-macros/pa_wrap.cmo -impl'
-#API_FILES = $(wildcard *.api)
-API_FILES = mkdir.api mknod.api
+API_FILES = $(wildcard *.api)
-OBJ_FILES = $(patsubst %.api,%.cmo,$(API_FILES))
+OBJECTS = $(patsubst %.api,%.cmo,$(API_FILES))
-noinst_SCRIPTS = $(OBJ_FILES)
+noinst_SCRIPTS = apis.cma
-%.cmo: %.api
+apis.cma: $(OBJECTS) ../generator-lib/generator_lib.cma
+ $(OCAMLFIND) ocamlc -linkall -a $(OBJECTS) -o apis.cma
+
+%.cmo: %.api ../generator-lib/generator_lib.cma ../generator-macros/pa_wrap.cmo
$(OCAMLFIND) ocamlc $(OCAMLOPTFLAGS) $(PP) -impl $< -c -o $@
-CLEANFILES = *.cmi *.cmo *.cmx *~
+CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *~
+
+depend: .depend
+
+.depend: $(API_FILES)
+ rm -f $@ $@-t
+ $(OCAMLFIND) ocamldep $(PP) -impl $^ | \
+ $(SED) -e 's/ *$$//' | \
+ $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
+ LANG=C sort > $@-t
+ mv $@-t $@
+
+include .depend
SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly .api