File: Makefile

package info (click to toggle)
libpgsql-ocaml 20040120-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 164 kB
  • ctags: 304
  • sloc: ml: 911; ansic: 312; makefile: 138
file content (122 lines) | stat: -rw-r--r-- 2,813 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
# Adapt the following line to your installation
POSTGRES_INCLUDE = -I /usr/include/postgresql
POSTGRES_LIB     = -lpq

# another example, when the linker does not find the library
#POSTGRES_PATH    = /usr/local/util/packages/postgresql-7.1.3
#POSTGRES_INCLUDE = -I $(POSTGRES_PATH)/include
#POSTGRES_LIB     = -L$(POSTGRES_PATH)/lib -lpq



# this package
##############
NAME = postgres
PACKAGE_NAME = postgres
LIB = postgres

RELEASE = $(shell cat RELEASE)

# Add -custom to build only statically linked version
#OCAMLMKLIB_OPTS = -custom $(POSTGRES_LIBS)
OCAMLMKLIB_OPTS = $(POSTGRES_LIB) -verbose

INCLUDES = $(POSTGRES_INCLUDE)
ARCHIVE = postgres
CLIB = mlpostgres
OBJECTS = postgres.ml libpq_stub.c
INTERFACES = postgres.mli
DESCRIPTION = Bindings for PostgreSQL
EXTRA_DIST = README LGPL Changes tests

DESTDIR =

default: all

# dependencies
postgres.cmo: postgres.cmi 
postgres.cmx: postgres.cmi 

# generic stuff
###############

OCAMLC = ocamlc
OCAMLOPT = ocamlopt
OCAMLFIND = ocamlfind

ML_OBJS = $(patsubst %.ml,%.cmo, $(filter %.ml, $(OBJECTS)))
ML_XOBJS = $(ML_OBJS:.cmo=.cmx)
C_OBJS  = $(patsubst %.c,%.o, $(filter %.c, $(OBJECTS)))

INSTALL_FILES = *.cmi *.cma *.a *.so META $(INTERFACES)
INSTALL_XFILES = *.cmi *.cma *.cmxa *.a *.so META $(INTERFACES)
DIST_FILES = Makefile RELEASE $(OBJECTS) $(INTERFACES) $(EXTRA_DIST)
LIB_OBJECTS = $(ML_OBJS) $(C_OBJS)
LIB_XOBJECTS = $(ML_XOBJS) $(C_OBJS)

all: META $(INTERFACES:.mli=.cmi) dll$(LIB).so lib$(LIB).a $(LIB).cma
opt: all $(LIB).cmxa

dll$(LIB).so lib$(LIB).a $(LIB).cma: $(LIB_OBJECTS)
	ocamlmklib $(OCAMLMKLIB_OPTS) -o $(LIB) $^

$(LIB).cmxa: $(LIB_XOBJECTS)
	ocamlmklib $(OCAMLMKLIB_OPTS) -o $(LIB) $^

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

.c.o:
	$(OCAMLC) -c $(INCLUDES) $<

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

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

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

.PHONY: clean
clean:
	rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *.so *~ META
	rm -f foo.ld.conf


.PHONY: install
install:
	if [ -f $(LIB).cmxa ]; then \
		$(OCAMLFIND) install -ldconf foo.ld.conf -destdir $(DESTDIR) $(PACKAGE_NAME) $(INSTALL_XFILES); \
	else \
		$(OCAMLFIND) install -ldconf foo.ld.conf -destdir $(DESTDIR) $(PACKAGE_NAME) $(INSTALL_FILES); \
	fi

.PHONY: uninstall
uninstall:
	$(OCAMLFIND) remove $(PACKAGE_NAME)

META: RELEASE
	rm -f META
	echo 'name="$(NAME)"' >> META
	echo 'version="$(RELEASE)"' >> META
	echo 'description="$(DESCRIPTION)"' >> META
	echo 'archive(byte)="$(LIB).cma"' >> META
	echo 'archive(native)="$(LIB).cmxa"' >> META

# for the package maintainer

.PHONY: release
release:
	date +%Y%m%d > RELEASE

DISTDIR = $(NAME)-$(RELEASE)

.PHONY: dist
dist:
	rm -Rf $(DISTDIR)
	mkdir $(DISTDIR)
	(mkdir dists) || true
	cp -R $(DIST_FILES) $(DISTDIR)
	rm -rf $(DISTDIR)/tests/CVS
	tar czf dists/$(DISTDIR).tar.gz $(DISTDIR)
	rm -Rf $(DISTDIR)