3d72b240b21197e779a8878f29509b54f314c8c7
[whenjobs.git] / lib / Makefile.am
1 # whenjobs
2 # Copyright (C) 2012 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program 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
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 EXTRA_DIST = whenproto.x pa_when.ml $(SOURCES)
19
20 libwhenjobsdir = $(libdir)/$(PACKAGE_NAME)
21 libwhenjobs_SCRIPTS = whenlib.cma pa_when.cmo
22
23 OCAMLPACKAGES = -package unix,num,camlp4.lib,calendar,rpc
24
25 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
26 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
27
28 # These should be in alphabetical order. 
29 SOURCES = \
30         config.ml \
31         whenfile.ml \
32         whenfile.mli \
33         whenlock.ml \
34         whenlock.mli \
35         whenproto_aux.ml \
36         whenproto_aux.mli \
37         whenutils.mli \
38         whenutils.ml
39
40 # In dependency order.
41 OBJECTS = \
42         config.cmo \
43         whenproto_aux.cmo \
44         whenutils.cmo \
45         whenfile.cmo \
46         whenlock.cmo
47
48 # Library.
49 noinst_LIBRARIES = liblibrary.a
50 liblibrary_a_SOURCES = flock.c
51 liblibrary_a_CFLAGS = -I$(shell $(OCAMLC) -where)
52
53 whenlib.cma: $(OBJECTS) liblibrary.a
54         $(OCAMLFIND) c -a $(OCAMLCFLAGS) $(OBJECTS) -cclib -llibrary -o $@
55
56 whenproto_aux.ml whenproto_aux.mli: whenproto.x
57         $(OCAMLRPCGEN) -int int32 -hyper int64 -aux $<
58
59 # Preprocessor for whenjobs files.
60 # Note that we intentionally don't want this to depend on any
61 # libraries except for camlp4.lib.
62 pa_when.cmo: pa_when.ml
63         $(OCAMLFIND) c -g -warn-error CDEFLMPSUVYZX \
64           -package camlp4.lib -linkpkg \
65           -pp $(CAMLP4OF) -c $< -o $@
66
67 # Rules for all OCaml files.
68 %.cmi: %.mli
69         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
70 %.cmo: %.ml
71         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
72 %.cmx: %.ml
73         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
74
75 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
76
77 # OCaml dependencies.
78 depend: .depend
79
80 .depend: $(SOURCES)
81         rm -f $@ $@-t
82         $(OCAMLFIND) ocamldep $^ | \
83           $(SED) -e 's/ *$$//' | \
84           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
85           LANG=C sort > $@-t
86         mv $@-t $@
87
88 -include .depend
89
90 CLEANFILES = \
91         *.cmi *.cmo *.cmx *.cma *.cmxa *~ \
92         config.ml whenproto_aux.ml whenproto_aux.mli