1421da386177246777d5a64cfd20299338768d99
[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 $(CMI_FILES)
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         config.mli \
32         whenfile.ml \
33         whenfile.mli \
34         whenlock.ml \
35         whenlock.mli \
36         whenproto_aux.ml \
37         whenproto_aux.mli \
38         whenutils.mli \
39         whenutils.ml
40
41 CMI_FILES = \
42         config.cmi \
43         whenfile.cmi \
44         whenlock.cmi \
45         whenproto_aux.cmi \
46         whenutils.cmi
47
48 # In dependency order.
49 OBJECTS = \
50         config.cmo \
51         whenproto_aux.cmo \
52         whenutils.cmo \
53         whenfile.cmo \
54         whenlock.cmo
55
56 # Library.
57 noinst_LIBRARIES = liblibrary.a
58 liblibrary_a_SOURCES = flock.c
59 liblibrary_a_CFLAGS = -I$(shell $(OCAMLC) -where)
60
61 whenlib.cma: $(OBJECTS) liblibrary.a
62         $(OCAMLFIND) c -a $(OCAMLCFLAGS) $(OBJECTS) -cclib -llibrary -o $@
63
64 whenproto_aux.ml whenproto_aux.mli: whenproto.x
65         $(OCAMLRPCGEN) -int int32 -hyper int64 -aux $<
66
67 # Preprocessor for whenjobs files.
68 # Note that we intentionally don't want this to depend on any
69 # libraries except for camlp4.lib.
70 pa_when.cmo: pa_when.ml
71         $(OCAMLFIND) c -g -warn-error CDEFLMPSUVYZX \
72           -package camlp4.lib -linkpkg \
73           -pp $(CAMLP4OF) -c $< -o $@
74
75 # Rules for all OCaml files.
76 %.cmi: %.mli
77         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
78 %.cmo: %.ml
79         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
80 %.cmx: %.ml
81         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
82
83 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
84
85 # OCaml dependencies.
86 depend: .depend
87
88 .depend: $(SOURCES)
89         rm -f $@ $@-t
90         $(OCAMLFIND) ocamldep $^ | \
91           $(SED) -e 's/ *$$//' | \
92           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
93           LANG=C sort > $@-t
94         mv $@-t $@
95
96 -include .depend
97
98 CLEANFILES = \
99         *.cmi *.cmo *.cmx *.cma *.cmxa *~ \
100         config.ml whenproto_aux.ml whenproto_aux.mli