-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
145 lines (117 loc) · 3.48 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#
# Copyright (c) 2019-2021 Grant Erickson
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Description:
# This file is the makefile for a script that synchronizes the
# music-only portion of a user's iTunes and/or Music library to a
# locally-mounted, remote file share using rsync.
#
# The remote file share is typically a NAS volume hosted by
# a product such as QNAP or Synology, accessible by Sonos.
#
#
# This Package
#
PACKAGE := nas-sonos-itunes-sync
#
# Build directories
#
builddir := .
top_builddir := .
abs_builddir := $(CURDIR)
abs_top_builddir := $(abspath $(top_builddir))
#
# Source directories
#
srcdir := .
top_srcdir := .
abs_srcdir := $(CURDIR)
abs_top_srcdir := $(abspath $(top_srcdir))
#
# Installation Directories
#
DESTDIR ?=
prefix = ${HOME}
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
#
# Programs
#
CAT = cat
CHMOD = chmod
CP = cp
MKDIR = mkdir
INSTALL = install
RM = rm
SED = sed
#
# Verbosity
#
V ?=
DEFAULT_VERBOSITY ?= 0
AT := @
VERBOSE = $(VERBOSE_$(V))
VERBOSE_ = $(VERBOSE_$(DEFAULT_VERBOSITY))
VERBOSE_0 = $(AT)
VERBOSE_1 =
_PROGRESS := printf " %-13s %s\n"
PROGRESS := $(AT)$(_PROGRESS)
VERBOSE_PROGRESS = $(VERBOSE_PROGRESS_$(V))
VERBOSE_PROGRESS_ = $(VERBOSE_PROGRESS_$(DEFAULT_VERBOSITY))
VERBOSE_PROGRESS_0 = $(PROGRESS)
VERBOSE_PROGRESS_1 = $(AT)true
#
# Version
#
PACKAGE_VERSION = $(shell $(CAT) $(top_builddir)/.default-version)
VERSION = $(PACKAGE_VERSION)
define copy-target
$(VERBOSE_PROGRESS) "CP" "$(@)"
$(VERBOSE)$(CP) $(<) $(@)
endef # copy-target
define create-directory-target
$(VERBOSE_PROGRESS) "MKDIR" "$(@)"
$(VERBOSE)$(MKDIR) -p $(@)
endef # create-directory-target
define install-target
$(VERBOSE_PROGRESS) "INSTALL" "$(@)"
$(VERBOSE)$(INSTALL) -c $(<) $(@)
endef # install-target
SCRIPT = nas-sonos-itunes-sync
all: $(SCRIPT)
$(SCRIPT): $(SCRIPT).sh
$(VERBOSE_PROGRESS) "SED" "$(@)"
$(VERBOSE)$(SED) -e \
"s,@PACKAGE_VERSION@,${PACKAGE_VERSION},g" \
< "$(<)" \
> "$(@)"
$(VERBOSE_PROGRESS) "CHMOD" "$(@)"
$(VERBOSE)$(CHMOD) 775 $(@)
$(DESTDIR):
$(create-directory-target)
$(DESTDIR)$(bindir): | $(DESTDIR)
$(create-directory-target)
$(DESTDIR)$(bindir)/$(SCRIPT): $(SCRIPT) | $(DESTDIR)$(bindir)
$(install-target)
install: $(DESTDIR)$(bindir)/$(SCRIPT)
uninstall:
$(VERBOSE_PROGRESS) "RM" "$(DESTDIR)$(bindir)/$(SCRIPT)"
$(VERBOSE)$(RM) -f $(DESTDIR)$(bindir)/$(SCRIPT)
dist: $(DIST_TARGETS)
clean:
-$(VERBOSE)$(RM) -f $(SCRIPT)
-$(VERBOSE)$(RM) -f *~ "#"*