summaryrefslogtreecommitdiff
path: root/build-aux/Makefile.each.tail/20-libretools.mk
blob: 4398e2cab45f7ea34150a8707c2d1e257fb38eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright (C) 2015-2017  Luke Shumaker
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

ifneq ($(sort $(wildcard $(addprefix $(srcdir)/,$(libretools.src.devtools)))),$(sort $(addprefix $(srcdir)/,$(libretools.src.devtools))))
ifeq ($(wildcard $(devtoolsdir)/),)
$(error config.mk:devtoolsdir points to a non-existant directory: $(devtoolsdir))
endif
endif

# Connect with `files` module ########################################
files.src.gen += $(libretools.src.devtools)
files.out.all += $(filter-out $(files.src),$(libretools.out)) \
                 $(if $(strip $(libretools.pots)),everything.pot)
files.sys.all += $(addprefix $(bindir)/,$(libretools.out.bins)) \
                 $(addprefix $(pkgconfdir)/,$(libretools.out.confs)) \
                 $(addprefix $(pkglibexecdir)/,$(libretools.out.libexecs) $(libretools.out.libs)) \
                 $(addprefix $(docdir)/,$(libretools.out.docs)) \
                 $(addprefix $(mandir)/man1/,$(filter %.1,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man2/,$(filter %.2,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man3/,$(filter %.3,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man4/,$(filter %.4,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man5/,$(filter %.5,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man6/,$(filter %.6,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man7/,$(filter %.7,$(libretools.out.mans))) \
                 $(addprefix $(mandir)/man8/,$(filter %.8,$(libretools.out.mans)))
files.out.int += *.pot *.ugly *.rej *.orig

# Generate rules #####################################################
$(srcdir)/%.in: $(devtoolsdir)/%.in
	cp -T '$<' '$@'
$(srcdir)/%.in: $(devtoolsdir)/lib/%
	cp -T '$<' '$@'

# Build rules ########################################################
_is_executable = $(filter $(libretools.out.bins) $(libretools.out.libexecs),$(@F))

$(outdir)/%: $(srcdir)/%.in
	@echo 'EDIT < $< > $@'; $(libretools.edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@'
$(outdir)/%: $(srcdir)/%.ronn
	ronn --roff $(RONNFLAGS) < '$<' > '$@'
$(outdir)/%.html: $(srcdir)/%.ronn
	ronn --html $(RONNFLAGS) < '$<' > '$@'
$(outdir)/%.pot: $(outdir)/% $(topsrcdir)/src/lib/librexgettext
	$(topsrcdir)/src/lib/librexgettext $(LIBREXGETTEXT_FLAGS) '$<' > '$@'
$(outdir)/%.pot: $(srcdir)/% $(topsrcdir)/src/lib/librexgettext
	$(topsrcdir)/src/lib/librexgettext $(LIBREXGETTEXT_FLAGS) '$<' > '$@'
$(outdir)/everything.pot: $(addprefix $(outdir)/,$(addsuffix .pot,$(libretools.pots)))
	cat $^ | $(libretools.pofmt) > '$@'

# Install rules ######################################################
$(DESTDIR)$(pkgconfdir)/%   : $(outdir)/%  ; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(docdir)/%       : $(outdir)/%  ; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man1/%.1: $(outdir)/%.1; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man2/%.2: $(outdir)/%.2; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man3/%.3: $(outdir)/%.3; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man4/%.4: $(outdir)/%.4; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man5/%.5: $(outdir)/%.5; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man6/%.6: $(outdir)/%.6; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man7/%.7: $(outdir)/%.7; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(mandir)/man8/%.8: $(outdir)/%.8; install -T -Dm644 '$<' '$@'
$(DESTDIR)$(pkglibexecdir)/%: $(outdir)/%  ; $(MKDIR_P) '$(@D)' && cp -T '$<' '$@'
$(DESTDIR)$(bindir)/%       : $(outdir)/%  ; install -T -Dm755 '$<' '$@'
# Repeat the last two rules again with explicit targets because
# otherwise it would try to do src/xbs->/bin/xbs instead of
# src/xbs/xbs->/bin/xbs
ifneq ($(filter $(notdir $(outdir)),$(libretools.out)),)
$(DESTDIR)$(pkglibexecdir)/$(notdir $(outdir)): $(DESTDIR)$(pkglibexecdir)/%: $(outdir)/%  ; $(MKDIR_P) '$(@D)' && cp -T '$<' '$@'
$(DESTDIR)$(bindir)/$(notdir        $(outdir)): $(DESTDIR)$(bindir)/%       : $(outdir)/%  ; install -T -Dm755 '$<' '$@'
endif