-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
266 lines (196 loc) · 7.84 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
BEE_VERSION = 1.2.14
CC=gcc
CFLAGS=-Wall -g
LDFLAGS=
PREFIX = /usr
EPREFIX = ${PREFIX}
SBINDIR = ${EPREFIX}/sbin
BINDIR = ${EPREFIX}/bin
LIBDIR = ${EPREFIX}/lib
LIBEXECDIR = ${EPREFIX}/libexec
DATADIR = ${PREFIX}/share
MANDIR = ${DATADIR}/man
SYSCONFDIR = ${PREFIX}/etc
# set sysconfdir /etc if prefix /usr || /usr/local
ifneq (, $(filter /usr /usr/local, ${PREFIX}))
SYSCONFDIR = /etc
endif
# strip /bee from LIBEXECDIR if set
ifeq ($(notdir ${LIBEXECDIR}),bee)
override LIBEXECDIR := $(patsubst %/,%,$(dir ${LIBEXECDIR}))
endif
# default config directory
DEFCONFDIR=${SYSCONFDIR}/default
DESTDIR=
quiet-command = $(if ${V},${1},$(if ${2},@echo ${2} && ${1}, @${1}))
quiet-install = $(call quiet-command,install -m ${1} ${2} ${3},"INSTALL ${3}")
quiet-installdir = $(call quiet-command,install -m ${1} -d ${2},"MKDIR ${2}")
sed-rules = -e 's,@PREFIX@,${PREFIX},g' \
-e 's,@EPREFIX@,${EPREFIX},g' \
-e 's,@BINDIR@,${BINDIR},g' \
-e 's,@SBINDIR@,${SBINDIR},g' \
-e 's,@LIBDIR@,${LIBDIR},g' \
-e 's,@SYSCONFDIR@,${SYSCONFDIR},g' \
-e 's,@DEFCONFDIR@,${DEFCONFDIR},g' \
-e 's,@LIBEXECDIR@,${LIBEXECDIR},g' \
-e 's,@BEE_VERSION@,${BEE_VERSION},g' \
-e 's,@DATADIR@,${DATADIR},g'
PROGRAMS_C+=beecut
PROGRAMS_C+=beeflock
PROGRAMS_C+=beegetopt
PROGRAMS_C+=beesep
PROGRAMS_C+=beesort
PROGRAMS_C+=beeuniq
PROGRAMS_C+=beeversion
PROGRAMS_SHELL+=bee
PROGRAMS_SHELL+=beefind
PROGRAMS_SHELL+=beesh
HELPER_BEE_SHELL+=bee-cache
HELPER_BEE_SHELL+=bee-check
HELPER_BEE_SHELL+=bee-download
HELPER_BEE_SHELL+=bee-init
HELPER_BEE_SHELL+=bee-install
HELPER_BEE_SHELL+=bee-list
HELPER_BEE_SHELL+=bee-query
HELPER_BEE_SHELL+=bee-remove
HELPER_BEE_SHELL+=bee-update
HELPER_C+=bee-cache-inventory
HELPER_SHELL+=compat-filesfile2contentfile
HELPER_SHELL+=compat-fixmetadir
HELPER_SHELL+=content2filelist
HELPER_SHELL+=filelist2content
HELPER_SHELL+=bee-cache-update
LIBRARY_SHELL+=beelib.config.sh
BUILDTYPES+=autogen
BUILDTYPES+=autotools
BUILDTYPES+=cmake
BUILDTYPES+=configure
BUILDTYPES+=jb
BUILDTYPES+=make
BUILDTYPES+=perl-module
BUILDTYPES+=perl-module-makemaker
BUILDTYPES+=python-module
BUILDTYPES+=r-package
BUILDTYPES+=haskell-module
HELPER_HOOKS_SHELL+=update-mime-database
HELPER_HOOKS_SHELL+=glib-compile-schemas
HELPER_HOOKS_SHELL+=mkfontdir-mkfontscale
HELPER_HOOKS_SHELL+=gtk-update-icon-cache
HELPER_HOOKS_SHELL+=ldconfig
HELPER_HOOKS_SHELL+=update-desktop-database
HELPER_HOOKS_SHELL+=gdk-pixbuf-query-loaders
HELPER_HOOKS_SHELL+=mandb
HELPER_HOOKS_SHELL+=systemd-tmpfiles
HELPER_HOOKS_SHELL+=gconf-install-schemas
HELPER_HOOKS_SHELL+=info-dir
HELPER_HOOKS_SHELL+=kernel-modules
MANPAGES+=bee.1
MANPAGES+=bee-check.1
MANPAGES+=bee-download.1
MANPAGES+=bee-list.1
MANPAGES+=bee-init.1
MANPAGES+=bee-install.1
MANPAGES+=bee-query.1
MANPAGES+=bee-remove.1
MANPAGES+=bee-update.1
CONFIG_TEMPLATES+=fallback
CONFIG_FILES+=skiplist
CONFIG_FILES+=beerc
.SUFFIXES: .in .sh .sh.in
all: build
build: shellscripts buildtypes cprograms manpages
SHELLSCRIPTS=$(PROGRAMS_SHELL) $(HELPER_BEE_SHELL) $(HELPER_SHELL)
BEEVERSION_OBJECTS=beeversion.o bee_version_parse.o bee_version_compare.o bee_version_output.o
BEESEP_OBJECTS=beesep.o
BEECUT_OBJECTS=beecut.o
BEEUNIQ_OBJECTS=beeuniq.o
BEESORT_OBJECTS=bee_tree.o bee_version_compare.o bee_version_output.o bee_version_parse.o bee_getopt.o beesort.o
BEEGETOPT_OBJECTS=bee_getopt.o beegetopt.o
BEEFLOCK_OBJECTS=bee_getopt.o beeflock.o
BEECACHEINVENTORY_OBJECTS=bee-cache-inventory.o bee_getopt.o
bee_BUILDTYPES=$(addsuffix .sh,$(addprefix buildtypes/,$(BUILDTYPES)))
shellscripts: $(addsuffix .sh,$(SHELLSCRIPTS)) $(LIBRARY_SHELL)
cprograms: $(PROGRAMS_C) ${HELPER_C}
manpages: $(MANPAGES)
buildtypes: ${bee_BUILDTYPES}
beesep: $(addprefix src/, ${BEESEP_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
beeversion: $(addprefix src/, ${BEEVERSION_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
beecut: $(addprefix src/, ${BEECUT_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
beeuniq: $(addprefix src/, ${BEEUNIQ_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
beesort: $(addprefix src/, ${BEESORT_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
beegetopt: $(addprefix src/, ${BEEGETOPT_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
beeflock: $(addprefix src/, ${BEEFLOCK_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
bee-cache-inventory: $(addprefix src/, ${BEECACHEINVENTORY_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")
%.o: %.c
$(call quiet-command,${CC} ${CFLAGS} -o $@ -c $^,"CC $@")
%.sh: src/%.sh.in
$(call quiet-command,sed ${sed-rules} $< >$@,"SED $@")
%.1: manpages/%.1.in
$(call quiet-command,sed ${sed-rules} $< >$@,"SED $@")
%.sh: %.sh.in
$(call quiet-command,sed ${sed-rules} $< >$@,"SED $@")
clean:
$(call quiet-command,rm -f $(addsuffix .sh,${SHELLSCRIPTS}) $(LIBRARY_SHELL) $(HELPER_SHELL),"CLEAN <various>.sh")
$(call quiet-command,rm -f ${PROGRAMS_C},"CLEAN ${PROGRAMS_C}")
$(call quiet-command,rm -f ${HELPER_C},"CLEAN ${HELPER_C}")
$(call quiet-command,rm -f src/*.o,"CLEAN c object files")
$(call quiet-command,rm -f ${MANPAGES},"CLEAN manpages")
$(call quiet-command,rm -f ${bee_BUILDTYPES},"CLEAN buildtypes")
install: install-core install-config
install-core: build install-man install-hooks install-buildtypes install-beeshlib install-tools install-helper install-bin
install-bin: $(addprefix ${DESTDIR}${BINDIR}/,${PROGRAMS_C} ${PROGRAMS_SHELL})
install-dir-bindir:
$(call quiet-installdir,0755,${DESTDIR}${BINDIR})
${DESTDIR}${BINDIR}/%: % install-dir-bindir
$(call quiet-install,0755,$<,$@)
${DESTDIR}${BINDIR}/%: %.sh install-dir-bindir
$(call quiet-install,0755,$<,$@)
install-tools: $(addprefix ${DESTDIR}${LIBEXECDIR}/bee/bee.d/,${HELPER_BEE_SHELL})
install-dir-tools:
$(call quiet-installdir,0755,${DESTDIR}${LIBEXECDIR}/bee/bee.d)
${DESTDIR}${LIBEXECDIR}/bee/bee.d/%: %.sh install-dir-tools
$(call quiet-install,0755,$<,$@)
${DESTDIR}${LIBEXECDIR}/bee/bee.d/%: % install-dir-tools
$(call quiet-install,0755,$<,$@)
install-helper: $(addprefix ${DESTDIR}${LIBEXECDIR}/bee/,${HELPER_SHELL} ${HELPER_C})
install-dir-helper:
$(call quiet-installdir,0755,${DESTDIR}${LIBEXECDIR}/bee)
${DESTDIR}${LIBEXECDIR}/bee/%: %.sh install-dir-helper
$(call quiet-install,0755,$<,$@)
${DESTDIR}${LIBEXECDIR}/bee/%: % install-dir-helper
$(call quiet-install,0755,$<,$@)
install-beeshlib: $(addprefix ${DESTDIR}${LIBEXECDIR}/bee/,${LIBRARY_SHELL})
install-dir-beeshlib:
$(call quiet-installdir,0755,${DESTDIR}${LIBEXECDIR}/bee)
${DESTDIR}${LIBEXECDIR}/bee/%: % install-dir-beeshlib
$(call quiet-install,0755,$<,$@)
install-buildtypes: $(addsuffix .sh,$(addprefix ${DESTDIR}${LIBEXECDIR}/bee/beesh.d/,${BUILDTYPES}))
install-dir-buildtypes:
$(call quiet-installdir,0755,${DESTDIR}${LIBEXECDIR}/bee/beesh.d)
${DESTDIR}${LIBEXECDIR}/bee/beesh.d/%.sh: buildtypes/%.sh install-dir-buildtypes
$(call quiet-install,0755,$<,$@)
install-hooks: $(addprefix ${DESTDIR}${LIBEXECDIR}/bee/hooks.d/,${HELPER_HOOKS_SHELL})
install-dir-hookdir:
$(call quiet-installdir,0755,${DESTDIR}${LIBEXECDIR}/bee/hooks.d)
${DESTDIR}${LIBEXECDIR}/bee/hooks.d/%: hooks/%.sh install-dir-hookdir
$(call quiet-install,0755,$<,$@)
install-man: $(addprefix ${DESTDIR}${MANDIR}/man1/,${MANPAGES})
install-dir-mandir:
$(call quiet-installdir,0755,${DESTDIR}${MANDIR}/man1)
${DESTDIR}${MANDIR}/man1/%.1: %.1 install-dir-mandir
$(call quiet-install,0644,$<,$@)
install-dir-config:
$(call quiet-installdir,0755,${DESTDIR}${DEFCONFDIR}/bee/templates)
install-config: install-config-defaults install-config-templates
install-config-defaults: $(addprefix ${DESTDIR}${DEFCONFDIR}/bee/,${CONFIG_FILES})
install-config-templates: $(addprefix ${DESTDIR}${DEFCONFDIR}/bee/templates/,${CONFIG_TEMPLATES})
${DESTDIR}${DEFCONFDIR}/bee/%: conf/% install-dir-config
$(call quiet-install,0444,$<,$@)