Persist variables to file (~/.whenjobs/variables).
[whenjobs.git] / tools / 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 = $(SOURCES) whenjobs.pod
19
20 bin_SCRIPTS = whenjobs
21
22 OCAMLPACKAGES = -package unix,num,camlp4.lib,calendar,rpc -I ../lib
23
24 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
25 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
26
27 # These should be in alphabetical order. 
28 SOURCES = \
29         libdir.ml \
30         tutorial.ml \
31         whenproto_clnt.ml \
32         whenproto_clnt.mli \
33         whenjobs.ml
34
35 # In dependency order.
36 OBJECTS = \
37         libdir.cmo \
38         tutorial.cmo \
39         whenproto_clnt.cmo \
40         whenjobs.cmo
41
42 XOBJECTS = $(OBJECTS:.cmo=.cmx)
43
44 libdir.ml: Makefile
45         rm -f $@ $@-t
46         echo 'let libdir = "$(libdir)/$(PACKAGE_NAME)"' > $@-t
47         mv $@-t $@
48
49 whenproto_clnt.ml whenproto_clnt.mli: whenproto.x
50         $(OCAMLRPCGEN) -int int32 -hyper int64 -clnt $<
51
52 whenproto.x: ../lib/whenproto.x
53         ln -f $< $@
54
55 if HAVE_OCAMLOPT
56 whenjobs: ../lib/whenlib.cmxa $(XOBJECTS)
57         $(OCAMLFIND) opt $(OCAMLCFLAGS) -ccopt -L../lib \
58           -linkpkg whenlib.cmxa $(XOBJECTS) -o $@
59 else
60 whenjobs: ../lib/whenlib.cma $(OBJECTS)
61         $(OCAMLFIND) c -custom $(OCAMLCFLAGS) -ccopt -L../lib \
62           -linkpkg whenlib.cma $(OBJECTS) -o $@
63 endif
64
65 # Rules for all OCaml files.
66 %.cmi: %.mli ../lib/whenlib.cma
67         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
68 %.cmo: %.ml ../lib/whenlib.cma
69         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
70 %.cmx: %.ml ../lib/whenlib.cma
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 # Manual page.
89 man_MANS = whenjobs.1
90
91 whenjobs.1: whenjobs.pod
92         pod2man \
93           -c "Job scheduling" \
94           --release "$(PACKAGE)-$(VERSION)" \
95           --section 1 \
96           --stderr --utf8 \
97           $< > $@
98
99 whenjobs.txt: whenjobs.pod
100         pod2text \
101           --stderr --utf8 \
102           $< > $@
103
104 CLEANFILES = \
105         *.cmi *.cmo *.cmx *.cma *.cmxa *~ \
106         libdir.ml \
107         whenproto.x \
108         whenproto_clnt.ml whenproto_clnt.mli \
109         whenjobs