1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.12 2003-10-22 10:18:26 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)
24 # XXX Hack required by ocamlopt, and sometimes ocamlc.
25 # To work out what this should be, try:
26 # `shell perl -MExtUtils::Embed -e ldopts'
27 DYNALOADER_HACK := /usr/lib/perl/5.8.1/auto/DynaLoader/DynaLoader.a
29 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
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_Message.cmo \
42 wrappers/pl_HTTP_Request.cmo \
43 wrappers/pl_HTTP_Response.cmo \
44 wrappers/pl_LWP_UserAgent.cmo
46 all: perl4caml.cma perl4caml.cmxa all-examples html
48 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
49 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
51 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
52 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
54 all-examples: examples/test examples/loadpage examples/google \
55 examples/test.opt examples/loadpage.opt examples/google.opt
57 examples/test: examples/test.cmo
58 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
60 examples/test.opt: examples/test.cmx
61 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
62 $(DYNALOADER_HACK) $^ -o $@
64 examples/loadpage: examples/loadpage.cmo
65 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
67 examples/loadpage.opt: examples/loadpage.cmx
68 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
69 $(DYNALOADER_HACK) $^ -o $@
71 examples/google: examples/google.cmo
72 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
74 examples/google.opt: examples/google.cmx
75 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
76 $(DYNALOADER_HACK) $^ -o $@
79 $(OCAMLC) $(OCAMLCFLAGS) -c $<
82 $(OCAMLC) $(OCAMLCFLAGS) -c $<
85 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
87 .SUFFIXES: .mli .ml .cmi .cmo .cmx
91 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
94 rm -f examples/test examples/loadpage examples/google
95 for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done
99 ifeq ($(wildcard .depend),.depend)
105 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
106 $(wildcard wrappers/*.ml)
107 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
113 rm -rf $(OCAMLLIBDIR)/perl
114 install -c -m 0755 -d $(OCAMLLIBDIR)/perl
115 install -c -m 0755 -d $(OCAMLLIBDIR)/stublibs
116 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
117 perl4caml.a libperl4caml.a \
118 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) $(OCAMLLIBDIR)/perl
119 install -c -m 0644 dllperl4caml.so $(OCAMLLIBDIR)/stublibs
124 rm -rf $(PACKAGE)-$(VERSION)
125 mkdir $(PACKAGE)-$(VERSION)
126 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
127 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
128 rm -rf $(PACKAGE)-$(VERSION)
129 ls -l $(PACKAGE)-$(VERSION).tar.gz
132 @for d in `find -type d -name CVS`; \
135 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
136 sed -e "s|^|$$b|" -e "s|^\./||"; \
137 done | sort > .check-manifest; \
138 sort MANIFEST > .orig-manifest; \
139 diff -u .orig-manifest .check-manifest; \
140 rm -f .orig-manifest .check-manifest
144 html: html/index.html
146 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
149 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
151 .PHONY: depend dist check-manifest html