pa_when does not need and shouldn't depend on whenlib.cma
[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 libwhenjobsdir = $(libdir)/$(PACKAGE_NAME)
19 libwhenjobs_SCRIPTS = whenlib.cma pa_when.cmo
20
21 OCAMLPACKAGES = -package unix,num,camlp4.lib,calendar,rpc
22
23 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
24 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
25
26 # These should be in alphabetical order. 
27 SOURCES = \
28         config.ml \
29         whenfile.mli \
30         whenfile.ml \
31         whenlock.ml \
32         whenlock.mli \
33         whenproto_aux.ml \
34         whenproto_aux.mli \
35         whenutils.mli \
36         whenutils.ml
37
38 # In dependency order.
39 OBJECTS = \
40         config.cmo \
41         whenproto_aux.cmo \
42         whenutils.cmo \
43         whenfile.cmo \
44         whenlock.cmo
45
46 # Library.
47 noinst_LIBRARIES = liblibrary.a
48 liblibrary_a_SOURCES = flock.c
49 liblibrary_a_CFLAGS = -I$(shell $(OCAMLC) -where)
50
51 whenlib.cma: $(OBJECTS) liblibrary.a
52         $(OCAMLFIND) c -a $(OCAMLCFLAGS) $(OBJECTS) -cclib -llibrary -o $@
53
54 whenproto_aux.ml whenproto_aux.mli: whenproto.x
55         $(OCAMLRPCGEN) -int int32 -hyper int64 -aux $<
56
57 # Preprocessor for whenjobs files.
58 # Note that we intentionally don't want this to depend on any
59 # libraries except for camlp4.lib.
60 pa_when.cmo: pa_when.ml
61         $(OCAMLFIND) c -g -warn-error CDEFLMPSUVYZX \
62           -package camlp4.lib -linkpkg \
63           -pp $(CAMLP4OF) -c $< -o $@
64
65 # Rules for all OCaml files.
66 %.cmi: %.mli
67         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
68 %.cmo: %.ml
69         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
70 %.cmx: %.ml
71         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
72
73 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
74
75 # OCaml dependencies.
76 depend: .depend
77
78 .depend: $(SOURCES)
79         rm -f $@ $@-t
80         $(OCAMLFIND) ocamldep $^ | \
81           $(SED) -e 's/ *$$//' | \
82           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
83           LANG=C sort > $@-t
84         mv $@-t $@
85
86 -include .depend
87
88 CLEANFILES = \
89         *.cmi *.cmo *.cmx *.cma *.cmxa *~ \
90         config.ml whenproto_aux.ml whenproto_aux.mli