Compare job names intelligently, so "job$9" < "job$10".
[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 bin_SCRIPTS = whenjobs
19
20 OCAMLPACKAGES = -package unix,num,camlp4.lib,calendar,rpc -I ../lib
21
22 OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
23 OCAMLOPTFLAGS = $(OCAMLCFLAGS)
24
25 # These should be in alphabetical order. 
26 SOURCES = \
27         libdir.ml \
28         tutorial.ml \
29         whenproto_clnt.ml \
30         whenproto_clnt.mli \
31         whenjobs.ml
32
33 # In dependency order.
34 OBJECTS = \
35         libdir.cmo \
36         tutorial.cmo \
37         whenproto_clnt.cmo \
38         whenjobs.cmo
39
40 libdir.ml: Makefile
41         rm -f $@ $@-t
42         echo 'let libdir = "$(libdir)/$(PACKAGE_NAME)"' > $@-t
43         mv $@-t $@
44
45 whenproto_clnt.ml whenproto_clnt.mli: whenproto.x
46         $(OCAMLRPCGEN) -int int32 -hyper int64 -clnt $<
47
48 whenproto.x: ../lib/whenproto.x
49         ln -f $< $@
50
51 whenjobs: ../lib/whenlib.cma $(OBJECTS)
52         $(OCAMLFIND) ocamlc -custom $(OCAMLCFLAGS) -ccopt -L../lib \
53           -linkpkg whenlib.cma $(OBJECTS) -o $@
54
55 # Rules for all OCaml files.
56 %.cmi: %.mli ../lib/whenlib.cma
57         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
58 %.cmo: %.ml ../lib/whenlib.cma
59         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
60 %.cmx: %.ml ../lib/whenlib.cma
61         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
62
63 SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
64
65 # OCaml dependencies.
66 depend: .depend
67
68 .depend: $(SOURCES)
69         rm -f $@ $@-t
70         $(OCAMLFIND) ocamldep $^ | \
71           $(SED) -e 's/ *$$//' | \
72           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
73           LANG=C sort > $@-t
74         mv $@-t $@
75
76 -include .depend
77
78 # Manual page.
79 man_MANS = whenjobs.1
80
81 whenjobs.1: whenjobs.pod
82         pod2man \
83           -c "Job scheduling" \
84           --release "$(PACKAGE)-$(VERSION)" \
85           --section 1 \
86           --stderr --utf8 \
87           $< > $@
88
89 CLEANFILES = \
90         *.cmi *.cmo *.cmx *.cma *.cmxa *~ \
91         libdir.ml \
92         whenproto.x \
93         whenproto_clnt.ml whenproto_clnt.mli \
94         whenjobs