1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.27 2004-12-11 13:38:32 rich Exp $
5 include Makefile.config
9 OCAMLMKLIB := ocamlmklib
13 OCAMLCINCS := -I wrappers
14 OCAMLOPTINCS := $(OCAMLCINCS)
16 OCAMLCFLAGS := -w s -g $(OCAMLCINCS)
17 OCAMLOPTFLAGS := -w s $(OCAMLOPTINCS)
20 CFLAGS := -fPIC -Wall -Wno-unused -I$(PERLINCDIR) $(EXTRA_CFLAGS)
22 LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)
26 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
29 wrappers/pl_Date_Calc.cmo \
30 wrappers/pl_Date_Format.cmo \
31 wrappers/pl_Date_Parse.cmo \
32 wrappers/pl_Net_Google_Cache.cmo \
33 wrappers/pl_Net_Google_Response.cmo \
34 wrappers/pl_Net_Google_Search.cmo \
35 wrappers/pl_Net_Google_Spelling.cmo \
36 wrappers/pl_Net_Google.cmo \
37 wrappers/pl_HTML_Element.cmo \
38 wrappers/pl_HTML_Parser.cmo \
39 wrappers/pl_HTML_TreeBuilder.cmo \
41 wrappers/pl_HTTP_Cookies.cmo \
42 wrappers/pl_HTTP_Headers.cmo \
43 wrappers/pl_HTTP_Message.cmo \
44 wrappers/pl_HTTP_Request.cmo \
45 wrappers/pl_HTTP_Request_Common.cmo \
46 wrappers/pl_HTTP_Response.cmo \
47 wrappers/pl_HTML_Form.cmo \
48 wrappers/pl_LWP_UserAgent.cmo \
49 wrappers/pl_Template.cmo \
50 wrappers/pl_WWW_Mechanize.cmo
52 all: perl4caml.cma perl4caml.cmxa META all-examples html
54 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
55 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
57 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
58 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
60 all-examples: examples/test examples/loadpage examples/google \
61 examples/test.opt examples/loadpage.opt examples/google.opt \
62 examples/parsedate examples/parsedate.opt
64 examples/test: examples/test.cmo
65 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
67 examples/test.opt: examples/test.cmx
68 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
69 $(DYNALOADER_HACK) $^ -o $@
71 examples/loadpage: examples/loadpage.cmo
72 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
74 examples/loadpage.opt: examples/loadpage.cmx
75 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
76 $(DYNALOADER_HACK) $^ -o $@
78 examples/google: examples/google.cmo
79 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
81 examples/google.opt: examples/google.cmx
82 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
83 $(DYNALOADER_HACK) $^ -o $@
85 examples/parsedate: examples/parsedate.cmo
86 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
88 examples/parsedate.opt: examples/parsedate.cmx
89 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
90 $(DYNALOADER_HACK) $^ -o $@
93 $(OCAMLC) $(OCAMLCFLAGS) -c $<
96 $(OCAMLC) $(OCAMLCFLAGS) -c $<
99 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
101 .SUFFIXES: .mli .ml .cmi .cmo .cmx
103 META: META.in Makefile.config
104 $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
105 -e 's/@VERSION@/$(VERSION)/' \
110 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *.opt
113 rm -f META examples/test examples/loadpage examples/google \
115 for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done
117 # Build dependencies.
119 ifeq ($(wildcard .depend),.depend)
125 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
126 $(wildcard wrappers/*.ml)
127 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
133 rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
134 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
135 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
136 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
137 perl4caml.a libperl4caml.a META \
138 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
139 $(DESTDIR)$(OCAMLLIBDIR)/perl
140 install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
145 $(MAKE) check-manifest
146 rm -rf $(PACKAGE)-$(VERSION)
147 mkdir $(PACKAGE)-$(VERSION)
148 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
149 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
150 rm -rf $(PACKAGE)-$(VERSION)
151 ls -l $(PACKAGE)-$(VERSION).tar.gz
154 @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
157 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
158 sed -e "s|^|$$b|" -e "s|^\./||"; \
159 done | sort > .check-manifest; \
160 sort MANIFEST > .orig-manifest; \
161 diff -u .orig-manifest .check-manifest; rv=$$?; \
162 rm -f .orig-manifest .check-manifest; \
168 @if [ 0 != `cvs -q update | wc -l` ]; then \
169 echo Please commit all changes to CVS first.; \
175 cp $(PACKAGE)-$(VERSION).tar.gz \
176 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
177 export CVSROOT=`cat CVS/Root`; \
180 -d $(PACKAGE)-$(VERSION) \
181 -D now merjis/test/perl4caml
182 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
183 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
188 html: html/index.html
190 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
193 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
195 .PHONY: depend dist check-manifest html dpkg