1 # to see the make rules:
10 # to add a new library:
12 # add PKG_3RD(pkg,<yes/no/auto>, <ver_basename>, <lib_paths>, <inc_paths>)
13 # add CHECK_LIB(pkg, <syslib>, <entry_pt>, [opt libs]) if may be in system
14 # add CHECK_HEADERS(pkg, <title>, <entry_pt>) to check for devel headers
15 # add CHECK_WANT(<want>, <title>, [ checks ]) around tests if conditional
16 # see openexr check for example if c++ lib
17 # add PKG_PROVIDE(pkg,<cond>) to instance pkg if probe succeeds
18 # add to exec > global_config if additional environment needed
20 # add pkg.<data> (pkg.x = .flags, .vars, .params)
21 # add $(call rules,$(call std-build,<name>,<dep>...))
22 # add deps to other call rules if they require the new library
23 # add config enables if other libraries use the new library
24 # add pc_<pkg>=<pkgcfg names> if needed for system build
27 TOPDIR ?= $(CURDIR)/..
28 include $(TOPDIR)/global_config
29 -include $(TOPDIR)/cin_config
30 BLD := $(THIRDPARTY)/build
32 ifneq ($(WANT_CIN_3RDPARTY),no)
34 # package build flags, if needed
35 # need frame pointer for debugs and helps with profiling
36 # NOTE: the trailing blank is MANDITORY or the builds fail
37 # due to bugs in the build scripts from auto*
38 CFLAGS_ ?= -g -O2 -fno-omit-frame-pointer
40 LDFLAGS += $(LDFLAGS_)
41 CXXFLAGS += $(CXXFLAGS_)
43 pkg-source=$(BLD)/$(1).source
44 pkg-config=$(BLD)/$(1).configure
45 pkg-built=$(BLD)/$(1).built
47 ext=$(lastword $(subst ., ,$(1)))
48 tarball=$(if $($(1).git),$(1).git,$(lastword $(sort $(wildcard src/$(1)*.tar.*))))
49 unpack=$(call unpack_$(call ext,$(1)),$(1))
50 unpack_git=git clone --depth 1 $($(1)) $(1)
51 unpack_gz=tar -xzf $(1)
52 unpack_bz2=tar -xjf $(1)
53 unpack_xz=tar -xJf $(1)
54 bld_depends=$(if $(ver_$(1)),$(call pkg-built,$(1)))
55 bld_path=$(ver_$(1))/$(2)
56 if_pkg=$(if $(ver_$(1)),$(2),$(3))
57 if_npkg=$(if $(ver_$(1)),,$(2))
58 if_shr=$(if $(filter $(1),$(shared_pkgs)),$(2),$(3))
59 pkg_conf=$(call if_shr,$(1),$(foreach p,$(pc_$(1)), $(shell pkg-config 2> /dev/null $(2) $(p))))
60 inc_path=$(call if_pkg,$(1),$(inc_$(1)), $(call pkg_conf,$(1),--cflags))
61 ld_path=$(call if_pkg,$(1),-L$(call bld_path,$(1),$(2)) $(lib_$(1)))
62 if_ena=$(if $(or $(ver_$(1)),$(filter $(1),$(shared_pkgs))),$(2))
63 if_want=$(if $(filter x$(WANT_$(1)),xyes),$(2),$(3))
64 sysincs:=usr/include usr/local/include
65 syslibs:=usr/lib usr/lib32 usr/lib64 lib lib32 lib64 usr/local/lib usr/local/lib32 usr/local/lib64
66 pkg_incl=$(lastword $(wildcard $(foreach f,$(sysincs), $(call bld_path,$(1),$(f)))))
67 pkg_libs=$(lastword $(wildcard $(foreach f,$(syslibs), $(call bld_path,$(1),$(f)))))
69 #$(eval $(call std-build,pkg,deps...))
70 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
71 #$(pkg.cppflags) added as CPPFLAGS+=$(cppflags) to pkg.vars
72 #$(pkg.cfg_vars) prepended to configure
73 #$(pkg.cfg_params) appended to configure
74 #$(pkg.mak_vars) prepended to make
75 #$(pkg.mak_params) appended to make
79 .PHONY: $(1) $(1)-configure $(1)-src $(1)-clean
80 $(1): $(call pkg-built,$(1))
81 $(1)-configure: $(call pkg-config,$(1))
82 $(1)-src: $(call pkg-source,$(1))
84 rm -rf $(1)* $(BLD)/$(1).*
86 $(call pkg-source,$(1)):
87 $(call unpack,$(call tarball,$(1))) \
88 $(foreach pch,$(sort $(wildcard src/$(notdir $(ver_$(1))).patch*)),
89 patch -d $(1)* -p1 < $(pch))
92 $(call pkg-config,$(1)): $(call pkg-source,$(1)) $(foreach dep,$(2),$(call bld_depends,$(dep)))
93 @echo "CONFIGURING $(1)"
95 $($(1).cfg_vars) $(CFG_VARS) ./configure $($(1).cfg_params) $(CFG_PARAMS)
98 $(call pkg-built,$(1)): $(call pkg-config,$(1))
99 +$($(1).mak_vars) $(MAK_VARS) $(MAKE) -C $(1)* $($(1).mak_params) $(MAK_PARAMS)
104 TARGETS := $(static_blds)
116 pc_libwebp=libwebp libwebpmux
118 pc_openjpeg=libopenjp2
119 pc_libvorbis=vorbis vorbisenc
125 encore.cfg_vars= true ||
126 esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile) -laudiofile"
127 esound.cfg_vars+= AUDIOFILE_LIBS="$(call ld_path,audiofile,libaudiofile/.libs)"
128 esound.cfg_params= --enable-shared=no --with-pic
129 esound.mak_vars+= CFLAGS=""
130 esound.ldflags=" -lm -lstdc++"
131 fftw.cfg_params= --disable-fortran --enable-shared=no
133 --enable-pthreads --disable-avdevice --enable-gpl --disable-ffplay \
134 $(call if_want,VAAPI,--enable-vaapi,--disable-vaapi) \
135 $(call if_want,VDPAU,--enable-vdpau,--disable-vdpau) \
136 $(call if_want,NV, --enable-nvenc --enable-nvdec --enable-ffnvcodec) \
137 $(call if_ena,twolame,--enable-libtwolame) \
138 $(call if_ena,openjpeg,--enable-libopenjpeg) \
139 $(call if_ena,lame,--enable-libmp3lame) \
140 $(call if_ena,libaom,--enable-libaom) \
141 $(call if_ena,dav1d,--enable-libdav1d) \
142 $(call if_ena,libwebp,--enable-libwebp) \
143 $(call if_ena,opus,--enable-libopus) \
144 $(call if_ena,libvorbis,--enable-libvorbis) \
145 $(call if_ena,libtheora,--enable-libtheora) \
146 $(call if_ena,libvpx,--enable-libvpx) \
147 $(call if_ena,x264,--enable-libx264) \
148 $(call if_ena,x265,--enable-libx265) \
149 --extra-cflags="-Wno-attributes \
150 $(call if_want,NV,$(inc_ffnvcodec)) \
151 $(call inc_path,twolame) \
152 $(call inc_path,lame) \
153 $(call inc_path,libaom) \
154 $(call inc_path,dav1d) \
155 $(call inc_path,libwebp) \
156 $(call inc_path,openjpeg) \
157 $(call inc_path,libogg) \
158 $(call inc_path,opus) \
159 $(call inc_path,libvorbis) \
160 $(call inc_path,libtheora) \
161 $(call inc_path,libvpx) \
162 $(call inc_path,x264) \
163 $(call inc_path,x265)" \
164 --extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
166 --extra-libs="-Wl,--start-group \
167 $(call ld_path,twolame,libtwolame/.libs) \
168 $(call ld_path,lame,libmp3lame/.libs) \
169 $(call ld_path,libaom,usr/local/lib) \
170 $(call ld_path,dav1d,usr/local/lib) \
171 $(call ld_path,libwebp,usr/local/lib) \
172 $(call ld_path,openjpeg,bin) \
173 $(call ld_path,opus,.libs) \
174 $(call ld_path,libogg,lib/.libs) \
175 $(call ld_path,libvorbis,lib/.libs) \
176 $(call ld_path,libtheora,lib/.libs) \
177 $(call ld_path,libvpx) \
178 $(call ld_path,x264) \
179 $(call ld_path,x265) \
181 -Wl,--end-group -lm -lstdc++ -pthread \
182 $(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
184 #cmake_config=echo "exec cmake \$$$$@ $(1)" > ./configure; chmod +x ./configure;
185 cmake_config=echo 'cmake "$$$$@" "$(1)"' > ./configure; chmod +x ./configure;
186 libbthread.cfg_vars?= echo "exec true" > ./configure; chmod +x ./configure;
187 a52dec.mak_params?= ; cd $(call bld_path,a52dec,include); ln -sf . a52dec
188 a52dec.cflags?= "$(call inc_path,djbfft)"
189 a52dec.ldflags?= "$(call ld_path,djbfft)"
190 a52dec.cfg_vars?= CFLAGS+=" -U__FreeBSD__ $(call inc_path,djbfft)" LIBS+=" $(call ld_path,djbfft)"; autoreconf -ifv && automake -caf;
191 a52dec.cfg_params?=--enable-djbfft --disable-oss
192 djbfft.cfg_vars?=echo "$(call bld_path,djbfft)" > conf-home; \
193 (CFLAGS="$(CFLAGS)"; $(CFG_VARS)$(if $(CFG_VARS),; )echo "$(CC) $$$$CFLAGS") > conf-cc; \
194 echo "exec true" > ./configure; chmod +x ./configure;
195 djbfft.mak_params?=; cd $(call bld_path,djbfft); ln -sf djbfft.a libdjbfft.a
196 audiofile.cfg_params?=--enable-shared=no --disable-doxygen-docs --enable-debug=no --enable-examples=no
197 audiofile.mak_params?=LIBS="-lm -lstdc++"
198 flac.cfg_vars?= CFLAGS+=" -O3 -funroll-loops " CPPFLAGS+=" -DNDEBUG " CXXFLAGS+=" -O2 "
199 flac.cfg_params?= --enable-shared=no --disable-doxygen-docs
200 flac.cflags?="$(call inc_path,libogg) $(call ld_path,libogg,src/.libs)"
201 ffnvcodec.cfg_vars=echo "exec true" > ./configure; chmod +x ./configure;
202 giflib.cfg_vars=echo "exec true" > ./configure; chmod +x ./configure;
203 lame.cfg_vars?= CFLAGS+=" -O"
204 lame.cfg_params?=--enable-shared=no
205 lame.mak_params?= ; cd $(call bld_path,lame,include); ln -sf . lame
206 libaom.cfg_vars?= mkdir aom.build && cd aom.build && $(call cmake_config,..)
207 libaom.cfg_params?= -DENABLE_TESTS=no -DCMAKE_BUILD_TYPE=Release -DENABLE_DOCS=no -DENABLE_SHARED=no -DCMAKE_INSTALL_LIBDIR=lib \
208 -DENABLE_EXAMPLES=no -DCMAKE_INSTALL_PREFIX=$(call bld_path,libaom)/usr/local
209 libaom.mak_params?= ; $(MAKE) -C libaom*/aom.build install
210 dav1d.cfg_vars?=echo "echo dav1d custom make" >> configure; chmod +x ./configure;
211 dav1d.mak_params?=; $(MAKE) -C dav1d* install DESTDIR="$(call bld_path,dav1d)"
212 libwebp.cfg_vars?= mkdir build && cd build && $(call cmake_config,..)
213 libwebp.mak_params?= -C build all install DESTDIR=$(call bld_path,libwebp)
214 mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,build)"
215 mjpegtools.cfg_vars?= ./autogen.sh;
216 mjpegtools.cfg_params?= --enable-shared=no --without-libquicktime --without-libdv \
217 --without-libpng --without-dga --without-gtk --without-libsdl --without-sdlgfx
218 mjpegtools.mak_params?= all
219 ladspa.cfg_vars?= CFLAGS+=' -Dinline="" '; autoreconf -ifv && automake -caf;
220 ladspa.mak_params?=; $(MAKE) -C ladspa* install DESTDIR=$(call bld_path,ladspa)
221 libavc1394.cfg_vars?= PKG_CONFIG_PATH="$(call bld_path,libraw1394)";autoreconf -ifv -I m4 && automake -caf;
222 libavc1394.cflags?="$(call inc_path,libraw1394)"
223 libavc1394.ldflags?="$(call ld_path,libraw1394,src/.libs)"
224 libavc1394.cfg_params?= PKG_CONFIG_PATH="$(call bld_path,libraw1394)" --enable-shared=no
225 libavc1394.mak_params?=; cd $(call bld_path,libavc1394); ln -sf ../librom1394/rom1394.h libavc1394/.
226 libdv.cfg_vars?= autoreconf -ifv -I m4 && automake -caf;
227 libdv.cfg_params?= --disable-gtk --enable-shared=no
228 libiec61883.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394); autoreconf -ifv && automake -caf;
229 libiec61883.cflags?="$(call inc_path,libraw1394)"
230 libiec61883.ldflags?="$(call ld_path,libraw1394,src/.libs)"
231 libiec61883.cfg_params?= PKG_CONFIG_PATH="$(call bld_path,libraw1394)" --enable-shared=no
232 libiec61883.mak_params?=; cd $(call bld_path,libiec61883,src); ln -sf . libiec61883
233 libjpeg.cfg_vars?= mkdir build && cd build && $(call cmake_config,..)
234 libjpeg.cfg_params?= -DENABLE_SHARED=no -DCMAKE_INSTALL_LIBDIR=lib
235 libjpeg.mak_params?= -C build all install DESTDIR=$(call bld_path,libjpeg)
236 libogg.cfg_vars?= autoreconf -ifv -I m4 && automake -caf;
237 libogg.cfg_params?= --enable-shared=no
238 libraw1394.cfg_params?= --enable-shared=no; ln -sf src libraw1394
239 libtheora.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libogg):$(call bld_path,libvorbis); autoreconf -ifv -I m4 && automake -caf;
240 libiec61883.cflags?="$(call inc_path,libraw1394)"
241 libtheora.cflags?="$(call inc_path,libogg) $(call inc_path,libvorbis)"
242 libtheora.ldflags?="$(call ld_path,libvorbis,lib/.libs) $(call ld_path,libogg,src/.libs)"
243 libtheora.cfg_params?= --disable-examples --disable-spec --enable-shared=no
244 libuuid.cfg_vars?= autoreconf -ifv -I m4 && automake -caf;
245 libuuid.cfg_params?=--enable-shared=no
246 libvorbis.cfg_params?= --disable-oggtest --enable-shared=no
247 openjpeg.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_CODEC:BOOL=OFF
248 openjpeg.cfg_vars?=$(call cmake_config,.)
249 openjpeg.mak_params?= ; cd $(call bld_path,openjpeg,src/lib/openjp2); ln -sf . openjpeg-2.1
250 opencv.cfg_vars?=$(call cmake_config,.)
251 opencv.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
252 openexr.cfg_vars?=true; \#
253 openexr.mak_vars?=true; \#
254 opus.cfg_params?= --disable-extra-programs
255 speech_tools.mak_params?=-j1
256 tiff.cfg_vars+=LIBS+=" -lpthread"; autoreconf -ifv -I m4 && automake -caf;
257 tiff.cfg_params+= --disable-libdeflate --disable-lerc --enable-shared=no --disable-zstd $(call if_pkg,libwebp,\
258 --with-webp-include-dir=$(call pkg_incl,libwebp)\
259 --with-webp-lib-dir=$(call pkg_libs,libwebp))\
260 $(call if_npkg,libwebp,--disable-webp)
261 twolame.cfg_params?=--enable-shared=no
262 x264.cfg_params?= --enable-static --enable-pic
263 x265.cfg_vars?=$(call cmake_config,source)
264 x265.cfg_params?= -DENABLE_SHARED=no
265 libvpx.cfg_params?= --enable-pic --disable-avx512 --enable-vp9-highbitdepth --disable-examples --disable-unit_tests
266 libdpx.cfg_vars?= libtoolize; aclocal; autoconf; automake -a;
269 pkg_cfg=$(call bld_path,$(1),usr/local/lib/pkgconfig):
270 LV2_PKGCFG:=$(subst : ,:,$(foreach p,lv2 serd sord sratom lilv suil,$(call pkg_cfg,$(p))))
274 $(1).cfg_vars+=./waf --version; find .waf* -type f -name "*.py" | \
275 while read f; do sed -e '/StopIter/d' -i "$(DS)f"; done; \
276 echo 'exec ./waf configure "$(DS)@"' > ./configure; chmod +x \
277 ./configure; PKG_CONFIG_PATH=$(LV2_PKGCFG):$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LV2_LIBPATH)
279 CFLAGS="-I$(call bld_path,lv2) $(foreach f,$(2), $(call inc_path,$(f))) -fPIC -std=c99"\
280 LDFLAGS="-lm `pkg-config --libs x11` $(foreach f,$(2), $(call ld_path,$(f),usr/local/lib)) "
281 $(1).mak_vars=(echo "all:"; echo " ./waf -v build") > $(call bld_path,$(1),Makefile);
282 $(1).mak_params+=; ( cd $(1)*; ./waf install --destdir=$(call bld_path,$(1)) )
285 SYS_LIB:=$(notdir $(lastword $(wildcard /usr/lib /usr/lib32 /usr/lib64)))
286 SYS_LV2:=$(lastword $(wildcard /usr/$(SYS_LIB)/lv2 /usr/local/$(SYS_LIB)/lv2))
287 $(if $(SYS_LV2),,$(eval SYS_LV2:=/usr/$(SYS_LIB)/lv2))
288 lv2.cfg_params?= --lv2dir=$(SYS_LV2)
289 SYS_LV2_PATH:=/usr/$(SYS_LIB)/lv2: /usr/local/$(SYS_LIB)/lv2:
290 DFT_LV2_PATH:= /usr/lib64/lv2: /usr/lib/lv2: /usr/local/lib64/lv2: /usr/local/lib/lv2:
291 LV2_PATH:=$(subst : ,:,$(SYS_LV2_PATH)$(filter-out $(SYS_LV2_PATH),$(DFT_LV2_PATH)))
292 lilv.cfg_params?= --static --default-lv2-path=$(LV2_PATH)
293 sratom.cfg_params?= --static --no-shared
294 serd.cfg_params?= --static --no-shared
295 sord.cfg_params?= --static --no-shared
296 lilv.cfg_params?= --static --dyn-manifest
297 suil.cfg_params?= --static --no-qt --no-qt5
299 $(eval $(call waf-setup,lv2))
300 $(eval $(call waf-setup,serd))
301 $(eval $(call waf-setup,sord, serd))
302 $(eval $(call waf-setup,sratom, serd sord lv2))
303 $(eval $(call waf-setup,lilv, lv2 sratom serd sord))
304 $(eval $(call waf-setup,suil, lv2))
306 # add softlinks for legacy paths
307 waf_link=$(1).mak_params+=; (cd $(1)*; ln -s $(1)-0/$(1) usr/local/include/.)
308 $(foreach p,sratom serd sord lilv suil,$(eval $(call waf_link,$(p))))
311 $(foreach tgt,$(TARGETS), \
312 $(if $($(tgt).cflags),$(eval $(tgt).cfg_vars+=CFLAGS+=$($(tgt).cflags))))
313 $(foreach tgt,$(TARGETS), \
314 $(if $($(tgt).cppflags),$(eval $(tgt).cfg_vars+=CPPFLAGS+=$($(tgt).cppflags))))
315 $(foreach tgt,$(TARGETS), \
316 $(if $($(tgt).ldflags),$(eval $(tgt).cfg_vars+=LDFLAGS+=$($(tgt).ldflags))))
322 #$(eval $(call std-build,pkg,deps...))
324 ifeq ($(MAKECMDGOALS),rules)
330 uname := $(shell uname -o)
331 ifeq ($(uname), Android)
332 $(call rules,$(call std-build,libbthread))
334 $(call rules,$(call std-build,a52dec,djbfft))
335 $(call rules,$(call std-build,djbfft))
336 $(call rules,$(call std-build,audiofile))
337 $(call rules,$(call std-build,encore))
338 $(call rules,$(call std-build,esound,audiofile))
339 $(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus \
340 libtheora x264 x265 libvpx libaom dav1d libwebp \
341 $(call if_want,NV, ffnvcodec)))
342 $(call rules,$(call std-build,fftw))
343 $(call rules,$(call std-build,flac,libogg))
344 $(call rules,$(call std-build,giflib))
345 $(call rules,$(call std-build,ilmBase, openexr))
346 $(call rules,$(call std-build,ladspa))
347 $(call rules,$(call std-build,lame))
348 $(call rules,$(call std-build,libaom))
349 $(call rules,$(call std-build,dav1d))
350 $(call rules,$(call std-build,libwebp))
351 $(call rules,$(call std-build,libavc1394,libraw1394))
352 $(call rules,$(call std-build,libdv))
353 $(call rules,$(call std-build,libiec61883,libraw1394))
354 $(call rules,$(call std-build,libjpeg))
355 $(call rules,$(call std-build,libogg))
356 $(call rules,$(call std-build,libraw1394))
357 $(call rules,$(call std-build,libsndfile))
358 $(call rules,$(call std-build,libtheora, libogg libvorbis))
359 $(call rules,$(call std-build,libuuid))
360 $(call rules,$(call std-build,libvorbis))
361 $(call rules,$(call std-build,mjpegtools, libjpeg))
362 $(call rules,$(call std-build,opencv))
363 $(call rules,$(call std-build,openexr))
364 $(call rules,$(call std-build,openExr, ilmBase))
365 $(call rules,$(call std-build,openjpeg))
366 $(call rules,$(call std-build,opus))
367 $(call rules,$(call std-build,speech_tools))
368 $(call rules,$(call std-build,tiff, libwebp))
369 $(call rules,$(call std-build,twolame))
370 $(call rules,$(call std-build,x264))
371 $(call rules,$(call std-build,x265))
372 $(call rules,$(call std-build,libvpx))
373 $(call rules,$(call std-build,lv2))
374 $(call rules,$(call std-build,serd))
375 $(call rules,$(call std-build,sord, serd))
376 $(call rules,$(call std-build,sratom, serd sord lv2))
377 $(call rules,$(call std-build,lilv, lv2 sratom serd sord))
378 $(call rules,$(call std-build,suil, lv2))
379 $(call rules,$(call std-build,ffnvcodec))
380 $(call rules,$(call std-build,libdpx))
382 # specialize festival, multiple tarballs
384 .PHONY: festival festival-configure festival-src
385 festival: $(call pkg-built,festival)
386 festival-configure: $(call pkg-config,festival)
387 festival-src: $(call pkg-source,festival)
389 rm -rf festival* $(BLD)/festival.*
391 $(call pkg-source,festival):
392 for f in src/festival* src/festlex_* src/festvox_*; do tar -xJf $$f; done
395 $(call pkg-config,festival): $(call pkg-source,festival) $(call pkg-built,speech_tools)
396 cd festival* && [ -f ./configure ] && \
400 $(call pkg-built,festival): $(call pkg-config,festival)
401 $(MAKE) -C festival* -j1
405 for f in $(static_pkgs); do rm -rf $$f*; done
409 cp -a $(ver_mjpegtools)/mpeg2enc/mpeg2enc $(BINDIR)/.
410 cp -a $(ver_mjpegtools)/mplex/mplex $(BINDIR)/.
413 find . -type f -name '*.o' -delete
415 # not WANT_CIN_3RDPARTY
422 @echo $($(subst val-,,$@))