X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=Makefile;h=4827101c2fcc7da6a8e0c41e2ae783aa486f5d4e;hb=31b49439d92ab7d8c555951335709dd41412b697;hp=6f42213b9509a39f4959e3cc27e7cdee90498586;hpb=92ee36459463e0a040d32f5eac0ec38bb28be8f4;p=perl4caml.git diff --git a/Makefile b/Makefile index 6f42213..4827101 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,22 @@ # Interface to Perl from OCaml. # Copyright (C) 2003 Merjis Ltd. -# $Id: Makefile,v 1.23 2004-11-25 21:24:51 rich Exp $ +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this library; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# +# $Id: Makefile,v 1.33 2008-03-01 13:02:21 rich Exp $ include Makefile.config @@ -16,21 +32,22 @@ OCAMLOPTINCS := $(OCAMLCINCS) OCAMLCFLAGS := -w s -g $(OCAMLCINCS) OCAMLOPTFLAGS := -w s $(OCAMLOPTINCS) +PERLCFLAGS := $(shell perl -e 'use Config; print $$Config{ccflags};') + CC := gcc -CFLAGS := -Wall -Wno-unused -I$(PERLINCDIR) $(EXTRA_CFLAGS) +CFLAGS := -fPIC -Wall -Wno-unused \ + -I$(OCAMLLIBDIR) \ + -I$(PERLINCDIR) $(PERLCFLAGS) \ + $(EXTRA_CFLAGS) $(EXTRA_EXTRA_CFLAGS) LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts) SED := sed -# XXX Hack required by ocamlopt, and sometimes ocamlc. -# To work out what this should be, try: -# `perl -MExtUtils::Embed -e ldopts' -DYNALOADER_HACK := /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a - OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCINCS) WRAPPERS := \ + wrappers/pl_Data_Dumper.cmo \ wrappers/pl_Date_Calc.cmo \ wrappers/pl_Date_Format.cmo \ wrappers/pl_Date_Parse.cmo \ @@ -49,6 +66,7 @@ WRAPPERS := \ wrappers/pl_HTTP_Request.cmo \ wrappers/pl_HTTP_Request_Common.cmo \ wrappers/pl_HTTP_Response.cmo \ + wrappers/pl_HTML_Form.cmo \ wrappers/pl_LWP_UserAgent.cmo \ wrappers/pl_Template.cmo \ wrappers/pl_WWW_Mechanize.cmo @@ -61,35 +79,39 @@ perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS) perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx) $(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^ -all-examples: examples/test examples/loadpage examples/google \ +all-examples: examples/test.bc examples/loadpage.bc examples/google.bc \ examples/test.opt examples/loadpage.opt examples/google.opt \ - examples/parsedate examples/parsedate.opt - -examples/test: examples/test.cmo - $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@ - -examples/test.opt: examples/test.cmx - $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \ - $(DYNALOADER_HACK) $^ -o $@ - -examples/loadpage: examples/loadpage.cmo - $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@ - -examples/loadpage.opt: examples/loadpage.cmx - $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \ - $(DYNALOADER_HACK) $^ -o $@ - -examples/google: examples/google.cmo - $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@ - -examples/google.opt: examples/google.cmx - $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \ - $(DYNALOADER_HACK) $^ -o $@ + examples/parsedate.bc examples/parsedate.opt + +TEST_PROGRAMS := $(patsubst %.ml,%.bc,$(wildcard test/*.ml)) \ + $(patsubst %.ml,%.opt,$(wildcard test/*.ml)) + +test: $(TEST_PROGRAMS) run-tests + +check: test + +run-tests: + @fails=0; count=0; \ + export LD_LIBRARY_PATH=`pwd`:$$LD_LIBRARY_PATH; \ + for prog in $(TEST_PROGRAMS); do \ + if ! $$prog; then \ + echo Test $$prog failed; \ + fails=$$(($$fails+1)); \ + fi; \ + count=$$(($$count+1)); \ + done; \ + if [ $$fails -eq 0 ]; then \ + echo All tests succeeded.; \ + exit 0; \ + else \ + echo $$fails/$$count tests failed.; \ + exit 1; \ + fi -examples/parsedate: examples/parsedate.cmo +%.bc: %.cmo $(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@ -examples/parsedate.opt: examples/parsedate.cmx +%.opt: %.cmx $(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \ $(DYNALOADER_HACK) $^ -o $@ @@ -111,12 +133,14 @@ META: META.in Makefile.config # Clean. -JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *.opt +JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so \ + *.bc *.opt clean: - rm -f META examples/test examples/loadpage examples/google \ - examples/parsedate - for d in . examples wrappers; do (cd $$d; rm -f $(JUNKFILES)); done + rm -f META + for d in . examples test wrappers; do \ + (cd $$d; rm -f $(JUNKFILES)); \ + done # Build dependencies. @@ -146,6 +170,7 @@ install: # Distribution. dist: + $(MAKE) check-manifest rm -rf $(PACKAGE)-$(VERSION) mkdir $(PACKAGE)-$(VERSION) tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf - @@ -195,4 +220,4 @@ html/index.html: $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml) mkdir html -$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^ -.PHONY: depend dist check-manifest html dpkg \ No newline at end of file +.PHONY: depend dist check-manifest html dpkg test run-tests \ No newline at end of file