-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
126 lines (97 loc) · 3.6 KB
/
Makefile
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
NAME = llgal
ifeq ($(shell [ -d .git ] && echo 1),1)
VERSION = $(shell cat VERSION)+git$(shell date +%Y%m%d).$(shell git show -s --pretty=format:%h)
else
VERSION = $(shell cat VERSION)
endif
DATA_SUBDIR = data
LIB_SUBDIR = lib
PO_SUBDIR = po
DOC_SUBDIR = doc
DESTDIR =
PREFIX = /usr/local
EXEC_PREFIX = $(PREFIX)
BINDIR = $(EXEC_PREFIX)/bin
DATADIR = $(PREFIX)/share
SYSCONFDIR = $(PREFIX)/etc
MANDIR = $(PREFIX)/man
LOCALEDIR = $(DATADIR)/locale
DOCDIR = $(DATADIR)/doc
PERL_INSTALLDIRS =
TARBALL = $(NAME)-$(VERSION)
DEBIAN_TARBALL = $(NAME)_$(VERSION).orig
.PHONY: llgal clean install uninstall tarball
all:: llgal
llgal:: llgal.in VERSION build-lib update-po
sed -e 's!@DATADIR@!$(DESTDIR)$(DATADIR)!g' -e 's!@SYSCONFDIR@!$(DESTDIR)$(SYSCONFDIR)!g' \
-e 's!@LOCALEDIR@!$(DESTDIR)$(LOCALEDIR)!' -e 's!@VERSION@!$(VERSION)!g' \
< llgal.in > llgal
chmod 755 llgal
clean:: clean-lib clean-po
rm -f llgal
install:: install-lib install-po llgal
install -d -m 0755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(DATADIR)/llgal/ $(DESTDIR)$(SYSCONFDIR)/llgal/
install -m 0755 llgal $(DESTDIR)$(BINDIR)/llgal
install -m 0644 $(DATA_SUBDIR)/* $(DESTDIR)$(DATADIR)/llgal/
uninstall:: uninstall-lib uninstall-po
rm $(DESTDIR)$(BINDIR)/llgal
rm -rf $(DESTDIR)$(DATADIR)/llgal/
rmdir $(DESTDIR)$(SYSCONFDIR)/llgal/ || true
tarball::
mkdir /tmp/$(TARBALL)/
cp llgal.in /tmp/$(TARBALL)
cp llgal.1 llgalrc.5 /tmp/$(TARBALL)
cp Makefile /tmp/$(TARBALL)
cp Changes /tmp/$(TARBALL)
cp COPYING README VERSION /tmp/$(TARBALL)
cp -a $(DOC_SUBDIR)/ /tmp/$(TARBALL)
cp -a $(DATA_SUBDIR)/ /tmp/$(TARBALL)
cp -a $(LIB_SUBDIR) /tmp/$(TARBALL)
mkdir /tmp/$(TARBALL)/$(PO_SUBDIR)/
cp $(PO_SUBDIR)/Makefile /tmp/$(TARBALL)/$(PO_SUBDIR)/
cp $(PO_SUBDIR)/*.po /tmp/$(TARBALL)/$(PO_SUBDIR)/
cd /tmp && tar cfz $(DEBIAN_TARBALL).tar.gz $(TARBALL)
cd /tmp && tar cfj $(TARBALL).tar.bz2 $(TARBALL)
mv /tmp/$(DEBIAN_TARBALL).tar.gz /tmp/$(TARBALL).tar.bz2 ..
rm -rf /tmp/$(TARBALL)
# Perl modules
.PHONY: build-lib clean-lib install-lib uninstall-lib prepare-lib
$(LIB_SUBDIR)/Makefile.PL: $(LIB_SUBDIR)/Makefile.PL.in VERSION
sed -e 's!@VERSION@!$(VERSION)!g' < $(LIB_SUBDIR)/Makefile.PL.in > $(LIB_SUBDIR)/Makefile.PL
$(LIB_SUBDIR)/Makefile: $(LIB_SUBDIR)/Makefile.PL
cd $(LIB_SUBDIR) && perl Makefile.PL INSTALLDIRS=$(PERL_INSTALLDIRS)
prepare-lib: $(LIB_SUBDIR)/Makefile
build-lib: prepare-lib
$(MAKE) -C $(LIB_SUBDIR)
install-lib: prepare-lib
$(MAKE) -C $(LIB_SUBDIR) install PREFIX= SITEPREFIX=$(PREFIX) PERLPREFIX=$(PREFIX) VENDORPREFIX=$(PREFIX)
clean-lib: prepare-lib
$(MAKE) -C $(LIB_SUBDIR) distclean
rm $(LIB_SUBDIR)/Makefile.PL
uninstall-lib: prepare-lib
$(MAKE) -C $(LIB_SUBDIR) uninstall
# PO files
.PHONY: update-po clean-po install-po uninstall-po
update-po:
$(MAKE) -C $(PO_SUBDIR) update
clean-po:
$(MAKE) -C $(PO_SUBDIR) clean
install-po:
$(MAKE) -C $(PO_SUBDIR) install LOCALEDIR=$(DESTDIR)$(LOCALEDIR)
uninstall-po:
$(MAKE) -C $(PO_SUBDIR) uninstall LOCALEDIR=$(DESTDIR)$(LOCALEDIR)
# Install the doc, only called on-demand by distrib-specific Makefile
.PHONY: install-doc uninstall-doc
install-doc:
$(MAKE) -C $(DOC_SUBDIR) install DOCDIR=$(DESTDIR)$(DOCDIR)
uninstall-doc:
$(MAKE) -C $(DOC_SUBDIR) uninstall DOCDIR=$(DESTDIR)$(DOCDIR)
# Install the manpages, only called on-demand by distrib-specific Makefile
.PHONY: install-man uninstall-man
install-man::
install -d -m 0755 $(DESTDIR)$(MANDIR)/man1/ $(DESTDIR)$(MANDIR)/man5/
install -m 0644 llgal.1 $(DESTDIR)$(MANDIR)/man1/
install -m 0644 llgalrc.5 $(DESTDIR)$(MANDIR)/man5/
uninstall-man::
rm $(DESTDIR)$(MANDIR)/man1/llgal.1
rm $(DESTDIR)$(MANDIR)/man5/llgalrc.5