1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.10 2003-10-15 16:51:12 rich Exp $
5 include Makefile.config
9 OCAMLMKLIB := ocamlmklib
12 OCAMLCINCS := -I wrappers
13 OCAMLOPTINCS := $(OCAMLCINCS)
15 OCAMLCFLAGS := -w s -g $(OCAMLCINCS)
16 OCAMLOPTFLAGS := -w s $(OCAMLOPTINCS)
19 CFLAGS := -Wall -Wno-unused -I$(PERLINCDIR)
21 LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)
23 # XXX Hack required by ocamlopt, and sometimes ocamlc.
24 # To work out what this should be, try:
25 # `shell perl -MExtUtils::Embed -e ldopts'
26 DYNALOADER_HACK := /usr/lib/perl/5.8.1/auto/DynaLoader/DynaLoader.a
29 wrappers/pl_Net_Google_Cache.cmo \
30 wrappers/pl_Net_Google_Response.cmo \
31 wrappers/pl_Net_Google_Search.cmo \
32 wrappers/pl_Net_Google_Spelling.cmo \
33 wrappers/pl_Net_Google.cmo \
34 wrappers/pl_HTML_Element.cmo \
35 wrappers/pl_HTML_Parser.cmo \
36 wrappers/pl_HTML_TreeBuilder.cmo \
38 wrappers/pl_HTTP_Message.cmo \
39 wrappers/pl_HTTP_Request.cmo \
40 wrappers/pl_HTTP_Response.cmo \
41 wrappers/pl_LWP_UserAgent.cmo
43 all: perl4caml.cma perl4caml.cmxa all-examples
45 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
46 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
48 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
49 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
51 all-examples: examples/test examples/loadpage examples/google \
52 examples/test.opt examples/loadpage.opt examples/google.opt
54 examples/test: examples/test.cmo
55 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
57 examples/test.opt: examples/test.cmx
58 $(OCAMLOPT) $(OCAMLOPTFLAGS) perl4caml.cmxa $(DYNALOADER_HACK) $^ -o $@
60 examples/loadpage: examples/loadpage.cmo
61 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
63 examples/loadpage.opt: examples/loadpage.cmx
64 $(OCAMLOPT) $(OCAMLOPTFLAGS) perl4caml.cmxa $(DYNALOADER_HACK) $^ -o $@
66 examples/google: examples/google.cmo
67 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
69 examples/google.opt: examples/google.cmx
70 $(OCAMLOPT) $(OCAMLOPTFLAGS) perl4caml.cmxa $(DYNALOADER_HACK) $^ -o $@
73 $(OCAMLC) $(OCAMLCFLAGS) -c $<
76 $(OCAMLC) $(OCAMLCFLAGS) -c $<
79 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
81 .SUFFIXES: .mli .ml .cmi .cmo .cmx
85 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
88 rm -f examples/test examples/loadpage examples/google
89 for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done
93 ifeq ($(wildcard .depend),.depend)
99 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
100 $(wildcard wrappers/*.ml)
101 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
107 rm -rf $(OCAMLLIBDIR)/perl
108 install -c -m 0755 -d $(OCAMLLIBDIR)/perl
109 install -c -m 0755 -d $(OCAMLLIBDIR)/stublibs
110 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
111 perl4caml.a libperl4caml.a \
112 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) $(OCAMLLIBDIR)/perl
113 install -c -m 0644 dllperl4caml.so $(OCAMLLIBDIR)/stublibs
118 rm -rf $(PACKAGE)-$(VERSION)
119 mkdir $(PACKAGE)-$(VERSION)
120 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
121 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
122 rm -rf $(PACKAGE)-$(VERSION)
123 ls -l $(PACKAGE)-$(VERSION).tar.gz
126 @for d in `find -type d -name CVS`; \
129 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
130 sed -e "s|^|$$b|" -e "s|^\./||"; \
131 done | sort > .check-manifest; \
132 sort MANIFEST > .orig-manifest; \
133 diff -u .orig-manifest .check-manifest; \
134 rm -f .orig-manifest .check-manifest
136 .PHONY: depend dist check-manifest