1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.19 2003-11-19 16:28:22 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.2/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
51 all: perl4caml.cma perl4caml.cmxa META all-examples html
53 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
54 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
56 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
57 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
59 all-examples: examples/test examples/loadpage examples/google \
60 examples/test.opt examples/loadpage.opt examples/google.opt \
61 examples/parsedate examples/parsedate.opt
63 examples/test: examples/test.cmo
64 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
66 examples/test.opt: examples/test.cmx
67 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
68 $(DYNALOADER_HACK) $^ -o $@
70 examples/loadpage: examples/loadpage.cmo
71 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
73 examples/loadpage.opt: examples/loadpage.cmx
74 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
75 $(DYNALOADER_HACK) $^ -o $@
77 examples/google: examples/google.cmo
78 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
80 examples/google.opt: examples/google.cmx
81 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
82 $(DYNALOADER_HACK) $^ -o $@
84 examples/parsedate: examples/parsedate.cmo
85 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
87 examples/parsedate.opt: examples/parsedate.cmx
88 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
89 $(DYNALOADER_HACK) $^ -o $@
92 $(OCAMLC) $(OCAMLCFLAGS) -c $<
95 $(OCAMLC) $(OCAMLCFLAGS) -c $<
98 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
100 .SUFFIXES: .mli .ml .cmi .cmo .cmx
102 META: META.in Makefile.config
103 $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
104 -e 's/@VERSION@/$(VERSION)/' \
109 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *.opt
112 rm -f META examples/test examples/loadpage examples/google \
114 for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done
116 # Build dependencies.
118 ifeq ($(wildcard .depend),.depend)
124 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
125 $(wildcard wrappers/*.ml)
126 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
132 rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
133 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
134 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
135 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
136 perl4caml.a libperl4caml.a META \
137 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
138 $(DESTDIR)$(OCAMLLIBDIR)/perl
139 install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
144 rm -rf $(PACKAGE)-$(VERSION)
145 mkdir $(PACKAGE)-$(VERSION)
146 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
147 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
148 rm -rf $(PACKAGE)-$(VERSION)
149 ls -l $(PACKAGE)-$(VERSION).tar.gz
152 @for d in `find -type d -name CVS`; \
155 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
156 sed -e "s|^|$$b|" -e "s|^\./||"; \
157 done | sort > .check-manifest; \
158 sort MANIFEST > .orig-manifest; \
159 diff -u .orig-manifest .check-manifest; \
160 rm -f .orig-manifest .check-manifest
165 @if [ 0 != `cvs -q update | wc -l` ]; then \
166 echo Please commit all changes to CVS first.; \
172 cp $(PACKAGE)-$(VERSION).tar.gz \
173 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
174 export CVSROOT=`cat CVS/Root`; \
177 -d $(PACKAGE)-$(VERSION) \
178 -D now merjis/test/perl4caml
179 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
180 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
185 html: html/index.html
187 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
190 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
192 .PHONY: depend dist check-manifest html dpkg