-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
467 lines (375 loc) · 16.3 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
#/******************************************************************************
# * w_scan_cpp - a dtv channel scanner based on VDR (www.tvdr.de) and it's
# * Plugins.
# *
# * See the README file for copyright information and how to reach the author.
# *****************************************************************************/
BINARY = w_scan_cpp
WIRBELSCAN_VERSION = wirbelscan-2023.10.15
# original git repo seems to be stale.
#SATIP_GIT_ADDR = https://github.com/rofafor/vdr-plugin-satip
SATIP_GIT_ADDR = https://github.com/wirbel-at-vdr-portal/vdr-plugin-satip.git
#/******************************************************************************
# * if you are still running a distro, not beeing able to use all valid
# * standard ASCII Characters (32-126) for package names, and prefer to modify
# * packages instead of fixing your broken distro, you may overwrite the
# * package_name here.
# *****************************************************************************/
package_name ?= $(BINARY)
#/******************************************************************************
# * dependencies, add variables here, and checks in target .dependencies
# *****************************************************************************/
LIBJPEG=libjpeg
FREETYPE2=freetype2
FONTCONFIG=fontconfig
LIBPUGIXML=pugixml
LIBREPFUNC=librepfunc
LIBREPFUNC_MINVERSION=1.9.0
# /* require either PKG_CONFIG_PATH to be set, or, a working pkg-config */
HAVE_LIBJPEG =$(shell if $(PKG_CONFIG) --exists $(LIBJPEG); then echo "1"; else echo "0"; fi )
HAVE_FREETYPE2 =$(shell if $(PKG_CONFIG) --exists $(FREETYPE2); then echo "1"; else echo "0"; fi )
HAVE_FONTCONFIG =$(shell if $(PKG_CONFIG) --exists $(FONTCONFIG); then echo "1"; else echo "0"; fi )
HAVE_LIBPUGIXML =$(shell if $(PKG_CONFIG) --exists $(LIBPUGIXML); then echo "1"; else echo "0"; fi )
HAVE_LIBREPFUNC =$(shell if $(PKG_CONFIG) --exists $(LIBREPFUNC); then echo "1"; else echo "0"; fi )
HAVE_LIBREPFUNC_MINVERSION=$(shell if $(PKG_CONFIG) --atleast-version=$(LIBREPFUNC_MINVERSION) $(LIBREPFUNC); then echo "1"; else echo "0"; fi )
#/******************************************************************************
# * if you prefer verbose non-coloured build messages, remove the '@' here:
# *****************************************************************************/
CC = @gcc
CXX = @g++
CFLAGS += -g -O3 -fPIC -Werror=overloaded-virtual
CXXFLAGS += -g -O3 -fPIC -Wall -Wextra -Werror=overloaded-virtual -Wno-unused-parameter -Wfatal-errors
#/******************************************************************************
# * programs, override if on different paths.
# *****************************************************************************/
CD ?= cd
CP ?= cp
CHMOD ?= chmod
GIT ?= git
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL) -m 755
INSTALL_DATA ?= $(INSTALL) -m 644
LN ?= ln
MAKE ?= make
MKDIR ?= mkdir
MKDIR_P ?= ${MKDIR} -p
PKG_CONFIG ?= pkg-config
RM ?= rm
SED ?= sed
SHELL = /bin/sh
STRIP ?= strip
TAR ?= tar
WGET ?= wget
#/******************************************************************************
# * directories:
# * HINT: http://115.28.130.42/make/Makefile-Conventions.html
# *****************************************************************************/
tmpdir ?= /tmp
#------------------------
# A prefix used in constructing the default values of the variables listed below.
# You may want (or not..) to change/override this to /usr .
prefix ?= /usr/local
#------------------------
# used for directories that contain machine-specific files, such as executables
# and subroutine libraries), while $(prefix) is used directly for other.
# directories.
exec_prefix ?= $(prefix)
#------------------------
# directory for installing executable programs that users can run.
bindir = $(exec_prefix)/bin
#------------------------
# directory for installing executable programs that can be run from the shell,
# but are only generally useful to system administrators.
sbindir = $(exec_prefix)/sbin
#------------------------
# directory for installing executable programs to be run by other programs
# rather than by users.
libexecdir = $(exec_prefix)/libexec
#------------------------
# root of the directory tree for read-only architecture-independent data files
# datadir's default value is based on this variable; so are infodir, mandir,
# and others.
datarootdir = $(prefix)/share
#------------------------
# directory for installing idiosyncratic read-only architecture-independent
# data files for this program. This is usually the same place as 'datarootdir',
# but we use the two separate variables so that you can move these program-
# specific files without altering the location for Info files, man pages, etc.
# -> Most packages install their data under $(datadir)/package-name/.
datadir = $(datarootdir)
#------------------------
# read-only data files that pertain to a single machine
sysconfdir = $(prefix)/etc
#------------------------
# directory for installing header files to be included by user programs with
# the #include (..) preprocessor directive
includedir = $(prefix)/include
#------------------------
# architecture-independent data files which the programs modify while they run
sharedstatedir = $(prefix)/com
#------------------------
# data files which the programs modify while they run
localstatedir = $(prefix)/var
#------------------------
# documentation files (other than Info)
docdir = $(datarootdir)/doc/$(package_name)
#------------------------
# the Info files for this package
infodir = $(datarootdir)/info
#------------------------
# object files and libraries of object code. No executables.
libdir = $(exec_prefix)/lib
#------------------------
# locale-specific message catalogs for this package
localedir = $(datarootdir)/locale
#------------------------
# Unix-style man pages
mandir = $(datarootdir)/man
man1dir = $(mandir)/man1
man2dir = $(mandir)/man2
man3dir = $(mandir)/man3
man4dir = $(mandir)/man4
man5dir = $(mandir)/man5
#------------------------
# no build outside of sources yet. Sorry.
# would be something like:
# mkdir ./build && cd build && make -j8 install
# -> Anyone..?
srcdir = $(shell pwd)
#------------------------
vdrdir = $(srcdir)/vdr
vdrlibsidir =$(vdrdir)/libsi
pluginsrcdir = $(vdrdir)/PLUGINS/src
pluginlibdir = $(vdrdir)/PLUGINS/lib
WIRBELSCAN_TARBALL = vdr-$(WIRBELSCAN_VERSION).tgz
WIRBELSCAN_DL_ADDR = https://www.gen2vdr.de/wirbel/wirbelscan/$(WIRBELSCAN_TARBALL)
#/******************************************************************************
# * targets starting from here:
# *****************************************************************************/
APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(vdrdir)/config.h)
DEFINES = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DPLUGIN_NAME_I18N='"cmd"'
DEFINES += -DAPIVERSION='"$(APIVERSION)"'
DEFINES += -DSTATIC_PLUGINS
LIBS = -ljpeg -pthread -lcap -ldl -lrt $(shell $(PKG_CONFIG) --libs freetype2 fontconfig)
LIBS += $(shell curl-config --libs)
LIBS += $(shell $(PKG_CONFIG) --libs-only-l $(LIBPUGIXML))
LIBS += $(shell $(PKG_CONFIG) --libs-only-l $(LIBREPFUNC))
INCLUDES = -I$(srcdir)
INCLUDES += -I$(vdrdir)
INCLUDES += -I$(pluginsrcdir)
INCLUDES += $(shell $(PKG_CONFIG) --cflags-only-I $(LIBJPEG))
INCLUDES += $(shell $(PKG_CONFIG) --cflags-only-I $(LIBPUGIXML))
INCLUDES += $(shell $(PKG_CONFIG) --cflags-only-I $(LIBREPFUNC))
INCLUDES += $(shell $(PKG_CONFIG) --cflags freetype2 fontconfig)
LDFLAGS += -L$(srcdir) -L$(vdrdir) -L$(vdrlibsidir)
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L $(LIBJPEG))
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L $(LIBPUGIXML))
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L $(LIBREPFUNC))
SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
VDR_SOURCES := $(shell find $(vdrdir) -maxdepth 1 ! -name "vdr.c" -name "*.c" 2>/dev/null | LC_ALL=C sort)
LIBSI_SOURCES := $(sort $(wildcard $(vdrlibsidir)/*.c))
WIRBELSCAN_SOURCES = $(sort $(wildcard $(pluginsrcdir)/wirbelscan/*.cpp))
SATIP_SOURCES = $(sort $(wildcard $(pluginsrcdir)/satip/*.c))
OBJS = $(SOURCES:.cpp=.o)
VDR_OBJS = $(VDR_SOURCES:.c=.o)
LIBSI_OBJS = $(LIBSI_SOURCES:.c=.o)
WIRBELSCAN_OBJS = $(WIRBELSCAN_SOURCES:.cpp=.o)
SATIP_OBJS = $(SATIP_SOURCES:.c=.o)
VERSION = $(shell date +%Y%m%d)
PACKAGE = $(package_name)-$(VERSION)
MACHINE = $(shell uname -m )
#/******************************************************************************
# * color definitions, RST=reset, CY=cyan, MG=magenta, BL=blue, (..)
# *****************************************************************************/
RST=\e[0m
CY=\e[1;36m
MG=\e[1;35m
BL=\e[1;34m
YE=\e[1;33m
RD=\e[1;31m
GN=\e[1;32m
#/******************************************************************************
# * targets starting from here:
# *****************************************************************************/
%.o: %.c
ifeq ($(CXX),@g++)
@echo -e "${CY} CXX $@${RST}"
endif
$(CXX) $(CFLAGS) $(CPPFLAGS) -Wno-parentheses -Wno-unused-parameter -c $(DEFINES) $(INCLUDES) -o $@ $<
%.o: %.cpp
ifeq ($(CXX),@g++)
@echo -e "${BL} CXX $@${RST}"
endif
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
$(BINARY): .dependencies $(LIBSI_OBJS) $(VDR_OBJS) $(WIRBELSCAN_OBJS) $(SATIP_OBJS) $(OBJS)
ifeq ($(CXX),@g++)
@echo -e "${GN} LINK $(BINARY)${RST}"
endif
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBSI_OBJS) $(VDR_OBJS) $(WIRBELSCAN_OBJS) $(SATIP_OBJS) $(OBJS) $(LIBS) -o $(BINARY)
install: $(BINARY)
$(MKDIR_P) $(DESTDIR)$(bindir)
$(MKDIR_P) $(DESTDIR)$(docdir)
$(MKDIR_P) $(DESTDIR)$(man1dir)
$(INSTALL_PROGRAM) $(BINARY) $(DESTDIR)$(bindir)
$(INSTALL_DATA) CONTRIBUTORS COPYING HISTORY README $(DESTDIR)$(docdir)
$(INSTALL_DATA) doc/w_scan_cpp.1 $(DESTDIR)$(man1dir)
uninstall:
$(RM) -f $(DESTDIR)$(bindir)/$(BINARY)
$(RM) -rf $(DESTDIR)$(docdir)
$(RM) -f $(DESTDIR)$(man1dir)/w_scan_cpp.1
.PHONY: download
download: $(vdrdir) $(pluginsrcdir)/satip $(pluginsrcdir)/wirbelscan
$(vdrdir):
$(GIT) clone git://git.tvdr.de/vdr.git
@$(RM) -rf $(vdrdir)/.git
$(MKDIR_P) $(pluginsrcdir)
$(MKDIR_P) $(pluginlibdir)
$(pluginsrcdir)/satip.git:
$(CD) $(pluginsrcdir) && $(GIT) clone $(SATIP_GIT_ADDR)
$(CD) $(pluginsrcdir) && $(LN) -sf vdr-plugin-satip satip
$(pluginsrcdir)/satip: $(pluginsrcdir)/satip.git
$(pluginsrcdir)/wirbelscan:
$(CD) $(pluginsrcdir) && $(WGET) $(WIRBELSCAN_DL_ADDR)
$(CD) $(pluginsrcdir) && $(TAR) xf $(WIRBELSCAN_TARBALL) && $(RM) -f $(WIRBELSCAN_TARBALL)
$(CD) $(pluginsrcdir) && $(LN) -s $(WIRBELSCAN_VERSION) wirbelscan
.PHONY: clean mrproper Version.h
clean:
@$(RM) -f $(LIBSI_OBJS) $(VDR_OBJS) $(OBJS) $(WIRBELSCAN_OBJS) $(SATIP_OBJS) $(BINARY) .dependencies
@$(RM) -rf $(vdrdir)/.git
@$(RM) -rf $(pluginsrcdir)/vdr-plugin-satip/.git
@$(RM) -rf MakeHeader.bin
mrproper: clean
@$(RM) -r $(vdrdir)
Version.h:
@echo "#pragma once" > Version.h
@echo "#include <string>" >> Version.h
@echo "/* AUTOMATICALLY GENERATED - DO NOT EDIT MANUALLY */" >> Version.h
@echo "" >> Version.h
@echo "const std::string version = \"$(VERSION)\";" >> Version.h
@$(CHMOD) a-x Version.h
version: Version.h
dist: Version.h mrproper
@-$(RM) -rf $(tmpdir)/$(PACKAGE)
@$(MKDIR_P) $(tmpdir)/$(PACKAGE)
@$(CP) -a * $(tmpdir)/$(PACKAGE)
@$(TAR) cfj $(PACKAGE).tar.bz2 -C $(tmpdir) $(PACKAGE)
@-$(RM) -rf $(tmpdir)/$(PACKAGE)
@echo Distribution package created as $(PACKAGE).tar.bz2
dist-download: clean
@$(TAR) cfj third_party_$(VERSION).tar.bz2 ./vdr
@echo third party package created as third_party_$(VERSION).tar.bz2
binary: $(BINARY)
@$(STRIP) $(BINARY)
@-$(RM) -rf $(tmpdir)/$(PACKAGE)
@$(MKDIR_P) $(tmpdir)/$(PACKAGE)
DESTDIR=$(tmpdir)/$(PACKAGE) prefix=/usr $(MAKE) install
@$(TAR) cfj $(PACKAGE)-binary-$(MACHINE).tar.bz2 -C $(tmpdir) $(PACKAGE)
@-$(RM) -rf $(tmpdir)/$(PACKAGE)
@echo binary package created as $(PACKAGE)-binary-$(MACHINE).tar.bz2
#/******************************************************************************
# * dependencies, check them here and provide message to user.
# *****************************************************************************/
MAKEDEP = $(CXX) -MM -MG
.dependencies: Makefile
ifeq ($(HAVE_LIBJPEG),0)
@echo "ERROR: dependency not found: $(LIBJPEG)"
exit 1
endif
ifeq ($(HAVE_FREETYPE2),0)
@echo "ERROR: dependency not found: $(FREETYPE2)"
exit 1
endif
ifeq ($(HAVE_FONTCONFIG),0)
@echo "ERROR: dependency not found: $(FONTCONFIG)"
exit 1
endif
ifeq ($(HAVE_LIBPUGIXML),0)
@echo "ERROR: dependency not found: $(LIBPUGIXML)"
exit 1
endif
ifeq ($(HAVE_LIBREPFUNC),0)
@echo "ERROR: dependency not found: $(LIBREPFUNC) >= $(LIBREPFUNC_MINVERSION)"
exit 1
endif
ifeq ($(HAVE_LIBREPFUNC_MINVERSION),0)
@echo "ERROR: dependency $(LIBREPFUNC) older than $(LIBREPFUNC_MINVERSION)"
exit 1
endif
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(SOURCES) > $@
-include .dependencies
#/******************************************************************************
# * debug
# *****************************************************************************/
printvars:
@echo "BINARY = $(BINARY)"
@echo "package_name = $(package_name)"
@echo "WIRBELSCAN_VERSION = $(WIRBELSCAN_VERSION)"
@echo "WIRBELSCAN_SOURCES = $(WIRBELSCAN_SOURCES)"
@echo "WIRBELSCAN_OBJS = $(WIRBELSCAN_OBJS)"
@echo "SATIP_GIT_ADDR = $(SATIP_GIT_ADDR)"
@echo "HAVE_LIBJPEG = $(HAVE_LIBJPEG)"
@echo "HAVE_FREETYPE2 = $(HAVE_FREETYPE2)"
@echo "HAVE_FONTCONFIG = $(HAVE_FONTCONFIG)"
@echo "HAVE_LIBPUGIXML = $(HAVE_LIBPUGIXML)"
@echo "HAVE_LIBREPFUNC = $(HAVE_LIBREPFUNC)"
@echo "HAVE_LIBREPFUNC_MINVERSION = $(HAVE_LIBREPFUNC_MINVERSION)"
@echo "CC = $(CC)"
@echo "CXX = $(CXX)"
@echo "CFLAGS = $(CFLAGS)"
@echo "CXXFLAGS = $(CXXFLAGS)"
@echo "CD = $(CD)"
@echo "CP = $(CP)"
@echo "CHMOD = $(CHMOD)"
@echo "GIT = $(GIT)"
@echo "INSTALL = $(INSTALL)"
@echo "INSTALL_PROGRAM = $(INSTALL_PROGRAM)"
@echo "INSTALL_DATA = $(INSTALL_DATA)"
@echo "LN = $(LN)"
@echo "MAKE = $(MAKE)"
@echo "MKDIR = $(MKDIR)"
@echo "MKDIR_P = $(MKDIR_P)"
@echo "PKG_CONFIG = $(PKG_CONFIG)"
@echo "RM = $(RM)"
@echo "SED = $(SED)"
@echo "SHELL = $(SHELL)"
@echo "STRIP = $(STRIP)"
@echo "TAR = $(TAR)"
@echo "WGET = $(WGET)"
@echo "tmpdir = $(tmpdir)"
@echo "prefix = $(prefix)"
@echo "exec_prefix = $(exec_prefix)"
@echo "bindir = $(bindir)"
@echo "sbindir = $(sbindir)"
@echo "libexecdir = $(libexecdir)"
@echo "datarootdir = $(datarootdir)"
@echo "datadir = $(datadir)"
@echo "sysconfdir = $(sysconfdir)"
@echo "includedir = $(includedir)"
@echo "sharedstatedir = $(sharedstatedir)"
@echo "localstatedir = $(localstatedir)"
@echo "docdir = $(docdir)"
@echo "infodir = $(infodir)"
@echo "libdir = $(libdir)"
@echo "localedir = $(localedir)"
@echo "mandir = $(mandir)"
@echo "man1dir = $(man1dir)"
@echo "man2dir = $(man2dir)"
@echo "man3dir = $(man3dir)"
@echo "man4dir = $(man4dir)"
@echo "man5dir = $(man5dir)"
@echo "srcdir = $(srcdir)"
@echo "vdrdir = $(srcdir)/vdr"
@echo "vdrlibsidir = $(vdrlibsidir)"
@echo "pluginsrcdir = $(pluginsrcdir)"
@echo "pluginlibdir = $(pluginlibdir)"
@echo "WIRBELSCAN_TARBALL = $(WIRBELSCAN_TARBALL)"
@echo "WIRBELSCAN_DL_ADDR = $(WIRBELSCAN_DL_ADDR)"
@echo "APIVERSION = $(APIVERSION)"
@echo "DEFINES = $(DEFINES)"
@echo "LIBS = $(LIBS)"
@echo "INCLUDES = $(INCLUDES)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "VERSION = $(VERSION)"
@echo "PACKAGE = $(PACKAGE)"
@echo "MACHINE = $(MACHINE)"
@echo "MAKEDEP = $(MAKEDEP)"