747f074ad1770145674a28f08ea384fe2ea67720
[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 if HAVE_OCAMLOPT
24 libwhenjobs_SCRIPTS += whenlib.cmxa
25 endif
26
27 OCAMLPACKAGES = -package unix,num,camlp4.lib,calendar,rpc
28
29 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
30 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
31
32 # These should be in alphabetical order. 
33 SOURCES = \
34         config.ml \
35         config.mli \
36         whenexpr.ml \
37         whenexpr.mli \
38         whenfile.ml \
39         whenfile.mli \
40         whenlock.ml \
41         whenlock.mli \
42         whenproto_aux.ml \
43         whenproto_aux.mli \
44         whenstate.ml \
45         whenstate.mli \
46         whentools.ml \
47         whentools.mli \
48         whenutils.ml \
49         whenutils.mli
50
51 # In alphabetical order.
52 CMI_FILES = \
53         config.cmi \
54         whenexpr.cmi \
55         whenfile.cmi \
56         whenlock.cmi \
57         whenproto_aux.cmi \
58         whenstate.cmi \
59         whentools.cmi \
60         whenutils.cmi
61
62 # In dependency order.
63 OBJECTS = \
64         config.cmo \
65         whenproto_aux.cmo \
66         whenutils.cmo \
67         whenexpr.cmo \
68         whenstate.cmo \
69         whenfile.cmo \
70         whentools.cmo \
71         whenlock.cmo
72
73 XOBJECTS = $(OBJECTS:.cmo=.cmx)
74
75 # Library.
76 noinst_LIBRARIES = liblibrary.a
77 liblibrary_a_SOURCES = flock.c
78 liblibrary_a_CFLAGS = -I$(shell $(OCAMLC) -where)
79
80 whenlib.cma: $(OBJECTS) liblibrary.a
81         $(OCAMLFIND) c -a $(OCAMLCFLAGS) $(OBJECTS) -cclib -llibrary -o $@
82
83 whenlib.cmxa: $(XOBJECTS) liblibrary.a
84         $(OCAMLFIND) opt -a $(OCAMLOPTFLAGS) $(XOBJECTS) -cclib -llibrary -o $@
85
86 whenproto_aux.ml whenproto_aux.mli: whenproto.x
87         $(OCAMLRPCGEN) -int int32 -hyper int64 -aux $<
88
89 # Preprocessor for whenjobs files.
90 # Note that we intentionally don't want this to depend on any
91 # libraries except for camlp4.lib.
92 pa_when.cmo: pa_when.ml
93         $(OCAMLFIND) c -g -warn-error CDEFLMPSUVYZX \
94           -package camlp4.lib -linkpkg \
95           -pp $(CAMLP4OF) -c $< -o $@
96
97 # Rules for all OCaml files.
98 %.cmi: %.mli
99         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
100 %.cmo: %.ml
101         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
102 %.cmx: %.ml
103         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
104
105 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
106
107 # OCaml dependencies.
108 depend: .depend
109
110 .depend: $(SOURCES)
111         rm -f $@ $@-t
112         $(OCAMLFIND) ocamldep $^ | \
113           $(SED) -e 's/ *$$//' | \
114           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
115           LANG=C sort > $@-t
116         mv $@-t $@
117
118 -include .depend
119
120 CLEANFILES = \
121         *.cmi *.cmo *.cmx *.cma *.cmxa *~ \
122         config.ml whenproto_aux.ml whenproto_aux.mli