build: Get 'make install' working.
[goaljobs.git] / Makefile.am
1 # goaljobs
2 # Copyright (C) 2013 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 include common-rules.mk
19
20 ACLOCAL_AMFLAGS = -I m4
21
22 EXTRA_DIST = \
23         COPYING \
24         goaljobs \
25         goaljobs.spec \
26         goaljobs.spec.in \
27         META.in \
28         NOTES \
29         README \
30         $(sources) \
31         pa_goal.ml
32
33 SUBDIRS = . examples tests
34
35 sources = \
36         goaljobs.ml \
37         goaljobs.mli
38
39 bin_SCRIPTS = goaljobs
40
41 # These targets are noinst because we use a custom install hook to
42 # install them, and are _SCRIPTS because automake doesn't know how to
43 # compile OCaml code.
44 noinst_SCRIPTS = goaljobs.cma goaljobs.cmxa pa_goal.cmo
45
46 # Library.
47 goaljobs.cma: goaljobs.cmo
48         $(OCAMLFIND) ocamlc -a -o $@ $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $<
49
50 goaljobs.cmxa: goaljobs.cmx
51         $(OCAMLFIND) ocamlopt -a -o $@ $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $<
52
53 # Preprocessor for goaljobs scripts.
54 pa_goal.cmo: pa_goal.ml
55         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package camlp4.lib -linkpkg \
56             -pp $(CAMLP4OF) -c $< -o $@
57
58 # Install.
59 install-data-hook:
60         mkdir -p $(DESTDIR)$(OCAMLLIB)
61         $(OCAMLFIND) install \
62             -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
63             goaljobs \
64             META goaljobs.cma goaljobs.cmxa pa_goal.cmo *.cmi $(srcdir)/*.mli
65         rm $(DESTDIR)$(OCAMLLIB)/goaljobs/pa_goal.cmi
66
67 # Dependencies.
68 depend: .depend
69
70 .depend: $(sources)
71         rm -f $@ $@-t
72         $(OCAMLFIND) ocamldep -I $(abs_srcdir) $^ | \
73           $(SED) 's/ *$$//' | \
74           $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
75           $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
76           sort > $@-t
77         mv $@-t $@
78
79 -include .depend
80
81 rpm: dist
82         rpmbuild -ta $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
83
84 # License check.
85 licensecheck:
86         licensecheck $$(git ls-files)