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 $($(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))
65 #$(eval $(call std-build,pkg,deps...))
66 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
67 #$(pkg.cppflags) added as CPPFLAGS+=$(cppflags) to pkg.vars
68 #$(pkg.cfg_vars) prepended to configure
69 #$(pkg.cfg_params) appended to configure
70 #$(pkg.mak_vars) prepended to make
71 #$(pkg.mak_params) appended to make
75 .PHONY: $(1) $(1)-configure $(1)-src $(1)-clean
76 $(1): $(call pkg-built,$(1))
77 $(1)-configure: $(call pkg-config,$(1))
78 $(1)-src: $(call pkg-source,$(1))
80 rm -rf $(1)* $(BLD)/$(1).*
82 $(call pkg-source,$(1)):
83 $(call unpack,$(call tarball,$(1))) \
84 $(foreach pch,$(sort $(wildcard src/$(notdir $(ver_$(1))).patch*)),
85 patch -d $(1)* -p1 < $(pch))
88 $(call pkg-config,$(1)): $(call pkg-source,$(1)) $(foreach dep,$(2),$(call bld_depends,$(dep)))
89 @echo "CONFIGURING $(1)"
91 $($(1).cfg_vars) $(CFG_VARS) ./configure $($(1).cfg_params) $(CFG_PARAMS)
94 $(call pkg-built,$(1)): $(call pkg-config,$(1))
95 +$($(1).mak_vars) $(MAK_VARS) $(MAKE) -C $(1)* $($(1).mak_params) $(MAK_PARAMS)
100 TARGETS := $(static_blds)
112 pc_libwebp=libwebp libwebpmux
114 pc_openjpeg=libopenjp2
115 pc_libvorbis=vorbis vorbisenc
121 encore.cfg_vars= true ||
122 esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile) -laudiofile"
123 esound.cfg_vars+= AUDIOFILE_LIBS="$(call ld_path,audiofile,libaudiofile/.libs)"
124 esound.cfg_params= --enable-shared=no --with-pic
125 esound.mak_vars+= CFLAGS=""
126 esound.ldflags=" -lm -lstdc++"
127 fftw.cfg_params= --disable-fortran --enable-shared=no
129 --enable-pthreads --enable-gpl --disable-ffplay \
130 $(call if_want,VAAPI,--enable-vaapi,--disable-vaapi) \
131 $(call if_want,VDPAU,--enable-vdpau,--disable-vdpau) \
132 $(call if_want,NV, --enable-nvenc --enable-nvdec --enable-ffnvcodec) \
133 $(call if_ena,twolame,--enable-libtwolame) \
134 $(call if_ena,openjpeg,--enable-libopenjpeg) \
135 $(call if_ena,lame,--enable-libmp3lame) \
136 $(call if_ena,libaom,--enable-libaom) \
137 $(call if_ena,dav1d,--enable-libdav1d) \
138 $(call if_ena,libwebp,--enable-libwebp) \
139 $(call if_ena,opus,--enable-libopus) \
140 $(call if_ena,libvorbis,--enable-libvorbis) \
141 $(call if_ena,libtheora,--enable-libtheora) \
142 $(call if_ena,libvpx,--enable-libvpx) \
143 $(call if_ena,x264,--enable-libx264) \
144 $(call if_ena,x265,--enable-libx265) \
145 --extra-cflags="-Wno-attributes \
146 $(call if_want,NV,$(inc_ffnvcodec)) \
147 $(call inc_path,twolame) \
148 $(call inc_path,lame) \
149 $(call inc_path,libaom) \
150 $(call inc_path,dav1d) \
151 $(call inc_path,libwebp) \
152 $(call inc_path,openjpeg) \
153 $(call inc_path,libogg) \
154 $(call inc_path,opus) \
155 $(call inc_path,libvorbis) \
156 $(call inc_path,libtheora) \
157 $(call inc_path,libvpx) \
158 $(call inc_path,x264) \
159 $(call inc_path,x265)" \
160 --extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
162 --extra-libs="-Wl,--start-group \
163 $(call ld_path,twolame,libtwolame/.libs) \
164 $(call ld_path,lame,libmp3lame/.libs) \
165 $(call ld_path,libaom,usr/local/lib) \
166 $(call ld_path,dav1d,usr/local/lib) \
167 $(call ld_path,libwebp,usr/local/lib) \
168 $(call ld_path,openjpeg,bin) \
169 $(call ld_path,opus,.libs) \
170 $(call ld_path,libogg,lib/.libs) \
171 $(call ld_path,libvorbis,lib/.libs) \
172 $(call ld_path,libtheora,lib/.libs) \
173 $(call ld_path,libvpx) \
174 $(call ld_path,x264) \
175 $(call ld_path,x265) \
177 -Wl,--end-group -lm -lstdc++ -pthread \
178 $(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
180 #cmake_config=echo "exec cmake \$$$$@ $(1)" > ./configure; chmod +x ./configure;
181 cmake_config=echo 'cmake "$$$$@" "$(1)"' > ./configure; chmod +x ./configure;
182 a52dec.mak_params?= ; cd $(call bld_path,a52dec,include); ln -sf . a52dec
183 a52dec.cfg_vars?= CFLAGS+=" -U__FreeBSD__ $(call inc_path,djbfft)" LIBS+=" $(call ld_path,djbfft)"
184 a52dec.cfg_params?=--enable-djbfft
185 djbfft.cfg_vars?=echo "$(call bld_path,djbfft)" > conf-home; \
186 (CFLAGS="$(CFLAGS)"; $(CFG_VARS)$(if $(CFG_VARS),; )echo "$(CC) $$$$CFLAGS") > conf-cc; \
187 echo > ./configure; chmod +x ./configure;
188 djbfft.mak_params?=; cd $(call bld_path,djbfft); ln -sf djbfft.a libdjbfft.a
189 audiofile.cfg_params?=--enable-shared=no
190 audiofile.mak_params?=LIBS="-lm -lstdc++"
191 flac.cfg_params?= --enable-shared=no
192 flac.cflags?="$(call inc_path,libogg) $(call ld_path,libogg,src/.libs)"
193 giflib.cfg_params=echo "exec true" > ./configure; chmod +x ./configure;
194 ilmbase.cfg_vars= CFLAGS+=" -Wno-narrowing" CXXFLAGS+=" -Wno-narrowing"
195 ilmbase.cfg_params?=--prefix=$(call bld_path,ilmbase,usr)
196 ilmbase.mak_params?=; $(MAKE) -C ilmbase* install; cd $(call bld_path,ilmbase); ln -sf lib64 usr/lib
197 lame.cfg_vars?= CFLAGS+=" -O"
198 lame.cfg_params?=--enable-shared=no
199 lame.mak_params?= ; cd $(call bld_path,lame,include); ln -sf . lame
200 libaom.cfg_vars?=$(call cmake_config,aom-master)
201 libaom.cfg_params?= -DENABLE_SHARED=no -DCMAKE_INSTALL_LIBDIR=lib \
202 -DCMAKE_INSTALL_PREFIX=$(call bld_path,libaom)/usr/local
203 libaom.mak_params?= ; $(MAKE) -C libaom* install
204 dav1d.cfg_vars?=echo "echo dav1d custom make" >> configure; chmod +x ./configure;
205 dav1d.mak_params?=; $(MAKE) -C dav1d* install DESTDIR="$(call bld_path,dav1d)"
206 libwebp.cfg_vars?= mkdir build && cd build && $(call cmake_config,..)
207 libwebp.mak_params?= -C build all install DESTDIR=$(call bld_path,libwebp)
208 mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,.libs)"
209 mjpegtools.mak_params?=; ln -s . $(call bld_path,mjpegtools,utils)/mjpegtools
210 mjpegtools.cfg_params?= --enable-shared=no --without-libsdl --without-v4l
211 ladspa.cfg_vars?= CFLAGS+=' -Dinline="" '
212 ladspa.mak_params?=; $(MAKE) -C ladspa* install DESTDIR=$(call bld_path,ladspa)
213 libavc1394.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
214 libavc1394.cflags?="$(call inc_path,libraw1394)"
215 libavc1394.ldflags?="$(call ld_path,libraw1394,src/.libs)"
216 libavc1394.cfg_params?= --enable-shared=no
217 libavc1394.mak_params?=; cd $(call bld_path,libavc1394); ln -sf ../librom1394/rom1394.h libavc1394/.
218 libdv.cfg_params?= --disable-gtk --enable-shared=no
219 libiec61883.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
220 libiec61883.cflags?="$(call inc_path,libraw1394)"
221 libiec61883.ldflags?="$(call ld_path,libraw1394,src/.libs)"
222 libiec61883.cfg_params?= --enable-shared=no
223 libiec61883.mak_params?=; cd $(call bld_path,libiec61883,src); ln -sf . libiec61883
224 libjpeg.cfg_params?= --enable-shared=no
225 libogg.cfg_params?= --enable-shared=no
226 libraw1394.cfg_params?= --enable-shared=no; ln -sf src libraw1394
227 libtheora.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libogg):$(call bld_path,libvorbis)
228 libtheora.cflags?="$(call inc_path,libogg) $(call inc_path,libvorbis)"
229 libtheora.ldflags?="$(call ld_path,libvorbis,lib/.libs) $(call ld_path,libogg,src/.libs)"
230 libtheora.cfg_params?= --disable-examples --disable-spec --enable-shared=no
231 libuuid.cfg_params?=--enable-shared=no
232 libvorbis.cfg_params?= --disable-oggtest --enable-shared=no
233 openjpeg.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
234 openjpeg.cfg_vars?=$(call cmake_config,.)
235 openjpeg.mak_params?= ; cd $(call bld_path,openjpeg,src/lib/openjp2); ln -sf . openjpeg-2.1
236 opencv.cfg_vars?=$(call cmake_config,.)
237 opencv.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
238 openexr.cfg_vars?=LD_LIBRARY_PATH=$(call bld_path,ilmbase,usr/lib)
239 openexr.cfg_params?=--enable-shared=no --with-ilmbase-prefix=$(call bld_path,ilmbase,usr)
240 speech_tools.mak_params?=-j1
241 tiff.cfg_params+= --enable-shared=no --disable-zstd $(call if_npkg,libwebp,--without-webp)
242 twolame.cfg_params?=--enable-shared=no
243 x264.cfg_params?= --enable-static --enable-pic
244 x265.cfg_vars?=$(call cmake_config,source)
245 x265.cfg_params?= -DENABLE_SHARED=no
246 libvpx.cfg_params?= --enable-pic
249 pkg_cfg=$(call bld_path,$(1),usr/local/lib/pkgconfig):
250 LV2_PKGCFG:=$(subst : ,:,$(foreach p,lv2 serd sord sratom lilv suil,$(call pkg_cfg,$(p))))
254 $(1).cfg_vars+=./waf --version; find .waf* -type f -name "*.py" | \
255 while read f; do sed -e '/StopIter/d' -i "$(DS)f"; done; \
256 echo 'exec ./waf configure "$(DS)@"' > ./configure; chmod +x \
257 ./configure; PKG_CONFIG_PATH=$(LV2_PKGCFG) LD_LIBRARY_PATH=$(LV2_LIBPATH)
259 CFLAGS="-I$(call bld_path,lv2) $(foreach f,$(2), $(call inc_path,$(f))) -fPIC -std=c99"\
260 LDFLAGS="-lm $(foreach f,$(2), $(call ld_path,$(f),usr/local/lib)) "
261 $(1).mak_vars=(echo "all:"; echo " ./waf -v build") > $(call bld_path,$(1),Makefile);
262 $(1).mak_params+=; ( cd $(1)*; ./waf install --destdir=$(call bld_path,$(1)) )
265 SYS_LIB:=$(notdir $(lastword $(wildcard /usr/lib /usrlib32 /usr/lib64)))
266 SYS_LV2:=$(lastword $(wildcard /usr/$(SYS_LIB)/lv2 /usr/local/$(SYS_LIB)/lv2))
267 $(if $(SYS_LV2),,$(eval SYS_LV2:=/usr/$(SYS_LIB)/lv2))
268 lv2.cfg_params?= --lv2dir=$(SYS_LV2)
269 SYS_LV2_PATH:=/usr/$(SYS_LIB)/lv2: /usr/local/$(SYS_LIB)/lv2:
270 DFT_LV2_PATH:= /usr/lib64/lv2: /usr/lib/lv2: /usr/local/lib64/lv2: /usr/local/lib/lv2:
271 LV2_PATH:=$(subst : ,:,$(SYS_LV2_PATH)$(filter-out $(SYS_LV2_PATH),$(DFT_LV2_PATH)))
272 lilv.cfg_params?= --static --default-lv2-path=$(LV2_PATH)
273 sratom.cfg_params?= --static --no-shared
274 serd.cfg_params?= --static --no-shared
275 sord.cfg_params?= --static --no-shared
276 lilv.cfg_params?= --static --dyn-manifest
277 suil.cfg_params?= --static --no-qt
279 $(eval $(call waf-setup,lv2))
280 $(eval $(call waf-setup,serd))
281 $(eval $(call waf-setup,sord, serd))
282 $(eval $(call waf-setup,sratom, serd sord lv2))
283 $(eval $(call waf-setup,lilv, lv2 sratom serd sord))
284 $(eval $(call waf-setup,suil, lv2))
286 # add softlinks for legacy paths
287 waf_link=$(1).mak_params+=; (cd $(1)*; ln -s $(1)-0/$(1) usr/local/include/.)
288 $(foreach p,sratom serd sord lilv suil,$(eval $(call waf_link,$(p))))
291 $(foreach tgt,$(TARGETS), \
292 $(if $($(tgt).cflags),$(eval $(tgt).cfg_vars+=CFLAGS+=$($(tgt).cflags))))
293 $(foreach tgt,$(TARGETS), \
294 $(if $($(tgt).cppflags),$(eval $(tgt).cfg_vars+=CPPFLAGS+=$($(tgt).cppflags))))
295 $(foreach tgt,$(TARGETS), \
296 $(if $($(tgt).ldflags),$(eval $(tgt).cfg_vars+=LDFLAGS+=$($(tgt).ldflags))))
302 #$(eval $(call std-build,pkg,deps...))
304 ifeq ($(MAKECMDGOALS),rules)
310 $(call rules,$(call std-build,a52dec,djbfft))
311 $(call rules,$(call std-build,djbfft))
312 $(call rules,$(call std-build,audiofile))
313 $(call rules,$(call std-build,encore))
314 $(call rules,$(call std-build,esound,audiofile))
315 $(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus \
316 libtheora x264 x265 libvpx libaom dav1d libwebp \
317 $(call if_want,NV, ffnvcodec)))
318 $(call rules,$(call std-build,fftw))
319 $(call rules,$(call std-build,flac,libogg))
320 $(call rules,$(call std-build,giflib))
321 $(call rules,$(call std-build,ilmbase))
322 $(call rules,$(call std-build,ladspa))
323 $(call rules,$(call std-build,lame))
324 $(call rules,$(call std-build,libaom))
325 $(call rules,$(call std-build,dav1d))
326 $(call rules,$(call std-build,libwebp))
327 $(call rules,$(call std-build,libavc1394,libraw1394))
328 $(call rules,$(call std-build,libdv))
329 $(call rules,$(call std-build,libiec61883,libraw1394))
330 $(call rules,$(call std-build,libjpeg))
331 $(call rules,$(call std-build,libogg))
332 $(call rules,$(call std-build,libraw1394))
333 $(call rules,$(call std-build,libsndfile))
334 $(call rules,$(call std-build,libtheora, libogg libvorbis))
335 $(call rules,$(call std-build,libuuid))
336 $(call rules,$(call std-build,libvorbis))
337 $(call rules,$(call std-build,mjpegtools, libjpeg))
338 $(call rules,$(call std-build,opencv))
339 $(call rules,$(call std-build,openexr, ilmbase))
340 $(call rules,$(call std-build,openjpeg))
341 $(call rules,$(call std-build,opus))
342 $(call rules,$(call std-build,speech_tools))
343 $(call rules,$(call std-build,tiff))
344 $(call rules,$(call std-build,twolame))
345 $(call rules,$(call std-build,x264))
346 $(call rules,$(call std-build,x265))
347 $(call rules,$(call std-build,libvpx))
348 $(call rules,$(call std-build,lv2))
349 $(call rules,$(call std-build,serd))
350 $(call rules,$(call std-build,sord, serd))
351 $(call rules,$(call std-build,sratom, serd sord lv2))
352 $(call rules,$(call std-build,lilv, lv2 sratom serd sord))
353 $(call rules,$(call std-build,suil, lv2))
354 $(call rules,$(call std-build,ffnvcodec))
356 # specialize festival, multiple tarballs
358 .PHONY: festival festival-configure festival-src
359 festival: $(call pkg-built,festival)
360 festival-configure: $(call pkg-config,festival)
361 festival-src: $(call pkg-source,festival)
363 rm -rf festival* $(BLD)/festival.*
365 $(call pkg-source,festival):
366 for f in src/festival* src/festlex_* src/festvox_*; do tar -xJf $$f; done
369 $(call pkg-config,festival): $(call pkg-source,festival) $(call pkg-built,speech_tools)
370 cd festival* && [ -f ./configure ] && \
374 $(call pkg-built,festival): $(call pkg-config,festival)
375 $(MAKE) -C festival* -j1
379 for f in $(static_pkgs); do rm -rf $$f*; done
383 cp -a $(ver_mjpegtools)/mpeg2enc/mpeg2enc $(BINDIR)/.
384 cp -a $(ver_mjpegtools)/mplex/mplex $(BINDIR)/.
386 # not WANT_CIN_3RDPARTY
393 @echo $($(subst val-,,$@))