1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.18 2003-11-08 11:52:03 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)
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.1/auto/DynaLoader/DynaLoader.a
31 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
34 wrappers/pl_Net_Google_Cache.cmo \
35 wrappers/pl_Net_Google_Response.cmo \
36 wrappers/pl_Net_Google_Search.cmo \
37 wrappers/pl_Net_Google_Spelling.cmo \
38 wrappers/pl_Net_Google.cmo \
39 wrappers/pl_HTML_Element.cmo \
40 wrappers/pl_HTML_Parser.cmo \
41 wrappers/pl_HTML_TreeBuilder.cmo \
43 wrappers/pl_HTTP_Message.cmo \
44 wrappers/pl_HTTP_Request.cmo \
45 wrappers/pl_HTTP_Response.cmo \
46 wrappers/pl_LWP_UserAgent.cmo
48 all: perl4caml.cma perl4caml.cmxa META all-examples html
50 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
51 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
53 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
54 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
56 all-examples: examples/test examples/loadpage examples/google \
57 examples/test.opt examples/loadpage.opt examples/google.opt
59 examples/test: examples/test.cmo
60 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
62 examples/test.opt: examples/test.cmx
63 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
64 $(DYNALOADER_HACK) $^ -o $@
66 examples/loadpage: examples/loadpage.cmo
67 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
69 examples/loadpage.opt: examples/loadpage.cmx
70 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
71 $(DYNALOADER_HACK) $^ -o $@
73 examples/google: examples/google.cmo
74 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
76 examples/google.opt: examples/google.cmx
77 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
78 $(DYNALOADER_HACK) $^ -o $@
81 $(OCAMLC) $(OCAMLCFLAGS) -c $<
84 $(OCAMLC) $(OCAMLCFLAGS) -c $<
87 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
89 .SUFFIXES: .mli .ml .cmi .cmo .cmx
91 META: META.in Makefile.config
92 $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
93 -e 's/@VERSION@/$(VERSION)/' \
98 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
101 rm -f META examples/test examples/loadpage examples/google
102 for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done
104 # Build dependencies.
106 ifeq ($(wildcard .depend),.depend)
112 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
113 $(wildcard wrappers/*.ml)
114 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
120 rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
121 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
122 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
123 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
124 perl4caml.a libperl4caml.a META \
125 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
126 $(DESTDIR)$(OCAMLLIBDIR)/perl
127 install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
132 rm -rf $(PACKAGE)-$(VERSION)
133 mkdir $(PACKAGE)-$(VERSION)
134 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
135 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
136 rm -rf $(PACKAGE)-$(VERSION)
137 ls -l $(PACKAGE)-$(VERSION).tar.gz
140 @for d in `find -type d -name CVS`; \
143 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
144 sed -e "s|^|$$b|" -e "s|^\./||"; \
145 done | sort > .check-manifest; \
146 sort MANIFEST > .orig-manifest; \
147 diff -u .orig-manifest .check-manifest; \
148 rm -f .orig-manifest .check-manifest
153 @if [ 0 != `cvs -q update | wc -l` ]; then \
154 echo Please commit all changes to CVS first.; \
160 cp $(PACKAGE)-$(VERSION).tar.gz \
161 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
162 export CVSROOT=`cat CVS/Root`; \
165 -d $(PACKAGE)-$(VERSION) \
166 -D now merjis/test/perl4caml
167 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
168 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
173 html: html/index.html
175 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
178 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
180 .PHONY: depend dist check-manifest html dpkg