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
26 TOPDIR ?= $(CURDIR)/..
27 include $(TOPDIR)/global_config
28 -include $(TOPDIR)/cin_config
29 BLD := $(THIRDPARTY)/build
31 ifneq ($(WANT_CIN_3RDPARTY),no)
33 # package build flags, if needed
34 # need frame pointer for debugs and helps with profiling
35 # NOTE: the trailing blank is MANDITORY or the builds fail
36 # due to bugs in the build scripts from auto*
37 CFLAGS_ ?= -g -O2 -fno-omit-frame-pointer
39 LDFLAGS += $(LDFLAGS_)
40 CXXFLAGS += $(CXXFLAGS_)
42 pkg-source=$(BLD)/$(1).source
43 pkg-config=$(BLD)/$(1).configure
44 pkg-built=$(BLD)/$(1).built
46 ext=$(lastword $(subst ., ,$(1)))
47 tarball=$(if $($(1).git),$(1).git,$(lastword $(sort $(wildcard src/$(1)*.tar.*))))
48 unpack=$(call unpack_$(call ext,$(1)),$(1))
49 unpack_git=git clone $($(1)) $(1)
50 unpack_gz=tar -xzf $(1)
51 unpack_bz2=tar -xjf $(1)
52 unpack_xz=tar -xJf $(1)
53 bld_depends=$(if $(ver_$(1)),$(call pkg-built,$(1)))
54 bld_path=$(ver_$(1))/$(2)
55 if_pkg=$(if $(ver_$(1)),$(2))
56 if_npkg=$(if $(ver_$(1)),,$(2))
57 inc_path=$(call if_pkg,$(1),$(inc_$(1)))
58 ld_path=$(call if_pkg,$(1),-L$(call bld_path,$(1),$(2)) $(lib_$(1)))
60 #$(eval $(call std-build,pkg,deps...))
61 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
62 #$(pkg.cppflags) added as CPPFLAGS+=$(cppflags) to pkg.vars
63 #$(pkg.cfg_vars) prepended to configure
64 #$(pkg.cfg_params) appended to configure
65 #$(pkg.mak_vars) prepended to make
66 #$(pkg.mak_params) appended to make
70 .PHONY: $(1) $(1)-configure $(1)-src $(1)-clean
71 $(1): $(call pkg-built,$(1))
72 $(1)-configure: $(call pkg-config,$(1))
73 $(1)-src: $(call pkg-source,$(1))
75 rm -rf $(1)* $(BLD)/$(1).*
77 $(call pkg-source,$(1)):
78 $(call unpack,$(call tarball,$(1))) \
79 $(foreach pch,$(sort $(wildcard src/$(notdir $(ver_$(1))).patch*)),
80 patch -d $(1)* -p1 < $(pch))
83 $(call pkg-config,$(1)): $(call pkg-source,$(1)) $(foreach dep,$(2),$(call bld_depends,$(dep)))
84 @echo "CONFIGURING $(1)"
86 $($(1).cfg_vars) $(CFG_VARS) ./configure $($(1).cfg_params) $(CFG_PARAMS)
89 $(call pkg-built,$(1)): $(call pkg-config,$(1))
90 +$($(1).mak_vars) $(MAK_VARS) $(MAKE) -C $(1)* $($(1).mak_params) $(MAK_PARAMS)
95 TARGETS := $(static_blds)
105 encore.cfg_vars= true ||
106 esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile,libaudiofile) -laudiofile"
107 esound.cfg_vars+= AUDIOFILE_LIBS="$(call ld_path,audiofile,libaudiofile/.libs)"
108 esound.cfg_params= --enable-shared=no --with-pic
109 esound.mak_vars+= CFLAGS=""
110 esound.ldflags=" -lm -lstdc++"
111 fftw.cfg_params= --disable-fortran --enable-shared=no
113 --enable-pthreads --enable-gpl --disable-ffplay \
114 $(if $(WANT_VAAPI),--enable-vaapi,--disable-vaapi) \
115 $(if $(WANT_VDPAU),--enable-vdpau,--disable-vdpau) \
116 $(if $(WANT_NV), --enable-nvenc --enable-nvdec) \
117 $(call if_pkg,twolame,--enable-libtwolame) \
118 $(call if_pkg,openjpeg,--enable-libopenjpeg) \
119 $(call if_pkg,lame,--enable-libmp3lame) \
120 $(call if_pkg,libaom,--enable-libaom) \
121 $(call if_pkg,libwebp,--enable-libwebp) \
122 $(call if_pkg,opus,--enable-libopus) \
123 $(call if_pkg,libvorbis,--enable-libvorbis) \
124 $(call if_pkg,libtheora,--enable-libtheora) \
125 $(call if_pkg,libvpx,--enable-libvpx) \
126 $(call if_pkg,x264,--enable-libx264) \
127 $(call if_pkg,x265,--enable-libx265) \
128 --extra-cflags="-Wno-attributes \
129 $(if $(WANT_NV), $(inc_ffnvcodec)) \
130 $(call inc_path,twolame,libtwolame) \
131 $(call inc_path,lame,include) \
132 $(call inc_path,libaom,usr/local/include) \
133 $(call inc_path,libwebp,usr/local/include) \
134 $(call inc_path,openjpeg,src/lib/openjp2) \
135 $(call inc_path,libogg,include) \
136 $(call inc_path,opus,include) \
137 $(call inc_path,libvorbis,include) \
138 $(call inc_path,libtheora,include) \
139 $(call inc_path,libvpx) \
140 $(call inc_path,x264) \
141 $(call inc_path,x265) \
142 $(call inc_path,x265,source)" \
143 --extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
145 --extra-libs="-Wl,--start-group \
146 $(call ld_path,twolame,libtwolame/.libs) \
147 $(call ld_path,lame,libmp3lame/.libs) \
148 $(call ld_path,libaom,usr/local/lib) \
149 $(call ld_path,libwebp,usr/local/lib) \
150 $(call ld_path,openjpeg,bin) \
151 $(call ld_path,opus,.libs) \
152 $(call ld_path,libogg,lib/.libs) \
153 $(call ld_path,libvorbis,lib/.libs) \
154 $(call ld_path,libtheora,lib/.libs) \
155 $(call ld_path,libvpx) \
156 $(call ld_path,x264) \
157 $(call ld_path,x265) \
158 -Wl,--end-group -lm -lstdc++ -pthread \
159 $(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
161 #cmake_config=echo "exec cmake \$$$$@ $(1)" > ./configure; chmod +x ./configure;
162 cmake_config=echo "exec cmake $(1) \$$$$@" > ./configure; chmod +x ./configure;
163 a52dec.mak_params?= ; cd $(call bld_path,a52dec,include); ln -sf . a52dec
164 a52dec.cfg_vars?= CFLAGS+=" -U__FreeBSD__ $(call inc_path,djbfft)" LIBS+=" $(call ld_path,djbfft)"
165 a52dec.cfg_params?=--enable-djbfft
166 djbfft.cfg_vars?=echo "$(call bld_path,djbfft)" > conf-home; \
167 (CFLAGS="$(CFLAGS)"; $(CFG_VARS)$(if $(CFG_VARS),; )echo "$(CC) $$$$CFLAGS") > conf-cc; \
168 echo > ./configure; chmod +x ./configure;
169 djbfft.mak_params?=; cd $(call bld_path,djbfft); ln -sf djbfft.a libdjbfft.a
170 audiofile.cfg_params?=--enable-shared=no
171 audiofile.mak_params?=LIBS="-lm -lstdc++"
172 flac.cfg_params?= --enable-shared=no
173 flac.cflags?="$(call inc_path,libogg,include) $(call ld_path,libogg,src/.libs)"
174 giflib.cfg_params=echo "exec true" > ./configure; chmod +x ./configure;
175 ilmbase.cfg_vars= CFLAGS+=" -Wno-narrowing" CXXFLAGS+=" -Wno-narrowing"
176 ilmbase.cfg_params?=--prefix=$(call bld_path,ilmbase,usr)
177 ilmbase.mak_params?=; $(MAKE) -C ilmbase* install; cd $(call bld_path,ilmbase); ln -sf lib64 usr/lib
178 lame.cfg_vars?= CFLAGS+=" -O"
179 lame.cfg_params?=--enable-shared=no
180 lame.mak_params?= ; cd $(call bld_path,lame,include); ln -sf . lame
181 libaom.cfg_vars?=$(call cmake_config,aom-master)
182 libaom.cfg_params?= -DENABLE_SHARED=no -DCMAKE_INSTALL_LIBDIR=lib \
183 -DCMAKE_INSTALL_PREFIX=$(call bld_path,libaom)/usr/local
184 libaom.mak_params?= ; $(MAKE) -C libaom* install
185 libwebp.cfg_vars?= mkdir build && cd build && $(call cmake_config,..)
186 libwebp.mak_params?= -C build all install DESTDIR=$(call bld_path,libwebp)
187 mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,.libs)"
188 mjpegtools.mak_params?=; ln -s . $(call bld_path,mjpegtools,utils)/mjpegtools
189 mjpegtools.cfg_params?= --enable-shared=no --without-libsdl --without-v4l
190 ladspa.cfg_vars?= CFLAGS+=' -Dinline="" '
191 ladspa.mak_params?=; $(MAKE) -C ladspa* install DESTDIR=$(call bld_path,ladspa)
192 libavc1394.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
193 libavc1394.cflags?="$(call inc_path,libraw1394)"
194 libavc1394.ldflags?="$(call ld_path,libraw1394,src/.libs)"
195 libavc1394.cfg_params?= --enable-shared=no
196 libavc1394.mak_params?=; cd $(call bld_path,libavc1394); ln -sf ../librom1394/rom1394.h libavc1394/.
197 libdv.cfg_params?= --disable-gtk --enable-shared=no
198 libiec61883.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
199 libiec61883.cflags?="$(call inc_path,libraw1394)"
200 libiec61883.ldflags?="$(call ld_path,libraw1394,src/.libs)"
201 libiec61883.cfg_params?= --enable-shared=no
202 libiec61883.mak_params?=; cd $(call bld_path,libiec61883,src); ln -sf . libiec61883
203 libjpeg.cfg_params?= --enable-shared=no
204 libogg.cfg_params?= --enable-shared=no
205 libraw1394.cfg_params?= --enable-shared=no; ln -sf src libraw1394
206 libtheora.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libogg):$(call bld_path,libvorbis)
207 libtheora.cflags?="$(call inc_path,libogg,include) $(call inc_path,libogg,src) $(call inc_path,libvorbis,include)"
208 libtheora.ldflags?="$(call ld_path,libvorbis,lib/.libs) $(call ld_path,libogg,src/.libs)"
209 libtheora.cfg_params?= --disable-examples --disable-spec --enable-shared=no
210 libuuid.cfg_params?=--enable-shared=no
211 libvorbis.cfg_params?= --disable-oggtest --enable-shared=no
212 openjpeg.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
213 openjpeg.cfg_vars?=$(call cmake_config,.)
214 openjpeg.mak_params?= ; cd $(call bld_path,openjpeg,src/lib/openjp2); ln -sf . openjpeg-2.1
215 opencv.cfg_vars?=$(call cmake_config,.)
216 opencv.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
217 openexr.cfg_vars?=LD_LIBRARY_PATH=$(call bld_path,ilmbase,usr/lib)
218 openexr.cfg_params?=--enable-shared=no --with-ilmbase-prefix=$(call bld_path,ilmbase,usr)
219 speech_tools.mak_params?=-j1
220 tiff.cfg_params+= --enable-shared=no --disable-zstd $(call if_npkg,libwebp,--without-webp)
221 twolame.cfg_params?=--enable-shared=no
222 x264.cfg_params?= --enable-static --enable-pic
223 x265.cfg_vars?=$(call cmake_config,source)
224 x265.cfg_params?= -DENABLE_SHARED=no
225 libvpx.cfg_params?= --enable-pic
228 pkg_cfg=$(call bld_path,$(1),usr/local/lib/pkgconfig):
229 LV2_PKGCFG:=$(subst : ,:,$(foreach p,lv2 serd sord sratom lilv suil,$(call pkg_cfg,$(p))))
233 $(1).cfg_vars+=./waf --version; find .waf* -type f -name "*.py" | \
234 while read f; do sed -e '/StopIter/d' -i "$(DS)f"; done; \
235 echo 'exec ./waf configure "$(DS)@"' > ./configure; chmod +x \
236 ./configure; PKG_CONFIG_PATH=$(LV2_PKGCFG) LD_LIBRARY_PATH=$(LV2_LIBPATH)
238 CFLAGS="-I$(call bld_path,lv2) $(foreach f,$(2), $(call inc_path,$(f))) -fPIC -std=c99"\
239 LDFLAGS="-lm $(foreach f,$(2), $(call ld_path,$(f),usr/local/lib)) "
240 $(1).mak_vars=(echo "all:"; echo " ./waf -v build") > $(call bld_path,$(1),Makefile);
241 $(1).mak_params+=; ( cd $(1)*; ./waf install --destdir=$(call bld_path,$(1)) )
244 SYS_LIB:=$(notdir $(lastword $(wildcard /usr/lib /usrlib32 /usr/lib64)))
245 SYS_LV2:=$(lastword $(wildcard /usr/$(SYS_LIB)/lv2 /usr/local/$(SYS_LIB)/lv2))
246 $(if $(SYS_LV2),,$(eval SYS_LV2:=/usr/$(SYS_LIB)/lv2))
247 lv2.cfg_params?= --lv2dir=$(SYS_LV2)
248 SYS_LV2_PATH:=/usr/$(SYS_LIB)/lv2: /usr/local/$(SYS_LIB)/lv2:
249 DFT_LV2_PATH:= /usr/lib64/lv2: /usr/lib/lv2: /usr/local/lib64/lv2: /usr/local/lib/lv2:
250 LV2_PATH:=$(subst : ,:,$(SYS_LV2_PATH)$(filter-out $(SYS_LV2_PATH),$(DFT_LV2_PATH)))
251 lilv.cfg_params?= --static --default-lv2-path=$(LV2_PATH)
252 sratom.cfg_params?= --static --no-shared
253 serd.cfg_params?= --static --no-shared
254 sord.cfg_params?= --static --no-shared
255 lilv.cfg_params?= --static --dyn-manifest
256 suil.cfg_params?= --static --no-qt
258 $(eval $(call waf-setup,lv2))
259 $(eval $(call waf-setup,serd))
260 $(eval $(call waf-setup,sord, serd))
261 $(eval $(call waf-setup,sratom, serd sord lv2))
262 $(eval $(call waf-setup,lilv, lv2 sratom serd sord))
263 $(eval $(call waf-setup,suil, lv2))
265 # add softlinks for legacy paths
266 waf_link=$(1).mak_params+=; (cd $(1)*; ln -s $(1)-0/$(1) usr/local/include/.)
267 $(foreach p,sratom serd sord lilv suil,$(eval $(call waf_link,$(p))))
270 $(foreach tgt,$(TARGETS), \
271 $(if $($(tgt).cflags),$(eval $(tgt).cfg_vars+=CFLAGS+=$($(tgt).cflags))))
272 $(foreach tgt,$(TARGETS), \
273 $(if $($(tgt).cppflags),$(eval $(tgt).cfg_vars+=CPPFLAGS+=$($(tgt).cppflags))))
274 $(foreach tgt,$(TARGETS), \
275 $(if $($(tgt).ldflags),$(eval $(tgt).cfg_vars+=LDFLAGS+=$($(tgt).ldflags))))
281 #$(eval $(call std-build,pkg,deps...))
283 ifeq ($(MAKECMDGOALS),rules)
289 $(call rules,$(call std-build,a52dec,djbfft))
290 $(call rules,$(call std-build,djbfft))
291 $(call rules,$(call std-build,audiofile))
292 $(call rules,$(call std-build,encore))
293 $(call rules,$(call std-build,esound,audiofile))
294 $(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus \
295 libtheora x264 x265 libvpx libaom libwebp \
296 $(if $(WANT_NV), ffnvcodec)))
297 $(call rules,$(call std-build,fftw))
298 $(call rules,$(call std-build,flac,libogg))
299 $(call rules,$(call std-build,giflib))
300 $(call rules,$(call std-build,ilmbase))
301 $(call rules,$(call std-build,ladspa))
302 $(call rules,$(call std-build,lame))
303 $(call rules,$(call std-build,libaom))
304 $(call rules,$(call std-build,libwebp))
305 $(call rules,$(call std-build,libavc1394,libraw1394))
306 $(call rules,$(call std-build,libdv))
307 $(call rules,$(call std-build,libiec61883,libraw1394))
308 $(call rules,$(call std-build,libjpeg))
309 $(call rules,$(call std-build,libogg))
310 $(call rules,$(call std-build,libraw1394))
311 $(call rules,$(call std-build,libsndfile))
312 $(call rules,$(call std-build,libtheora, libogg libvorbis))
313 $(call rules,$(call std-build,libuuid))
314 $(call rules,$(call std-build,libvorbis))
315 $(call rules,$(call std-build,mjpegtools, libjpeg))
316 $(call rules,$(call std-build,opencv))
317 $(call rules,$(call std-build,openexr, ilmbase))
318 $(call rules,$(call std-build,openjpeg))
319 $(call rules,$(call std-build,opus))
320 $(call rules,$(call std-build,speech_tools))
321 $(call rules,$(call std-build,tiff))
322 $(call rules,$(call std-build,twolame))
323 $(call rules,$(call std-build,x264))
324 $(call rules,$(call std-build,x265))
325 $(call rules,$(call std-build,libvpx))
326 $(call rules,$(call std-build,lv2))
327 $(call rules,$(call std-build,serd))
328 $(call rules,$(call std-build,sord, serd))
329 $(call rules,$(call std-build,sratom, serd sord lv2))
330 $(call rules,$(call std-build,lilv, lv2 sratom serd sord))
331 $(call rules,$(call std-build,suil, lv2))
332 $(call rules,$(call std-build,ffnvcodec))
334 # specialize festival, multiple tarballs
336 .PHONY: festival festival-configure festival-src
337 festival: $(call pkg-built,festival)
338 festival-configure: $(call pkg-config,festival)
339 festival-src: $(call pkg-source,festival)
341 rm -rf festival* $(BLD)/festival.*
343 $(call pkg-source,festival):
344 for f in src/festival* src/festlex_* src/festvox_*; do tar -xJf $$f; done
347 $(call pkg-config,festival): $(call pkg-source,festival) $(call pkg-built,speech_tools)
348 cd festival* && [ -f ./configure ] && \
352 $(call pkg-built,festival): $(call pkg-config,festival)
353 $(MAKE) -C festival* -j1
357 for f in $(static_pkgs); do rm -rf $$f*; done
361 cp -a $(ver_mjpegtools)/mpeg2enc/mpeg2enc $(BINDIR)/.
362 cp -a $(ver_mjpegtools)/mplex/mplex $(BINDIR)/.
364 # not WANT_CIN_3RDPARTY
371 @echo $($(subst val-,,$@))