File: Makefile

package info (click to toggle)
perl4caml 0.9.5-5.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 512 kB
  • sloc: ml: 1,572; ansic: 957; makefile: 186; perl: 45
file content (244 lines) | stat: -rw-r--r-- 6,378 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Interface to Perl from OCaml.
# Copyright (C) 2003 Merjis Ltd.
#
# 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

ifeq (YES, $(shell if [ -x /usr/bin/ocamlopt ]; then echo YES; fi))
HASOCAMLOPT := yes
endif

OCAMLC := ocamlc
OCAMLOPT := ocamlopt
OCAMLMKLIB := ocamlmklib
OCAMLDEP := ocamldep
OCAMLDOC := ocamldoc

OCAMLCINCS := -I wrappers
OCAMLOPTINCS := $(OCAMLCINCS)

OCAMLCFLAGS := -w s -g $(OCAMLCINCS)
OCAMLOPTFLAGS := -w s $(OCAMLOPTINCS)

PERLCFLAGS := $(shell perl -e 'use Config; print $$Config{ccflags};')

CC := gcc
CFLAGS := -fPIC -Wall -Wno-unused \
	-I$(OCAMLLIBDIR) \
	-I$(PERLINCDIR) $(PERLCFLAGS) \
	$(EXTRA_CFLAGS) $(EXTRA_EXTRA_CFLAGS)

LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts)

SED := sed

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 \
	wrappers/pl_HTML_Element.cmo \
	wrappers/pl_HTML_Parser.cmo \
	wrappers/pl_HTML_TreeBuilder.cmo \
	wrappers/pl_URI.cmo \
	wrappers/pl_HTTP_Cookies.cmo \
	wrappers/pl_HTTP_Headers.cmo \
	wrappers/pl_HTTP_Message.cmo \
	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

ifdef HASOCAMLOPT
all:	perl4caml.cma perl4caml.cmxa META all-examples html
else
all:	perl4caml.cma META all-examples html
endif

perl4caml.cma: perl.cmo perl_c.o $(WRAPPERS)
	$(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^

perl4caml.cmxa: perl.cmx perl_c.o $(WRAPPERS:.cmo=.cmx)
	$(OCAMLMKLIB) -o perl4caml $(LIBPERL) $^

ifdef HASOCAMLOPT
all-examples: examples/test.bc examples/loadpage.bc \
	examples/test.opt examples/loadpage.opt \
	examples/parsedate.bc examples/parsedate.opt
else
all-examples: examples/test.bc examples/loadpage.bc \
	examples/parsedate.bc
endif

TEST_PROGRAMS := $(patsubst %.ml,%.bc,$(wildcard test/*.ml))

ifdef HASOCAMLOPT
TEST_PROGRAMS += $(patsubst %.ml,%.opt,$(wildcard test/*.ml))
endif

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

%.bc: %.cmo
	$(OCAMLC) $(OCAMLCFLAGS) perl4caml.cma $^ -o $@

%.opt: %.cmx
	$(OCAMLOPT) $(OCAMLOPTFLAGS) -cclib -L. perl4caml.cmxa \
	$(DYNALOADER_HACK) $^ -o $@

%.cmi: %.mli
	$(OCAMLC) $(OCAMLCFLAGS) -c $<

%.cmo: %.ml
	$(OCAMLC) $(OCAMLCFLAGS) -c $<

%.cmx: %.ml
	$(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<

.SUFFIXES: .mli .ml .cmi .cmo .cmx

META:	META.in Makefile.config
	$(SED)  -e 's/@PACKAGE@/$(PACKAGE)/' \
		-e 's/@VERSION@/$(VERSION)/' \
		< $< > $@

# Clean.

JUNKFILES = core *~ *.bak *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so \
	*.bc *.opt

clean:
	rm -f META
	for d in . examples test wrappers; do \
	  (cd $$d; rm -f $(JUNKFILES)); \
	done

# Build dependencies.

ifeq ($(wildcard .depend),.depend)
include .depend
endif

depend:	.depend

.depend: $(wildcard *.ml) $(wildcard *.mli) $(wildcard examples/*.ml) \
	$(wildcard wrappers/*.ml)
	$(OCAMLDEP) $(OCAMLCINCS) *.mli *.ml examples/*.ml wrappers/*.ml \
	> .depend

# Install.

install:
	rm -rf $(DESTDIR)$(OCAMLLIBDIR)/perl
	install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/perl
	install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/stublibs
ifdef HASOCAMLOPT
	install -c -m 0644 perl.cmi perl.mli perl4caml.cma perl4caml.cmxa \
	  perl4caml.a libperl4caml.a META \
	  $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
	  $(DESTDIR)$(OCAMLLIBDIR)/perl
else
	install -c -m 0644 perl.cmi perl.mli perl4caml.cma \
	  META \
	  $(WRAPPERS:.cmo=.ml) $(WRAPPERS:.cmo=.cmi) \
	  $(DESTDIR)$(OCAMLLIBDIR)/perl
endif
	install -c -m 0644 dllperl4caml.so $(DESTDIR)$(OCAMLLIBDIR)/stublibs

# Distribution.

dist:
	$(MAKE) check-manifest
	rm -rf $(PACKAGE)-$(VERSION)
	mkdir $(PACKAGE)-$(VERSION)
	tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
	tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
	rm -rf $(PACKAGE)-$(VERSION)
	ls -l $(PACKAGE)-$(VERSION).tar.gz

check-manifest:
	@for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
	do \
	b=`dirname $$d`/; \
	awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
	sed -e "s|^|$$b|" -e "s|^\./||"; \
	done | sort > .check-manifest; \
	sort MANIFEST > .orig-manifest; \
	diff -u .orig-manifest .check-manifest; rv=$$?; \
	rm -f .orig-manifest .check-manifest; \
	exit $$rv

# Debian packages.

dpkg:
	@if [ 0 != `cvs -q update | wc -l` ]; then \
	echo Please commit all changes to CVS first.; \
	exit 1; \
	fi
	$(MAKE) dist
	rm -rf /tmp/dbuild
	mkdir /tmp/dbuild
	cp $(PACKAGE)-$(VERSION).tar.gz \
	  /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
	export CVSROOT=`cat CVS/Root`; \
	  cd /tmp/dbuild && \
	  cvs export \
	  -d $(PACKAGE)-$(VERSION) \
	  -D now merjis/test/perl4caml
	cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
	rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
	ls -l /tmp/dbuild

# Documentation.

html:	html/index.html

DOCUMENTED_FILES := $(wildcard *.ml) $(wildcard *.mli) $(wildcard wrappers/*.ml)
DOCUMENTED_FILES := $(patsubst wrappers/pl_Net_Google%,,$(DOCUMENTED_FILES))

html/index.html: $(DOCUMENTED_FILES)
	rm -rf html
	mkdir html
	-$(OCAMLDOC) $(OCAMLDOCFLAGS) -d html $^

.PHONY: depend dist check-manifest html dpkg test run-tests