1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.31 2006-11-01 10:32:46 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)
19 PERLCFLAGS := $(shell perl -e 'use Config; print $$Config{ccflags};')
22 CFLAGS := -fPIC -Wall -Wno-unused -I$(PERLINCDIR) $(PERLCFLAGS) $(EXTRA_CFLAGS)
24 LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)
28 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
31 wrappers/pl_Data_Dumper.cmo \
32 wrappers/pl_Date_Calc.cmo \
33 wrappers/pl_Date_Format.cmo \
34 wrappers/pl_Date_Parse.cmo \
35 wrappers/pl_Net_Google_Cache.cmo \
36 wrappers/pl_Net_Google_Response.cmo \
37 wrappers/pl_Net_Google_Search.cmo \
38 wrappers/pl_Net_Google_Spelling.cmo \
39 wrappers/pl_Net_Google.cmo \
40 wrappers/pl_HTML_Element.cmo \
41 wrappers/pl_HTML_Parser.cmo \
42 wrappers/pl_HTML_TreeBuilder.cmo \
44 wrappers/pl_HTTP_Cookies.cmo \
45 wrappers/pl_HTTP_Headers.cmo \
46 wrappers/pl_HTTP_Message.cmo \
47 wrappers/pl_HTTP_Request.cmo \
48 wrappers/pl_HTTP_Request_Common.cmo \
49 wrappers/pl_HTTP_Response.cmo \
50 wrappers/pl_HTML_Form.cmo \
51 wrappers/pl_LWP_UserAgent.cmo \
52 wrappers/pl_Template.cmo \
53 wrappers/pl_WWW_Mechanize.cmo
55 all: perl4caml.cma perl4caml.cmxa META all-examples html
57 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
58 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
60 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
61 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
63 all-examples: examples/test.bc examples/loadpage.bc examples/google.bc \
64 examples/test.opt examples/loadpage.opt examples/google.opt \
65 examples/parsedate.bc examples/parsedate.opt
67 TEST_PROGRAMS := $(patsubst %.ml,%.bc,$(wildcard test/*.ml)) \
68 $(patsubst %.ml,%.opt,$(wildcard test/*.ml))
70 test: $(TEST_PROGRAMS) run-tests
76 export LD_LIBRARY_PATH=`pwd`:$$LD_LIBRARY_PATH; \
77 for prog in $(TEST_PROGRAMS); do \
79 echo Test $$prog failed; \
80 fails=$$(($$fails+1)); \
82 count=$$(($$count+1)); \
84 if [ $$fails -eq 0 ]; then \
85 echo All tests succeeded.; \
88 echo $$fails/$$count tests failed.; \
93 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
96 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
97 $(DYNALOADER_HACK) $^ -o $@
100 $(OCAMLC) $(OCAMLCFLAGS) -c $<
103 $(OCAMLC) $(OCAMLCFLAGS) -c $<
106 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
108 .SUFFIXES: .mli .ml .cmi .cmo .cmx
110 META: META.in Makefile.config
111 $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
112 -e 's/@VERSION@/$(VERSION)/' \
117 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so \
122 for d in . examples test wrappers; do \
123 (cd $$d; rm -f $(JUNKFILES)); \
126 # Build dependencies.
128 ifeq ($(wildcard .depend),.depend)
134 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
135 $(wildcard wrappers/*.ml)
136 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
142 rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
143 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
144 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
145 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
146 perl4caml.a libperl4caml.a META \
147 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
148 $(DESTDIR)$(OCAMLLIBDIR)/perl
149 install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
154 $(MAKE) check-manifest
155 rm -rf $(PACKAGE)-$(VERSION)
156 mkdir $(PACKAGE)-$(VERSION)
157 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
158 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
159 rm -rf $(PACKAGE)-$(VERSION)
160 ls -l $(PACKAGE)-$(VERSION).tar.gz
163 @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
166 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
167 sed -e "s|^|$$b|" -e "s|^\./||"; \
168 done | sort > .check-manifest; \
169 sort MANIFEST > .orig-manifest; \
170 diff -u .orig-manifest .check-manifest; rv=$$?; \
171 rm -f .orig-manifest .check-manifest; \
177 @if [ 0 != `cvs -q update | wc -l` ]; then \
178 echo Please commit all changes to CVS first.; \
184 cp $(PACKAGE)-$(VERSION).tar.gz \
185 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
186 export CVSROOT=`cat CVS/Root`; \
189 -d $(PACKAGE)-$(VERSION) \
190 -D now merjis/test/perl4caml
191 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
192 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
197 html: html/index.html
199 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
202 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
204 .PHONY: depend dist check-manifest html dpkg test run-tests