forked from tsduck/tsduck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.tsduck
179 lines (153 loc) · 5.71 KB
/
Makefile.tsduck
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
#-----------------------------------------------------------------------------
#
# TSDuck - The MPEG Transport Stream Toolkit
# Copyright (c) 2005-2021, Thierry Lelegard
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
#-----------------------------------------------------------------------------
#
# Common makefile definitions for the TSDuck project.
#
#-----------------------------------------------------------------------------
# Duplicate output for specific compilers or profiling tools.
ifdef LLVM
BINDIR_SUFFIX = -clang
endif
ifdef GCOV
BINDIR_SUFFIX = -gcov
endif
ifdef GPROF
BINDIR_SUFFIX = -gprof
endif
# Standard common makefile is in same directory.
include $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))/Makefile.common
# Project specific directories and files.
INSTALLERDIR = $(ROOTDIR)/installers
SRCROOT = $(ROOTDIR)/src
LIBTSDUCKDIR = $(SRCROOT)/libtsduck
TSTOOLSDIR = $(SRCROOT)/tstools
TSPLUGINSDIR = $(SRCROOT)/tsplugins
STATIC_LIBTSDUCK = $(BINDIR)/libtsduck.a
SHARED_LIBTSDUCK = $(BINDIR)/libtsduck.so
ifndef TSPLUGINS
export TSPLUGINS := $(sort $(filter-out $(if $(NOTELETEXT),tsplugin_teletext,),\
$(notdir $(basename $(wildcard $(TSPLUGINSDIR)/tsplugin_*.cpp)))))
export TSEXECS := $(sort $(filter-out $(notdir $(basename $(wildcard $(TSTOOLSDIR)/*.h))),\
$(notdir $(basename $(wildcard $(TSTOOLSDIR)/*.cpp)))))
endif
# Default installation root.
# RPM packagers should override this in the "make install" command line.
SYSROOT =
# A shortcut-target to rebuild with static linking.
# Not meaningfull everywhere:
# - Static linking with system libraries is not supported on macOS.
# - On Linux, all used libraries must be installed. This is not supported
# on all distros. On Fedora, you may install "glibc-static libstdc++-static"
# but there is no static package for curl and pcsclite.
.PHONY: static
static:
+@$(MAKE) STATIC=true
ifeq ($(STATIC),)
# Dynamic (default) link
LDLIBS := -ldl $(LDLIBS)
else ifdef MACOS
$(error static linking is not supported on macOS)
else
NOCURL = true
NOPCSC = true
NODTAPI = true
NOSRT = true
NOTEST = true
CFLAGS_INCLUDES += -DTSDUCK_STATIC=1
endif
# External include directories and libraries.
ifdef CROSS_TARGET
# Some libraries are bypassed in cross-compilation.
NOCURL = true
NOPCSC = true
NODTAPI = true
NOSRT = true
endif
ifdef NOTELETEXT
CFLAGS_INCLUDES += -DTS_NOTELETEXT=1
endif
ifdef ASSERTIONS
CFLAGS_INCLUDES += -DTS_KEEP_ASSERTIONS=1
endif
ifeq ($(MACOS)$(NOSRT),)
# Not on macOS and SRT not disabled, check if libsrt is available.
NOSRT := $(if $(wildcard /usr/include/srt/*.h)$(wildcard /usr/local/include/srt/*.h),,true)
endif
ifneq ($(NOSRT),)
CFLAGS_INCLUDES += -DTS_NOSRT=1
else
LDLIBS := -lsrt $(LDLIBS)
endif
ifdef NOCURL
CFLAGS_INCLUDES += -DTS_NO_CURL=1
else
ifndef CFLAGS_CURL
export CFLAGS_CURL := $(shell curl-config --cflags)
export LDLIBS_CURL := $(shell curl-config --libs)
endif
CFLAGS_INCLUDES += $(CFLAGS_CURL)
LDLIBS := $(LDLIBS_CURL) $(LDLIBS)
endif
ifdef NOPCSC
CFLAGS_INCLUDES += -DTS_NO_PCSC=1
else ifeq ($(MACOS),)
# PCSC on Linux
CFLAGS_INCLUDES += -I/usr/include/PCSC
LDLIBS := -lpcsclite $(LDLIBS)
else
# PCSC on macOS
PCSC_ROOT = $(word 1,$(wildcard /opt/homebrew/opt/pcsc-lite /usr/local/opt/pcsc-lite))
CFLAGS_INCLUDES += -I$(PCSC_ROOT)/include/PCSC
LDLIBS := -L$(PCSC_ROOT)/lib -lpcsclite $(LDLIBS)
endif
ifdef NODTAPI
CFLAGS_INCLUDES += -DTS_NO_DTAPI=1
endif
ifdef BITRATE_DECIMALS
CFLAGS_INCLUDES += -DTS_BITRATE_DECIMALS=$(BITRATE_DECIMALS)
endif
ifeq ($(MACOS),)
# Link flags on Linux
CFLAGS_INCLUDES += -I$(LIBTSDUCKDIR)/linux
LDFLAGS_EXTRA += -Wl,-rpath,'$$ORIGIN',-z,noexecstack
SOFLAGS = -Wl,-soname=$(notdir $@),-z,noexecstack
else
# Link flags on macOS
CFLAGS_INCLUDES += -I$(LIBTSDUCKDIR)/mac
LDFLAGS_EXTRA += -Wl,-rpath,@executable_path -Wl,-rpath,@executable_path/../lib
SOFLAGS = -install_name '@rpath/$(notdir $@)'
endif
CFLAGS_INCLUDES += $(addprefix -I,$(shell find $(LIBTSDUCKDIR) -type d ! -name private ! -name windows ! -name $(if $(MACOS),linux,mac)))
ifneq ($(TS_NO_BUILD_VERSION),)
CPPFLAGS += -DTS_NO_BUILD_VERSION
endif
# Make sure that full paths of source files never appear in binaries.
ifneq ($(CC_FILE_PREFIX_MAP),)
CXXFLAGS += -ffile-prefix-map=$(SRCROOT)/=
endif