1 # Interface to Perl from OCaml.
2 # Copyright (C) 2003 Merjis Ltd.
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Library General Public
6 # License as published by the Free Software Foundation; either
7 # version 2 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Library General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this library; see the file COPYING. If not, write to
16 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
19 # $Id: Makefile,v 1.33 2008-03-01 13:02:21 rich Exp $
21 include Makefile.config
25 OCAMLMKLIB := ocamlmklib
29 OCAMLCINCS := -I wrappers
30 OCAMLOPTINCS := $(OCAMLCINCS)
32 OCAMLCFLAGS := -w s -g $(OCAMLCINCS)
33 OCAMLOPTFLAGS := -w s $(OCAMLOPTINCS)
35 PERLCFLAGS := $(shell perl -e 'use Config; print $$Config{ccflags};')
38 CFLAGS := -fPIC -Wall -Wno-unused \
40 -I$(PERLINCDIR) $(PERLCFLAGS) \
41 $(EXTRA_CFLAGS) $(EXTRA_EXTRA_CFLAGS)
43 LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)
47 OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS)
50 wrappers/pl_Data_Dumper.cmo \
51 wrappers/pl_Date_Calc.cmo \
52 wrappers/pl_Date_Format.cmo \
53 wrappers/pl_Date_Parse.cmo \
54 wrappers/pl_Net_Google_Cache.cmo \
55 wrappers/pl_Net_Google_Response.cmo \
56 wrappers/pl_Net_Google_Search.cmo \
57 wrappers/pl_Net_Google_Spelling.cmo \
58 wrappers/pl_Net_Google.cmo \
59 wrappers/pl_HTML_Element.cmo \
60 wrappers/pl_HTML_Parser.cmo \
61 wrappers/pl_HTML_TreeBuilder.cmo \
63 wrappers/pl_HTTP_Cookies.cmo \
64 wrappers/pl_HTTP_Headers.cmo \
65 wrappers/pl_HTTP_Message.cmo \
66 wrappers/pl_HTTP_Request.cmo \
67 wrappers/pl_HTTP_Request_Common.cmo \
68 wrappers/pl_HTTP_Response.cmo \
69 wrappers/pl_HTML_Form.cmo \
70 wrappers/pl_LWP_UserAgent.cmo \
71 wrappers/pl_Template.cmo \
72 wrappers/pl_WWW_Mechanize.cmo
74 all: perl4caml.cma perl4caml.cmxa META all-examples html
76 perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
77 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
79 perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
80 $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^
82 all-examples: examples/test.bc examples/loadpage.bc examples/google.bc \
83 examples/test.opt examples/loadpage.opt examples/google.opt \
84 examples/parsedate.bc examples/parsedate.opt
86 TEST_PROGRAMS := $(patsubst %.ml,%.bc,$(wildcard test/*.ml)) \
87 $(patsubst %.ml,%.opt,$(wildcard test/*.ml))
89 test: $(TEST_PROGRAMS) run-tests
95 export LD_LIBRARY_PATH=`pwd`:$$LD_LIBRARY_PATH; \
96 for prog in $(TEST_PROGRAMS); do \
98 echo Test $$prog failed; \
99 fails=$$(($$fails+1)); \
101 count=$$(($$count+1)); \
103 if [ $$fails -eq 0 ]; then \
104 echo All tests succeeded.; \
107 echo $$fails/$$count tests failed.; \
112 $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@
115 $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
116 $(DYNALOADER_HACK) $^ -o $@
119 $(OCAMLC) $(OCAMLCFLAGS) -c $<
122 $(OCAMLC) $(OCAMLCFLAGS) -c $<
125 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
127 .SUFFIXES: .mli .ml .cmi .cmo .cmx
129 META: META.in Makefile.config
130 $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
131 -e 's/@VERSION@/$(VERSION)/' \
136 JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so \
141 for d in . examples test wrappers; do \
142 (cd $$d; rm -f $(JUNKFILES)); \
145 # Build dependencies.
147 ifeq ($(wildcard .depend),.depend)
153 .depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
154 $(wildcard wrappers/*.ml)
155 $(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
161 rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
162 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
163 install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
164 install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
165 perl4caml.a libperl4caml.a META \
166 $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
167 $(DESTDIR)$(OCAMLLIBDIR)/perl
168 install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs
173 $(MAKE) check-manifest
174 rm -rf $(PACKAGE)-$(VERSION)
175 mkdir $(PACKAGE)-$(VERSION)
176 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
177 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
178 rm -rf $(PACKAGE)-$(VERSION)
179 ls -l $(PACKAGE)-$(VERSION).tar.gz
182 @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
185 awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
186 sed -e "s|^|$$b|" -e "s|^\./||"; \
187 done | sort > .check-manifest; \
188 sort MANIFEST > .orig-manifest; \
189 diff -u .orig-manifest .check-manifest; rv=$$?; \
190 rm -f .orig-manifest .check-manifest; \
196 @if [ 0 != `cvs -q update | wc -l` ]; then \
197 echo Please commit all changes to CVS first.; \
203 cp $(PACKAGE)-$(VERSION).tar.gz \
204 /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
205 export CVSROOT=`cat CVS/Root`; \
208 -d $(PACKAGE)-$(VERSION) \
209 -D now merjis/test/perl4caml
210 cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
211 rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
216 html: html/index.html
218 html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
221 -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^
223 .PHONY: depend dist check-manifest html dpkg test run-tests