File: Makefile

package info (click to toggle)
pgocaml 1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 332 kB
  • sloc: ml: 1,812; makefile: 575; sh: 55
file content (252 lines) | stat: -rw-r--r-- 6,847 bytes parent folder | download
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
245
246
247
248
249
250
251
252
# PG'OCaml - type safe interface to PostgreSQL.
# Copyright (C) 2005-2009 Richard Jones and other authors.
#
# 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.

include Makefile.config

ifeq ($(USE_BATTERIES),yes)
EXTLIB := batteries
else
EXTLIB := extlib
endif

SED	:= sed
FGREP	:= fgrep

OCAMLCFLAGS	:= -g
OCAMLCPACKAGES	:= -package unix,$(EXTLIB),pcre,calendar,csv,findlib
OCAMLCLIBS	:= -linkpkg

OCAMLSYNTAX := -syntax camlp4o -package camlp4.macro
ifeq ($(USE_BATTERIES),yes)
OCAMLSYNTAX += -ppopt -DUSE_BATTERIES
endif

OCAMLOPTFLAGS	:=
OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
OCAMLOPTLIBS	:= -linkpkg

OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCPACKAGES)

GETLIB=-I +$(1) $(shell ocamlfind query $(1) -predicates byte -format "%d/%a")

FOR_P4  := \
	$(call GETLIB,unix) \
	$(call GETLIB,str) \
	$(call GETLIB,pcre) \
	$(call GETLIB,$(EXTLIB)) \
	$(call GETLIB,calendar) \
	$(call GETLIB,csv) \
	./pgocaml.cma

#
# This is split into two because back-tick notation
# doesn't necessarily work under Windows
#

OCAMLVERSION := $(shell ocamlc -v | $(FGREP) "version" | $(SED) -e "s/.*3\.\(..\)\..*/\1/")
P4_PARAMS := $(shell [ $(OCAMLVERSION) -ge 9 ] && echo -loc loc)
P4_PARAMS += -parser Camlp4MacroParser
ifeq ($(USE_BATTERIES),yes)
P4_PARAMS += -DUSE_BATTERIES
endif

ifdef WINDOWS
  EXECUTABLE_SUFFIX := .exe
endif

#
# Top-rules.
#

OBJS	:= pGOCaml_config.cmo pGOCaml_generic.cmo pGOCaml.cmo
XOBJS	:= $(OBJS:.cmo=.cmx)

all: META pGOCaml_config.ml pgocaml.cma pgocaml.cmxa pgocaml.cmxs pa_pgsql.cmo pgocaml_prof$(EXECUTABLE_SUFFIX)
all_byte: META pGOCaml_config.ml pgocaml.cma pa_pgsql.cmo

test: test_pgocaml_lowlevel$(EXECUTABLE_SUFFIX) test_pgocaml$(EXECUTABLE_SUFFIX)

#
# Rules for testing programs.
#

test_pgocaml_lowlevel$(EXECUTABLE_SUFFIX): test_pgocaml_lowlevel.cmo pgocaml.cma
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(OCAMLCLIBS) pgocaml.cma -o $@ $<

test_pgocaml$(EXECUTABLE_SUFFIX): test_pgocaml.cmo pgocaml.cma
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(OCAMLCLIBS) pgocaml.cma -o $@ $<

pgocaml_prof$(EXECUTABLE_SUFFIX): pgocaml_prof.cmx
	ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $<

test_pgocaml.cmo: test_pgocaml.ml pgocaml.cma pa_pgsql.cmo
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(OCAMLCLIBS) -pp "camlp4o $(FOR_P4) ./pa_pgsql.cmo" -c $<

print_test: force
	camlp4o $(FOR_P4) ./pa_pgsql.cmo pr_o.cmo test_pgocaml.ml

#
# Rules for core library.
#

pa_pgsql.cmo: pa_pgsql.ml4
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
	  -pp "camlp4o pa_extend.cmo q_MLast.cmo $(P4_PARAMS) -impl" \
	  -I +camlp4 -c -impl $<

pgocaml.cma: $(OBJS)
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -a -o $@ $^

pgocaml.cmxa: $(XOBJS)
	ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -a -o $@ $^

pgocaml.cmxs: pgocaml.cmxa
	ocamlfind ocamlopt $(OCAMLOPTPACKAGES) -shared -linkall -o $@ $<

pGOCaml_config.ml: pGOCaml_config.ml.in Makefile Makefile.config
	< $< sed -e "s|@DEFAULT_UNIX_DOMAIN_SOCKET_DIR@|$(DEFAULT_UNIX_DOMAIN_SOCKET_DIR)|" > $@

#
# Common rules for building OCaml objects.
#

.mli.cmi:
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCINCS) $(OCAMLCPACKAGES) -c $<
.ml.cmo:
	ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLSYNTAX) $(OCAMLCINCS) $(OCAMLCPACKAGES) -c $<
.ml.cmx:
	ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLSYNTAX) $(OCAMLOPTINCS) $(OCAMLOPTPACKAGES) -c $<

#
# Findlib META file.
#

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

#
# Clean.
#

clean:
	rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.cmxs *.o *.a *.so *~ core .depend META \
	test_pgocaml_lowlevel test_pgocaml pgocaml_prof

#
# Dependencies.
#

depend: .depend

.depend: pGOCaml_config.ml
	rm -f .depend
	ocamlfind ocamldep $(OCAMLSYNTAX) pGOCaml*.ml >$@
	ocamldep pGOCaml*.mli >> $@
	-ocamldep -pp "camlp4o $(FOR_P4) ./pa_pgsql.cmo" >> $@

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

#
# Install.
#

findlib_install:
	ocamlfind install $(PACKAGE) META pgocaml.a pgocaml.cma pgocaml.cmxa pgocaml.cmxs pGOCaml_generic.cm[ix] pGOCaml.cm[ix] pa_pgsql.cmo pGOCaml_generic.mli pGOCaml.mli

reinstall:
	ocamlfind remove $(PACKAGE)
	ocamlfind install $(PACKAGE) META pgocaml.a pgocaml.cma pgocaml.cmxa pGOCaml_generic.cm[ix] pGOCaml.cm[ix] pa_pgsql.cmo pGOCaml_generic.mli pGOCaml.mli

install:
	rm -rf $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
	install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
	install -c -m 0644 *.cmi *.mli *.cmo *.cma *.cmxa *.a META \
	  $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)

install_byte:
	rm -rf $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
	install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
	install -c -m 0644 *.cmi *.mli *.cmo *.cma META \
	  $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)

#
# 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:
	svn list | 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/freeware/pgocaml
	cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
	rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
	ls -l /tmp/dbuild

#
# Developer documentation (in html/ subdirectory).
#

doc:
	rm -rf html
	mkdir html
	-ocamlfind ocamldoc $(OCAMLDOCFLAGS) $(OCAMLSYNTAX) -d html pGOCaml_generic.mli pGOCaml_generic.ml pGOCaml.mli pGOCaml.ml

#
# Miscelaneous.
#

force:

.PHONY:	depend dist check-manifest dpkg doc print_test

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