This repository has been archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
86 lines (80 loc) · 3.41 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
# MagicPO makefile
VERSION=0.4
MYVERSION=$(VERSION)
ifdef DESTDIR
prefix ?= /usr
endif
ifndef prefix
# This little trick ensures that make install will succeed both for a local
# user and for root. It will also succeed for distro installs as long as
# prefix is set by the builder.
prefix=$(shell perl -e 'if($$< == 0 or $$> == 0) { print "/usr" } else { print "$$ENV{HOME}/.local"}')
endif
BINDIR ?= $(prefix)/bin
DATADIR ?= $(prefix)/share
mandir ?= $(prefix)/share/man
# Create the manpage if required
POD2MAN = $(shell [ ! -e "./magicpo.1" ] && echo man)
ifneq ($(POD2MAN), man)
POD2MAN = $(shell [ ! -e "./magicpo.dict.5" ] && echo man)
endif
# Extract the git revision from the log
GITREV=$(shell git log|head|grep commit|perl -pi -e 'chomp; s/.//g if $$i; $$i =1;s/commit\s*//;')
# Compression filter to use (ie. gz, bz2, lzma, xz, Z)
COMPFILTER=bz2
# Install magicpo
install: $(POD2MAN)
mkdir -p "$(DESTDIR)$(BINDIR)"
mkdir -p "$(DESTDIR)$(DATADIR)/magicpo"
install -m755 magicpo -D "$(DESTDIR)$(DATADIR)/magicpo/magicpo"
install -m755 gtk-magicpo -D "$(DESTDIR)$(DATADIR)/magicpo/gtk-magicpo"
ln -sf "$(DATADIR)/magicpo/magicpo" "$(DATADIR)/magicpo/gtk-magicpo" "$(DESTDIR)$(BINDIR)"
cp -rf dictionaries modules "$(DESTDIR)$(DATADIR)/magicpo"
install -m644 magicpo.1 -D "$(DESTDIR)$(mandir)/man1/magicpo.1"
install -m644 magicpo.dict.5 -D "$(DESTDIR)$(mandir)/man5/magicpo.dict.5"
# Uninstall an installed magicpo
uninstall:
rm -f "$(DESTDIR)$(BINDIR)/magicpo" "$(DESTDIR)$(BINDIR)/gtk-magicpo"
rm -rf "$(DESTDIR)$(DATADIR)/magicpo"
# Clean up the tree
clean:
rm -f `find|egrep '~$$'`
rm -f *.po
rm -f *.tmp
rm -f magicpo-$(MYVERSION).tar.$(COMPFILTER) magicpo-gitsnapshot-*.tar.$(COMPFILTER)
rm -rf magicpo-$(MYVERSION) magicpo-$(MYVERSION)-*git
# Verify syntax and run automated tests
test:
@perl -Imodules -c modules/MagicPO/Parser.pm
@perl -Imodules -c modules/MagicPO/DictLoader.pm
@perl -Imodules -c modules/MagicPO/Magic.pm
@perl -Imodules -c modules/MagicPO/TransDB.pm
@perl -c magicpo
@perl -c gtk-magicpo
@perl -c tools/dictlint
@perl -c tools/ReverseDict
@echo
perl -Imodules -mTest::Harness -e 'Test::Harness::runtests(glob("tools/tests/*.t"))'
# Create a manpage from the POD
man:
pod2man --name "magicpo" --center "" --release "MagicPO $(MYVERSION)" ./magicpo ./magicpo.1
pod2man --name "magicpo.dict" --center "" --release "MagicPO dictionary $(MYVERSION)" ./magicpo.dict.pod ./magicpo.dict.5
# Clean up the tree to prepare for distrib
distclean: clean
perl -MFile::Find -e 'use File::Path qw/rmtree/;find(sub { return if $$File::Find::name =~ /\.git/; my $$i = `git stat $$_ 2>&1`; if ($$i =~ /^error.*did.*not.*match/) { if (-d $$_) { print "rmtree: $$File::Find::name\n"; rmtree($$_); } else { print "unlink: $$File::Find::name\n"; unlink($$_); }}},"./");'
# Create the tarball
distrib: distclean test man
mkdir -p magicpo-$(MYVERSION)
cp -r ./`ls|grep -v magicpo-$(MYVERSION)` ./magicpo-$(MYVERSION)
rm -rf `find magicpo-$(MYVERSION) -name \\.git`
tar --use-compress-program=$(COMPFILTER) -cvf magicpo-$(MYVERSION).tar.$(COMPFILTER) ./magicpo-$(MYVERSION)
rm -rf magicpo-$(MYVERSION)
# Create a git snapshot
gitsnapshot:
./tools/SetVersion "$(VERSION)-$(GITREV)git"
-make distrib
mv magicpo-$(VERSION)-$(GITREV)git.tar.$(COMPFILTER) magicpo-gitsnapshot-$(GITREV).tar.$(COMPFILTER)
./tools/SetVersion "$(VERSION)"
# User-facing version of gitsnapshot
gitdistrib: MYVERSION =$(VERSION)-$(GITREV)git
gitdistrib: distrib