-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
388 lines (323 loc) · 11.4 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
################################################################################
#
# Makefile for building native ni-libstb-hal and ni-neutrino
#
################################################################################
#
# (C) 2012,2013 Stefan Seyfried
# (C) 2015-2023 Sven Hoefer
#
# This is a 'stand-alone' Makefile that works outside of NI \o/ Buildsystem too.
#
# ------------------------------------------------------------------------------
#
# Prerequisite packages need to be installed, no checking is done for that
#
# Prerequisits
# ------------
#
# apt-get install build-essential ccache git make subversion patch gcc bison \
# flex texinfo automake libtool ncurses-dev pkg-config
#
# Neutrino dependencies for Debian
# --------------------------------
#
# apt-get install libavformat-dev
# apt-get install libswscale-dev
# echo "deb http://www.deb-multimedia.org stable main non-free" >> /etc/apt/sources.list
# apt-get install deb-multimedia-keyring
# apt-get install libswresample-dev
# apt-get install libopenthreads-dev
# apt-get install libglew-dev
# apt-get install freeglut3-dev
# apt-get install libao-dev
# apt-get install libid3tag0-dev
# apt-get install libmad0-dev
# apt-get install libogg-dev
# apt-get install libfreetype6-dev
# apt-get install libsigc++-2.0-dev
# apt-get install libjpeg-dev
# apt-get install libgif-dev
# apt-get install libvorbis-dev
# apt-get install libflac-dev
# apt-get install libcurl4-openssl-dev
# apt-get install libreadline6-dev
#
# Optional
# --------
#
# apt-get install libgstreamer1.0-dev
# apt-get install libgstreamer-plugins-base1.0-dev
#
# ------------------------------------------------------------------------------
-include config.local
BOXMODEL ?= generic
BUILD_DIR = $(PWD)/.build
DEPS_DIR = $(PWD)/.deps
ARCHIVE_DIR = $(PWD)/archive
TARGET_DIR = $(PWD)/root
SOURCE_DIR = $(PWD)/../source
ifeq ($(wildcard $(SOURCE_DIR)),)
SOURCE_DIR = $(ARCHIVE_DIR)
endif
SKEL_DIR = $(PWD)/skel
prefix = /usr
# search path(s) for all prerequisites
VPATH = $(DEPS_DIR)
# ------------------------------------------------------------------------------
CFLAGS = -W
CFLAGS += -Wall
#CFLAGS += -Werror
CFLAGS += -Wextra
CFLAGS += -Wshadow
CFLAGS += -Wsign-compare
#CFLAGS += -Wconversion
#CFLAGS += -Wfloat-equal
CFLAGS += -Wuninitialized
CFLAGS += -Wmaybe-uninitialized
CFLAGS += -Werror=type-limits
CFLAGS += -Warray-bounds
CFLAGS += -Wformat-security
#CFLAGS += -fmax-errors=10
CFLAGS += -O0 -g -ggdb3
CFLAGS += -funsigned-char
CFLAGS += -rdynamic
CFLAGS += -DPEDANTIC_VALGRIND_SETUP
CFLAGS += -DDYNAMIC_LUAPOSIX
CFLAGS += -D__KERNEL_STRICT_NAMES
CFLAGS += -D__STDC_FORMAT_MACROS
CFLAGS += -D__STDC_CONSTANT_MACROS
CFLAGS += -DASSUME_MDEV
CFLAGS += -DTEST_MENU
# enable --as-needed for catching more build problems...
CFLAGS += -Wl,--as-needed
# in case some libs are installed in $(TARGET_DIR)$(prefix) (e.g. libdvbsi++)
CFLAGS += -I$(TARGET_DIR)$(prefix)/include
CFLAGS += -L$(TARGET_DIR)$(prefix)/lib
CFLAGS += -L$(TARGET_DIR)$(prefix)/lib64
# workaround for debian's non-std sigc++ locations
CFLAGS += -I/usr/include/sigc++-2.0
CFLAGS += -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include
# gstreamer flags
#CFLAGS += $(shell pkg-config --cflags --libs gstreamer-1.0)
#CFLAGS += $(shell pkg-config --cflags --libs gstreamer-audio-1.0)
#CFLAGS += $(shell pkg-config --cflags --libs gstreamer-video-1.0)
CXXFLAGS = $(CFLAGS)
CXXFLAGS += -std=c++11
export CFLAGS CXXFLAGS
# ------------------------------------------------------------------------------
PKG_CONFIG_PATH = $(TARGET_DIR)$(prefix)/lib/pkgconfig
export PKG_CONFIG_PATH
# ------------------------------------------------------------------------------
# first target is default
default: neutrino
local-files: config.local $(SKEL_DIR)
config.local:
@clear
@echo ""
@echo " ### ### ###"
@echo " ### ## ##"
@echo " #### ## ##"
@echo " ## ## ## ##"
@echo " ## #### ##"
@echo " ## ### ##"
@echo " ## ## ## http://www.neutrino-images.de"
@echo " #"
@echo ""
@echo " -------------------------------------------------"
@echo ""
@echo " 1) Generic-PC"
@echo " 2) Raspberry Pi"
@echo ""
@read -p "Select your boxmodel? [default: 1] " boxmodel; \
boxmodel=$${boxmodel:-1}; \
case "$$boxmodel" in \
1) boxmodel=generic;; \
2) boxmodel=raspi;; \
*) boxmodel=generic;; \
esac; \
install -m 0644 config.example $(@); \
sed -i -e "s|^#BOXMODEL = $$boxmodel|BOXMODEL = $$boxmodel|" $(@)
# ------------------------------------------------------------------------------
run:
export SIMULATE_FE=1; \
$(TARGET_DIR)$(prefix)/bin/neutrino
run-gdb:
export SIMULATE_FE=1; \
gdb -ex run $(TARGET_DIR)$(prefix)/bin/neutrino
run-valgrind:
export SIMULATE_FE=1; \
valgrind --leak-check=full --log-file="$(TARGET_DIR)/valgrind.log" -v $(TARGET_DIR)$(prefix)/bin/neutrino
# ------------------------------------------------------------------------------
$(BUILD_DIR) \
$(DEPS_DIR) \
$(ARCHIVE_DIR) \
$(SKEL_DIR):
install -d $(@)
ifneq ($(ARCHIVE_DIR),$(SOURCE_DIR))
$(SOURCE_DIR):
install -d $(@)
endif
$(TARGET_DIR): | $(SKEL_DIR)
install -d $(@)
install -d $(@)/etc
install -d $(@)/media/sda1/{epg,logos,movies,music,pictures,plugins,streamripper}
echo "imagename=NI \o/ Neutrino Generic-PC" > $(@)/.version
cp --remove-destination -a $(SKEL_DIR)/. $(@)/
# ------------------------------------------------------------------------------
LIBSTB_HAL_VERSION = master
LIBSTB_HAL_DIR = ni-libstb-hal
LIBSTB_HAL_SOURCE = ni-libstb-hal
LIBSTB_HAL_SITE = https://github.com/neutrino-images
LIBSTB_HAL_DEPENDENCIES = ffmpeg
LIBSTB_HAL_SOURCE_DIR = $(SOURCE_DIR)/$(LIBSTB_HAL_SOURCE)
LIBSTB_HAL_OBJ_DIR = $(BUILD_DIR)/$(LIBSTB_HAL_DIR)-obj
LIBSTB_HAL_CONFIG_STATUS = $(LIBSTB_HAL_OBJ_DIR)/config.status
$(LIBSTB_HAL_SOURCE_DIR): | $(SOURCE_DIR)
cd $(SOURCE_DIR) && git clone $(LIBSTB_HAL_SITE)/$(LIBSTB_HAL_SOURCE).git
$(LIBSTB_HAL_CONFIG_STATUS): $(LIBSTB_HAL_DEPENDENCIES) | $(LIBSTB_HAL_SOURCE_DIR) $(LIBSTB_HAL_OBJ_DIR)
set -e; cd $(LIBSTB_HAL_SOURCE_DIR); \
git checkout $(LIBSTB_HAL_VERSION)
$(LIBSTB_HAL_SOURCE_DIR)/autogen.sh
set -e; cd $(LIBSTB_HAL_OBJ_DIR); \
$(LIBSTB_HAL_SOURCE_DIR)/configure \
--prefix=$(TARGET_DIR)$(prefix) \
\
--enable-maintainer-mode \
--enable-shared=no \
$(if $(findstring gstreamer,$(CFLAGS)),--enable-gstreamer_10=yes) \
\
--with-target=native \
--with-targetroot=$(TARGET_DIR) \
--with-boxtype=generic \
$(if $(filter $(BOXMODEL), raspi),--with-boxmodel=raspi) \
;
$(LIBSTB_HAL_OBJ_DIR)/libstb-hal.a: libstb-hal
libstb-hal: $(LIBSTB_HAL_CONFIG_STATUS) | $(TARGET_DIR)
$(MAKE) -C $(LIBSTB_HAL_OBJ_DIR) install
libstb-hal.clean:
-$(MAKE) -C $(LIBSTB_HAL_OBJ_DIR) clean
rm -rf $(LIBSTB_HAL_OBJ_DIR)
# ------------------------------------------------------------------------------
NEUTRINO_VERSION = master
NEUTRINO_DIR = ni-neutrino
NEUTRINO_SOURCE = ni-neutrino
NEUTRINO_SITE = https://github.com/neutrino-images
NEUTRINO_DEPENDENCIES = ffmpeg libdvbsi lua
NEUTRINO_SOURCE_DIR = $(SOURCE_DIR)/$(NEUTRINO_SOURCE)
NEUTRINO_OBJ_DIR = $(BUILD_DIR)/$(NEUTRINO_DIR)-obj
NEUTRINO_CONFIG_STATUS = $(NEUTRINO_OBJ_DIR)/config.status
$(NEUTRINO_SOURCE_DIR): | $(SOURCE_DIR)
cd $(SOURCE_DIR); git clone $(NEUTRINO_SITE)/$(NEUTRINO_SOURCE).git
$(NEUTRINO_CONFIG_STATUS): $(NEUTRINO_DEPENDENCIES) | $(NEUTRINO_SOURCE_DIR) $(NEUTRINO_OBJ_DIR) $(LIBSTB_HAL_OBJ_DIR)/libstb-hal.a
set -e; cd $(NEUTRINO_SOURCE_DIR); \
git checkout $(NEUTRINO_VERSION)
$(NEUTRINO_SOURCE_DIR)/autogen.sh
set -e; cd $(NEUTRINO_OBJ_DIR); \
$(NEUTRINO_SOURCE_DIR)/configure \
--prefix=$(TARGET_DIR)$(prefix) \
--sysconfdir=$(TARGET_DIR)/etc \
--localstatedir=$(TARGET_DIR)/var \
\
--enable-maintainer-mode \
--enable-silent-rules \
--enable-mdev \
--enable-giflib \
--enable-cleanup \
\
--with-target=native \
--with-targetroot=$(TARGET_DIR) \
--with-boxtype=generic \
$(if $(filter $(BOXMODEL), raspi),--with-boxmodel=raspi) \
--with-stb-hal-includes=$(LIBSTB_HAL_SOURCE_DIR)/include \
--with-stb-hal-build=$(TARGET_DIR)$(prefix)/lib \
; \
neutrino: $(NEUTRINO_CONFIG_STATUS) | $(TARGET_DIR)
-rm $(NEUTRINO_OBJ_DIR)/src/neutrino # force relinking on changed libstb-hal
$(MAKE) -C $(NEUTRINO_OBJ_DIR) install
neutrino.clean:
-$(MAKE) -C $(NEUTRINO_OBJ_DIR) clean
rm -rf $(NEUTRINO_OBJ_DIR)
# ------------------------------------------------------------------------------
$(LIBSTB_HAL_OBJ_DIR) \
$(NEUTRINO_OBJ_DIR): | $(BUILD_DIR)
install -d $(@)
# ------------------------------------------------------------------------------
update: $(LIBSTB_HAL_SOURCE_DIR) $(NEUTRINO_SOURCE_DIR)
cd $(LIBSTB_HAL_SOURCE_DIR); git pull
cd $(NEUTRINO_SOURCE_DIR); git pull
git pull
# ------------------------------------------------------------------------------
clean: libstb-hal.clean neutrino.clean
clean-all:
rm -rf $(BUILD_DIR)
rm -rf $(DEPS_DIR)
rm -rf $(TARGET_DIR)
%-clean:
-find $(DEPS_DIR) -name $(subst -clean,,$(@)) -delete
# ------------------------------------------------------------------------------
FFMPEG_VERSION = 4.4.2
FFMPEG_DIR = ffmpeg-$(FFMPEG_VERSION)
FFMPEG_SOURCE = ffmpeg-$(FFMPEG_VERSION).tar.xz
FFMPEG_SITE = http://www.ffmpeg.org/releases
$(ARCHIVE_DIR)/$(FFMPEG_SOURCE): | $(ARCHIVE_DIR)
cd $(ARCHIVE_DIR) && wget $(FFMPEG_SITE)/$(FFMPEG_SOURCE)
ffmpeg: $(ARCHIVE_DIR)/$(FFMPEG_SOURCE) | $(BUILD_DIR) $(DEPS_DIR) $(TARGET_DIR)
rm -rf $(BUILD_DIR)/$(FFMPEG_DIR)
tar -C $(BUILD_DIR) -xf $(ARCHIVE_DIR)/$(FFMPEG_SOURCE)
set -e; cd $(BUILD_DIR)/$(FFMPEG_DIR); \
./configure \
--prefix=$(TARGET_DIR)$(prefix) \
\
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
\
--disable-stripping \
--disable-x86asm \
; \
$(MAKE); \
make install
rm -rf $(BUILD_DIR)/$(FFMPEG_DIR)
touch $(DEPS_DIR)/$(@)
# ------------------------------------------------------------------------------
# libdvbsi is not commonly packaged for linux distributions
LIBDVBSI_VERSION = 0.3.9
LIBDVBSI_DIR = libdvbsi++-$(LIBDVBSI_VERSION)
LIBDVBSI_SOURCE = libdvbsi++-$(LIBDVBSI_VERSION).tar.bz2
LIBDVBSI_SITE = https://github.com/mtdcr/libdvbsi/releases/download/$(LIBDVBSI_VERSION)
$(ARCHIVE_DIR)/$(LIBDVBSI_SOURCE): | $(ARCHIVE_DIR)
cd $(ARCHIVE_DIR) && wget $(LIBDVBSI_SITE)/$(LIBDVBSI_SOURCE)
libdvbsi: $(ARCHIVE_DIR)/$(LIBDVBSI_SOURCE) | $(BUILD_DIR) $(DEPS_DIR) $(TARGET_DIR)
rm -rf $(BUILD_DIR)/$(LIBDVBSI_DIR)
tar -C $(BUILD_DIR) -xf $(ARCHIVE_DIR)/$(LIBDVBSI_SOURCE)
set -e; cd $(BUILD_DIR)/$(LIBDVBSI_DIR); \
./autogen.sh; \
./configure \
--prefix=$(TARGET_DIR)$(prefix) \
; \
$(MAKE); \
make install
rm -rf $(BUILD_DIR)/$(LIBDVBSI_DIR)
touch $(DEPS_DIR)/$(@)
# ------------------------------------------------------------------------------
LUA_VERSION = 5.2.4
LUA_DIR = lua-$(LUA_VERSION)
LUA_SOURCE = lua-$(LUA_VERSION).tar.gz
LUA_SITE = https://www.lua.org/ftp
$(ARCHIVE_DIR)/$(LUA_SOURCE): | $(ARCHIVE_DIR)
cd $(ARCHIVE_DIR) && wget $(LUA_SITE)/$(LUA_SOURCE)
lua: $(ARCHIVE_DIR)/$(LUA_SOURCE) | $(BUILD_DIR) $(DEPS_DIR) $(TARGET_DIR)
rm -rf $(BUILD_DIR)/$(LUA_DIR)
tar -C $(BUILD_DIR) -xf $(ARCHIVE_DIR)/$(LUA_SOURCE)
set -e; cd $(BUILD_DIR)/$(LUA_DIR); \
sed -i "s|^#define LUA_ROOT .*|#define LUA_ROOT \"$(TARGET_DIR)$(prefix)/\"|" src/luaconf.h && \
$(MAKE) linux; \
make install INSTALL_TOP=$(TARGET_DIR)$(prefix)
rm -rf $(BUILD_DIR)/$(LUA_DIR)
touch $(DEPS_DIR)/$(@)
# ------------------------------------------------------------------------------
#PHONY =
.PHONY: $(PHONY)