1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.21 2004-11-03 14:15:16 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 := -Wall -Wno-unused -I$(PERLINCDIR) $(EXTRA_CFLAGS)
22 LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)
26 # XXX Hack required by ocamlopt, and sometimes ocamlc.
27 # To work out what this should be, try:
28 # `perl -MExtUtils::Embed -e ldopts'
29 DYNALOADER_HACK := /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a
31 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
34 wrappers/pl_Date_Calc.cmo \
35 wrappers/pl_Date_Format.cmo \
36 wrappers/pl_Date_Parse.cmo \
37 wrappers/pl_Net_Google_Cache.cmo \
38 wrappers/pl_Net_Google_Response.cmo \
39 wrappers/pl_Net_Google_Search.cmo \
40 wrappers/pl_Net_Google_Spelling.cmo \
41 wrappers/pl_Net_Google.cmo \
42 wrappers/pl_HTML_Element.cmo \
43 wrappers/pl_HTML_Parser.cmo \
44 wrappers/pl_HTML_TreeBuilder.cmo \
46 wrappers/pl_HTTP_Message.cmo \
47 wrappers/pl_HTTP_Request.cmo \
48 wrappers/pl_HTTP_Response.cmo \
49 wrappers/pl_LWP_UserAgent.cmo \
50 wrappers/pl_Template.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 rm -rf $(PACKAGE)-$(VERSION)
146 mkdir $(PACKAGE)-$(VERSION)
147 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
148 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
149 rm -rf $(PACKAGE)-$(VERSION)
150 ls -l $(PACKAGE)-$(VERSION).tar.gz
153 @for d in `find -type d -name CVS`; \
156 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
157 sed -e "s|^|$$b|" -e "s|^\./||"; \
158 done | sort > .check-manifest; \
159 sort MANIFEST > .orig-manifest; \
160 diff -u .orig-manifest .check-manifest; \
161 rm -f .orig-manifest .check-manifest
166 @if [ 0 != `cvs -q update | wc -l` ]; then \
167 echo Please commit all changes to CVS first.; \
173 cp $(PACKAGE)-$(VERSION).tar.gz \
174 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
175 export CVSROOT=`cat CVS/Root`; \
178 -d $(PACKAGE)-$(VERSION) \
179 -D now merjis/test/perl4caml
180 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
181 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
186 html: html/index.html
188 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
191 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
193 .PHONY: depend dist check-manifest html dpkg