1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
3 # $Id: Makefile,v 1.29 2005-01-28 23:09:30 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_Date_Calc.cmo \
32 wrappers/pl_Date_Format.cmo \
33 wrappers/pl_Date_Parse.cmo \
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_Cookies.cmo \
44 wrappers/pl_HTTP_Headers.cmo \
45 wrappers/pl_HTTP_Message.cmo \
46 wrappers/pl_HTTP_Request.cmo \
47 wrappers/pl_HTTP_Request_Common.cmo \
48 wrappers/pl_HTTP_Response.cmo \
49 wrappers/pl_HTML_Form.cmo \
50 wrappers/pl_LWP_UserAgent.cmo \
51 wrappers/pl_Template.cmo \
52 wrappers/pl_WWW_Mechanize.cmo
54 all: perl4caml.cma perl4caml.cmxa META all-examples html
56 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
57 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
59 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
60 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
62 all-examples: examples/test.bc examples/loadpage.bc examples/google.bc \
63 examples/test.opt examples/loadpage.opt examples/google.opt \
64 examples/parsedate.bc examples/parsedate.opt
66 TEST_PROGRAMS := $(patsubst %.ml,%.bc,$(wildcard test/*.ml)) \
67 $(patsubst %.ml,%.opt,$(wildcard test/*.ml))
69 test: $(TEST_PROGRAMS) run-tests
75 export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; \
76 for prog in $(TEST_PROGRAMS); do \
78 echo Test $$prog failed; \
79 fails=$$(($$fails+1)); \
81 count=$$(($$count+1)); \
83 if [ $$fails -eq 0 ]; then \
84 echo All tests succeeded.; \
87 echo $$fails/$$count tests failed.; \
92 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
95 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
96 $(DYNALOADER_HACK) $^ -o $@
99 $(OCAMLC) $(OCAMLCFLAGS) -c $<
102 $(OCAMLC) $(OCAMLCFLAGS) -c $<
105 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
107 .SUFFIXES: .mli .ml .cmi .cmo .cmx
109 META: META.in Makefile.config
110 $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
111 -e 's/@VERSION@/$(VERSION)/' \
116 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so \
121 for d in . examples test wrappers; do \
122 (cd $$d; rm -f $(JUNKFILES)); \
125 # Build dependencies.
127 ifeq ($(wildcard .depend),.depend)
133 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
134 $(wildcard wrappers/*.ml)
135 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
141 rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
142 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
143 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
144 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
145 perl4caml.a libperl4caml.a META \
146 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
147 $(DESTDIR)$(OCAMLLIBDIR)/perl
148 install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
153 $(MAKE) check-manifest
154 rm -rf $(PACKAGE)-$(VERSION)
155 mkdir $(PACKAGE)-$(VERSION)
156 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
157 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
158 rm -rf $(PACKAGE)-$(VERSION)
159 ls -l $(PACKAGE)-$(VERSION).tar.gz
162 @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
165 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
166 sed -e "s|^|$$b|" -e "s|^\./||"; \
167 done | sort > .check-manifest; \
168 sort MANIFEST > .orig-manifest; \
169 diff -u .orig-manifest .check-manifest; rv=$$?; \
170 rm -f .orig-manifest .check-manifest; \
176 @if [ 0 != `cvs -q update | wc -l` ]; then \
177 echo Please commit all changes to CVS first.; \
183 cp $(PACKAGE)-$(VERSION).tar.gz \
184 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
185 export CVSROOT=`cat CVS/Root`; \
188 -d $(PACKAGE)-$(VERSION) \
189 -D now merjis/test/perl4caml
190 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
191 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
196 html: html/index.html
198 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
201 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
203 .PHONY: depend dist check-manifest html dpkg test run-tests