Better hashbang when perl is not in /usr/bin
[clawsker.git] / Makefile
1 #
2 # Clawsker Makefile
3 # Copyright 2007-2018 Ricardo Mones <ricardo@mones.org>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # See COPYING file for license details.
11 #
12
13 NAME = clawsker
14 VERSION ?= 1.3.1
15 PREFIX ?= /usr/local
16 BINDIR = ${PREFIX}/bin
17 DATADIR = ${PREFIX}/share
18 LIBDIR = ${PREFIX}/lib/${NAME}
19 MANDIR = ${DATADIR}/man
20 MAN1DIR = ${MANDIR}/man1
21 APPSDIR = ${DATADIR}/applications
22 THEMEDIR = ${DATADIR}/icons/hicolor
23 ICONRES = 48 64 128
24
25 all: build
26
27 build: ${NAME}.1
28         -mkdir build
29         perl -MConfig -p -e'1..1 and s/.*/$$Config{startperl}/;' \
30                 -e's,\@PREFIX\@,${PREFIX},;' \
31                 -e's,\@LIBDIR\@,${LIBDIR},;' \
32                 -e's,\@VERSION\@,${VERSION},;' \
33                 -e's,\@DATADIR\@,${DATADIR},' ${NAME} > build/${NAME}
34         cp -p $< build/$<
35         ${MAKE} -C po build
36
37 ${NAME}.1: ${NAME}.pod
38         pod2man --release ${VERSION} -c '' $< > $@
39
40 install: all install-dirs install-icons
41         install -m 0755 build/${NAME} ${DESTDIR}${BINDIR}
42         install -m 0644 build/${NAME}.1 ${DESTDIR}${MAN1DIR}
43         install -m 0644 ${NAME}.desktop ${DESTDIR}${APPSDIR}
44         ${MAKE} -C po install
45
46 install-dirs: install-icons-dirs
47         install -d ${DESTDIR}${BINDIR}
48         install -d ${DESTDIR}${MAN1DIR}
49         install -d ${DESTDIR}${APPSDIR}
50         ${MAKE} -C po install-dirs
51
52 install-icons-dirs:
53         install -d ${DESTDIR}${THEMEDIR}
54         for res in ${ICONRES}; do \
55                 install -d ${DESTDIR}${THEMEDIR}/$${res}x$${res}/apps; \
56         done
57
58 install-icons: install-icons-dirs
59         for res in ${ICONRES}; do \
60                 install -m 0644 icons/${NAME}-$${res}.png ${DESTDIR}${THEMEDIR}/$${res}x$${res}/apps/${NAME}.png; \
61         done
62
63 uninstall-icons:
64         for res in ${ICONRES}; do \
65                 rm -f ${DESTDIR}${THEMEDIR}/$${res}x$${res}/apps/${NAME}.png; \
66         done
67
68 uninstall: uninstall-icons
69         rm -f ${DESTDIR}${BINDIR}/${NAME}
70         rm -f ${DESTDIR}${MAN1DIR}/${NAME}.1
71         rm -f ${DESTDIR}${APPSDIR}/${NAME}.desktop
72         ${MAKE} -C po uninstall
73
74 dist:
75         rm -rf ${NAME}-${VERSION}
76         mkdir ${NAME}-${VERSION}
77         cp -p AUTHORS ChangeLog.old ${NAME} ${NAME}.pod ${NAME}.desktop \
78                 COPYING Makefile NEWS README ${NAME}-${VERSION}
79         mkdir ${NAME}-${VERSION}/po
80         cp -p po/*.po po/*.pot po/Makefile po/POTFILES po/README po/STATUS \
81                 ${NAME}-${VERSION}/po
82         mkdir ${NAME}-${VERSION}/po/unmaint
83         cp -p po/unmaint/*.po ${NAME}-${VERSION}/po/unmaint
84         mkdir ${NAME}-${VERSION}/icons
85         cp -p icons/*.xcf icons/*.png ${NAME}-${VERSION}/icons
86         mkdir ${NAME}-${VERSION}/t
87         cp -p t/*.t ${NAME}-${VERSION}/t
88         tar cJf ${NAME}-${VERSION}.tar.xz ${NAME}-${VERSION} \
89                 && rm -rf ${NAME}-${VERSION}
90
91 clean-build:
92         rm -f ${NAME}.1
93         rm -rf build
94
95 clean: clean-build
96         rm -f *~
97         ${MAKE} -C po clean
98
99 test-setup:
100         @test -h t/Clawsker.pm || ( cd t/ && ln -s ../clawsker Clawsker.pm )
101
102 test: test-setup
103         @env DISPLAY= prove -It
104
105 .PHONY: all build install install-dirs install-icons-dirs install-icons
106 .PHONY: uninstall uninstall-icons clean clean-build dist
107 .PHONY: test-setup test