1#  Perl Audio Converter
2#
3#  Copyright (C) 2005-2021 Philip Lyons (vorzox@gmail.com)
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#    This program is distributed in the hope that it will be useful,
11#    but WITHOUT ANY WARRANTY; without even the implied warranty of
12#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13#    GNU General Public License for more details.
14#
15#    You should have received a copy of the GNU General Public License
16#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18PACKAGE_NAME     = @PACKAGE_NAME@
19PACKAGE_VERSION  = @PACKAGE_VERSION@
20
21ACLOCAL_M4 = ./aclocal.m4
22
23#
24# Modules & Documentation
25#
26
27DOCS = INSTALL README AUTHORS TODO NEWS ChangeLog COPYING
28
29LANG_MODS = po/*
30EXTRAS    = extra/*
31
32#
33# Plugin directories
34#
35
36NAUTILUS_PLUGIN_DIR = plugins/gnome/nautilus
37NEMO_PLUGIN_DIR     = plugins/gnome/nemo
38KDE_PLUGIN_DIR      = plugins/kde
39
40#
41# Default KDE directory
42#
43
44DESTDIR =
45KDEDIR  = /usr
46GNOMEDIR = /usr
47
48#
49# Target KDE directories
50#
51
52KDE_INSTALL_DIR      = $(DESTDIR)$(KDEDIR)/share/kde4/services
53NAUTILUS_INSTALL_DIR = $(DESTDIR)$(HOME)/.local/share/nautilus/scripts
54NEMO_INSTALL_DIR     = $(DESTDIR)$(GNOMEDIR)/share/nemo/actions
55ICON_DIR             = $(DESTDIR)$(GNOMEDIR)/share/icons
56
57#
58# Compiler tools definitions...
59#
60
61POD2MAN = @POD2MAN@
62POD2HTML = @POD2HTML@
63GZIP = @GZIP@
64RM = @RM@ -f
65SHELL = /bin/sh
66
67#
68# Configuration files directories and other
69#
70CONF_DIR = $(DESTDIR)$(sysconfdir)/$(PACKAGE_NAME)
71PO_DIR   = $(DESTDIR)$(pkgdatadir)/locale
72MOD_DIR  = $(CONF_DIR)/modules
73DOC_DIR  = $(DESTDIR)$(docdir)
74MAN_DIR  = $(DESTDIR)$(mandir)/man1
75EXTRA_DIR = $(CONF_DIR)/extra
76
77edit = sed \
78	-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
79	-e 's|@sysconfdir[@]|$(sysconfdir)|g'
80
81all : pacpl.1.gz
82
83pacpl: pacpl.in Makefile
84	rm -f $@ $@.tmp
85	$(edit) '$@.in' >$@.tmp
86	mv $@.tmp $@
87	chmod +x $@
88
89pacpl.1.gz : pacpl
90	$(POD2MAN) $< |	$(GZIP) -9 > $@
91	touch $@
92
93install: all main install-plugins
94
95main:
96	$(INSTALL) -d $(DESTDIR)$(bindir)
97	$(INSTALL) -d $(CONF_DIR)
98	$(INSTALL) -d $(PO_DIR)
99	$(INSTALL) -d $(MOD_DIR)
100	$(INSTALL) -d $(MAN_DIR)
101	$(INSTALL) -d $(DOC_DIR)
102	$(INSTALL) -d $(EXTRA_DIR)
103
104	$(INSTALL) pacpl $(DESTDIR)$(bindir)
105	$(INSTALL_DATA) pacpl.conf codecs.conf pacpl.png $(CONF_DIR)
106	$(INSTALL_DATA) $(LANG_MODS) $(PO_DIR)
107	$(INSTALL_DATA) pacpl.1.gz $(MAN_DIR)
108	$(INSTALL_DATA) $(DOCS) $(DOC_DIR)
109	$(INSTALL_DATA) $(EXTRAS) $(EXTRA_DIR)
110
111install-plugins:
112
113if INSTALL_KDE
114	$(INSTALL) -d $(KDE_INSTALL_DIR)
115	$(INSTALL) $(KDE_PLUGIN_DIR)/PACPL-Konvert $(DESTDIR)$(bindir)
116	$(INSTALL_DATA) $(KDE_PLUGIN_DIR)/pacpl.desktop $(KDE_INSTALL_DIR)
117	sed -i 's/KDE_DIR = 0/KDE_DIR = 1/' $(CONF_DIR)/pacpl.conf
118	sed -i 's/KDE_OPTS = 0/KDE_OPTS = 1/' $(CONF_DIR)/pacpl.conf
119endif
120
121if INSTALL_NAUTILUS
122	$(INSTALL) -d $(NAUTILUS_INSTALL_DIR)
123	$(INSTALL) $(NAUTILUS_PLUGIN_DIR)/PACPL-Convert $(NAUTILUS_INSTALL_DIR)
124endif
125
126if INSTALL_NEMO
127	$(INSTALL) -d $(NEMO_INSTALL_DIR)
128	$(INSTALL) $(NEMO_PLUGIN_DIR)/PACPL-Convert $(NEMO_INSTALL_DIR)
129	$(INSTALL_DATA) $(NEMO_PLUGIN_DIR)/pacpl.nemo_action $(NEMO_INSTALL_DIR)
130	$(INSTALL_DATA) $(NEMO_PLUGIN_DIR)/pacpl.png $(ICON_DIR)
131endif
132
133if ENABLE_GNOME_NAUTILUS
134	sed -i 's/ZEN_DIR = 0/ZEN_DIR = 1/' $(CONF_DIR)/pacpl.conf
135	sed -i 's/ZEN_OPTS = 0/ZEN_OPTS = 1/' $(CONF_DIR)/pacpl.conf
136endif
137
138if ENABLE_GNOME_NEMO
139	sed -i 's/ZEN_DIR = 0/ZEN_DIR = 1/' $(CONF_DIR)/pacpl.conf
140	sed -i 's/ZEN_OPTS = 0/ZEN_OPTS = 1/' $(CONF_DIR)/pacpl.conf
141endif
142
143clean:
144	$(RM) pacpl.1.gz
145
146distclean: clean
147	$(RM) config.log
148	$(RM) config.status
149	$(RM) Makefile
150	$(RM) pacpl
151	find . -name '*~' -exec $(RM) '{}' \;
152
153uninstall: uninstall-plugins
154	$(RM) $(DESTDIR)$(bindir)/pacpl
155	$(RM) $(MAN_DIR)/pacpl.1.gz
156	$(RM) -r $(CONF_DIR)/pacpl
157	$(RM) -r $(DOC_DIR)/pacpl
158	$(RM) -r $(DESTDIR)$(pkgdatadir)
159
160uninstall-plugins:
161if INSTALL_KDE
162	$(RM) $(KDE_INSTALL_DIR)/pacpl.desktop
163	$(RM) $(DESTDIR)$(bindir)/PACPL-Konvert
164endif
165
166if INSTALL_NAUTILUS
167	$(RM) $(NAUTILUS_INSTALL_DIR)/PACPL-Convert
168endif
169
170if INSTALL_NEMO
171	$(RM) $(NEMO_INSTALL_DIR)/PACPL-Convert
172	$(RM) $(NEMO_INSTALL_DIR)/pacpl.nemo_action
173	$(RM) $(ICON_DIR)/pacpl.png
174endif
175