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 inc_path=$(call if_pkg,$(1),$(inc_$(1)))
57 ld_path=$(call if_pkg,$(1),-L$(call bld_path,$(1),$(2)) $(lib_$(1)))
59 #$(eval $(call std-build,pkg,deps...))
60 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
61 #$(pkg.cppflags) added as CPPFLAGS+=$(cppflags) to pkg.vars
62 #$(pkg.cfg_vars) prepended to configure
63 #$(pkg.cfg_params) appended to configure
64 #$(pkg.mak_vars) prepended to make
65 #$(pkg.mak_params) appended to make
69 .PHONY: $(1) $(1)-configure $(1)-src $(1)-clean
70 $(1): $(call pkg-built,$(1))
71 $(1)-configure: $(call pkg-config,$(1))
72 $(1)-src: $(call pkg-source,$(1))
74 rm -rf $(1)* $(BLD)/$(1).*
76 $(call pkg-source,$(1)):
77 $(call unpack,$(call tarball,$(1))) \
78 $(foreach pch,$(sort $(wildcard src/$(notdir $(ver_$(1))).patch*)),
79 patch -d $(1)* -p1 < $(pch))
82 $(call pkg-config,$(1)): $(call pkg-source,$(1)) $(foreach dep,$(2),$(call bld_depends,$(dep)))
83 @echo "CONFIGURING $(1)"
85 $($(1).cfg_vars) $(CFG_VARS) ./configure $($(1).cfg_params) $(CFG_PARAMS)
88 $(call pkg-built,$(1)): $(call pkg-config,$(1))
89 +$($(1).mak_vars) $(MAK_VARS) $(MAKE) -C $(1)* $($(1).mak_params) $(MAK_PARAMS)
94 TARGETS := $(static_blds)
104 encore.cfg_vars= true ||
105 esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile,libaudiofile) -laudiofile"
106 esound.cfg_vars+= AUDIOFILE_LIBS="$(call ld_path,audiofile,libaudiofile/.libs)"
107 esound.cfg_params= --enable-shared=no --with-pic
108 esound.mak_vars+= CFLAGS=""
109 esound.ldflags=" -lm -lstdc++"
110 fftw.cfg_params= --disable-fortran --enable-shared=no
112 --enable-pthreads --enable-gpl \
113 --disable-ffplay --disable-vaapi \
114 $(call if_pkg,twolame,--enable-libtwolame) \
115 $(call if_pkg,openjpeg,--enable-libopenjpeg) \
116 $(call if_pkg,lame,--enable-libmp3lame) \
117 $(call if_pkg,libaom,--enable-libaom) \
118 $(call if_pkg,libwebp,--enable-libwebp) \
119 $(call if_pkg,opus,--enable-libopus) \
120 $(call if_pkg,libvorbis,--enable-libvorbis) \
121 $(call if_pkg,libtheora,--enable-libtheora) \
122 $(call if_pkg,libvpx,--enable-libvpx) \
123 $(call if_pkg,x264,--enable-libx264) \
124 $(call if_pkg,x265,--enable-libx265) \
126 $(call inc_path,twolame,libtwolame) \
127 $(call inc_path,lame,include) \
128 $(call inc_path,libaom,usr/local/include) \
129 $(call inc_path,libwebp,usr/local/include) \
130 $(call inc_path,openjpeg,src/lib/openjp2) \
131 $(call inc_path,libogg,include) \
132 $(call inc_path,opus,include) \
133 $(call inc_path,libvorbis,include) \
134 $(call inc_path,libtheora,include) \
135 $(call inc_path,libvpx) \
136 $(call inc_path,x264) \
137 $(call inc_path,x265) \
138 $(call inc_path,x265,source)" \
139 --extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
141 --extra-libs="-Wl,--start-group \
142 $(call ld_path,twolame,libtwolame/.libs) \
143 $(call ld_path,lame,libmp3lame/.libs) \
144 $(call ld_path,libaom,usr/local/lib) \
145 $(call ld_path,libwebp,usr/local/lib) \
146 $(call ld_path,openjpeg,bin) \
147 $(call ld_path,opus,.libs) \
148 $(call ld_path,libogg,lib/.libs) \
149 $(call ld_path,libvorbis,lib/.libs) \
150 $(call ld_path,libtheora,lib/.libs) \
151 $(call ld_path,libvpx) \
152 $(call ld_path,x264) \
153 $(call ld_path,x265) \
154 -Wl,--end-group -lm -lstdc++ -pthread \
155 $(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
157 cmake_config=echo "exec cmake \$$$$@ $(1)" > ./configure; chmod +x ./configure;
158 a52dec.mak_params?= ; cd $(call bld_path,a52dec,include); ln -sf . a52dec
159 a52dec.cfg_vars?= CFLAGS+=" -U__FreeBSD__ $(call inc_path,djbfft)" LIBS+=" $(call ld_path,djbfft)"
160 a52dec.cfg_params?=--enable-djbfft
161 djbfft.cfg_vars?=echo "$(call bld_path,djbfft)" > conf-home; \
162 (CFLAGS="$(CFLAGS)"; $(CFG_VARS)$(if $(CFG_VARS),; )echo "$(CC) $$$$CFLAGS") > conf-cc; \
163 echo > ./configure; chmod +x ./configure;
164 djbfft.mak_params?=; cd $(call bld_path,djbfft); ln -sf djbfft.a libdjbfft.a
165 audiofile.cfg_params?=--enable-shared=no
166 audiofile.mak_params?=LIBS="-lm -lstdc++"
167 flac.cfg_params?= --enable-shared=no
168 flac.cflags?="$(call inc_path,libogg,include) $(call ld_path,libogg,src/.libs)"
169 giflib.cfg_params?=--enable-shared=no
170 ilmbase.cfg_vars= CFLAGS+=" -Wno-narrowing" CXXFLAGS+=" -Wno-narrowing"
171 ilmbase.cfg_params?=--prefix=$(call bld_path,ilmbase,usr)
172 ilmbase.mak_params?=; $(MAKE) -C ilmbase* install; cd $(call bld_path,ilmbase); ln -sf lib64 usr/lib
173 lame.cfg_vars?= CFLAGS+=" -O"
174 lame.cfg_params?=--enable-shared=no
175 lame.mak_params?= ; cd $(call bld_path,lame,include); ln -sf . lame
176 libaom.cfg_vars?=$(call cmake_config,aom-master)
177 libaom.cfg_params?= -DENABLE_SHARED=no -DCMAKE_INSTALL_LIBDIR=lib \
178 -DCMAKE_INSTALL_PREFIX=$(call bld_path,libaom)/usr/local
179 libaom.mak_params?= ; $(MAKE) -C libaom* install
180 libwebp.cfg_vars?= ./autogen.sh ;
181 libwebp.cfg_params?=--enable-shared=no
182 libwebp.mak_params?=; $(MAKE) -C libwebp* install DESTDIR=$(call bld_path,libwebp)
183 mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,.libs)"
184 mjpegtools.mak_params?=; ln -s . $(call bld_path,mjpegtools,utils)/mjpegtools
185 mjpegtools.cfg_params?= --enable-shared=no --without-libsdl --without-v4l
186 ladspa.cfg_vars?= CFLAGS+=' -Dinline="" '
187 ladspa.mak_params?=; $(MAKE) -C ladspa* install DESTDIR=$(call bld_path,ladspa)
188 libavc1394.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
189 libavc1394.cflags?="$(call inc_path,libraw1394)"
190 libavc1394.ldflags?="$(call ld_path,libraw1394,src/.libs)"
191 libavc1394.cfg_params?= --enable-shared=no
192 libavc1394.mak_params?=; cd $(call bld_path,libavc1394); ln -sf ../librom1394/rom1394.h libavc1394/.
193 libdv.cfg_params?= --disable-gtk --enable-shared=no
194 libiec61883.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
195 libiec61883.cflags?="$(call inc_path,libraw1394)"
196 libiec61883.ldflags?="$(call ld_path,libraw1394,src/.libs)"
197 libiec61883.cfg_params?= --enable-shared=no
198 libiec61883.mak_params?=; cd $(call bld_path,libiec61883,src); ln -sf . libiec61883
199 libjpeg.cfg_params?= --enable-shared=no
200 libogg.cfg_params?= --enable-shared=no
201 libraw1394.cfg_params?= --enable-shared=no; ln -sf src libraw1394
202 libtheora.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libogg):$(call bld_path,libvorbis)
203 libtheora.cflags?="$(call inc_path,libogg,include) $(call inc_path,libogg,src) $(call inc_path,libvorbis,include)"
204 libtheora.ldflags?="$(call ld_path,libvorbis,lib/.libs) $(call ld_path,libogg,src/.libs)"
205 libtheora.cfg_params?= --disable-examples --disable-spec --enable-shared=no
206 libuuid.cfg_params?=--enable-shared=no
207 libvorbis.cfg_params?= --disable-oggtest --enable-shared=no
208 openjpeg.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
209 openjpeg.cfg_vars?=$(call cmake_config,.)
210 openjpeg.mak_params?= ; cd $(call bld_path,openjpeg,src/lib/openjp2); ln -sf . openjpeg-2.1
211 opencv.cfg_vars?=$(call cmake_config,.)
212 opencv.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
213 openexr.cfg_vars?=LD_LIBRARY_PATH=$(call bld_path,ilmbase,usr/lib)
214 openexr.cfg_params?=--enable-shared=no --with-ilmbase-prefix=$(call bld_path,ilmbase,usr)
215 speech_tools.mak_params?=-j1
216 twolame.cfg_params?=--enable-shared=no
217 x264.cfg_params?= --enable-static --enable-pic
218 x265.cfg_vars?=$(call cmake_config,source)
219 x265.cfg_params?= -DENABLE_SHARED=no
220 libvpx.cfg_params?= --enable-pic
223 pkg_cfg=$(call bld_path,$(1),usr/local/lib/pkgconfig):
224 LV2_PKGCFG:=$(subst : ,:,$(foreach p,lv2 serd sord sratom lilv suil,$(call pkg_cfg,$(p))))
228 $(1).cfg_vars+=./waf --version; find .waf* -type f -name "*.py" | \
229 while read f; do sed -e '/StopIter/d' -i "$(DS)f"; done; \
230 echo 'exec ./waf configure "$(DS)@"' > ./configure; chmod +x \
231 ./configure; PKG_CONFIG_PATH=$(LV2_PKGCFG) LD_LIBRARY_PATH=$(LV2_LIBPATH)
233 CFLAGS="-I$(call bld_path,lv2) $(foreach f,$(2), $(call inc_path,$(f))) -fPIC "\
234 LDFLAGS="-lm $(foreach f,$(2), $(call ld_path,$(f),usr/local/lib)) "
235 $(1).mak_vars=(echo "all:"; echo " ./waf -v build") > $(call bld_path,$(1),Makefile);
236 $(1).mak_params+=; ( cd $(1)*; ./waf install --destdir=$(call bld_path,$(1)) )
239 SYS_LIB:=$(notdir $(lastword $(wildcard /usr/lib /usrlib32 /usr/lib64)))
240 SYS_LV2:=$(lastword $(wildcard /usr/$(SYS_LIB)/lv2 /usr/local/$(SYS_LIB)/lv2))
241 $(if $(SYS_LV2),,$(eval SYS_LV2:=/usr/$(SYS_LIB)/lv2))
242 lv2.cfg_params?= --lv2dir=$(SYS_LV2)
243 SYS_LV2_PATH:=/usr/$(SYS_LIB)/lv2: /usr/local/$(SYS_LIB)/lv2:
244 DFT_LV2_PATH:= /usr/lib64/lv2: /usr/lib/lv2: /usr/local/lib64/lv2: /usr/local/lib/lv2:
245 LV2_PATH:=$(subst : ,:,$(SYS_LV2_PATH)$(filter-out $(SYS_LV2_PATH),$(DFT_LV2_PATH)))
246 lilv.cfg_params?= --static --default-lv2-path=$(LV2_PATH)
247 sratom.cfg_params?= --static --no-shared
248 serd.cfg_params?= --static --no-shared
249 sord.cfg_params?= --static --no-shared
250 lilv.cfg_params?= --static --dyn-manifest
251 suil.cfg_params?= --static --no-qt
253 $(eval $(call waf-setup,lv2))
254 $(eval $(call waf-setup,serd))
255 $(eval $(call waf-setup,sord, serd))
256 $(eval $(call waf-setup,sratom, serd sord lv2))
257 $(eval $(call waf-setup,lilv, lv2 sratom serd sord))
258 $(eval $(call waf-setup,suil, lv2))
260 # add softlinks for legacy paths
261 waf_link=$(1).mak_params+=; (cd $(1)*; ln -s $(1)-0/$(1) usr/local/include/.)
262 $(foreach p,sratom serd sord lilv suil,$(eval $(call waf_link,$(p))))
265 $(foreach tgt,$(TARGETS), \
266 $(if $($(tgt).cflags),$(eval $(tgt).cfg_vars+=CFLAGS+=$($(tgt).cflags))))
267 $(foreach tgt,$(TARGETS), \
268 $(if $($(tgt).cppflags),$(eval $(tgt).cfg_vars+=CPPFLAGS+=$($(tgt).cppflags))))
269 $(foreach tgt,$(TARGETS), \
270 $(if $($(tgt).ldflags),$(eval $(tgt).cfg_vars+=LDFLAGS+=$($(tgt).ldflags))))
276 #$(eval $(call std-build,pkg,deps...))
278 ifeq ($(MAKECMDGOALS),rules)
284 $(call rules,$(call std-build,a52dec,djbfft))
285 $(call rules,$(call std-build,djbfft))
286 $(call rules,$(call std-build,audiofile))
287 $(call rules,$(call std-build,encore))
288 $(call rules,$(call std-build,esound,audiofile))
289 $(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus libtheora x264 x265 libvpx libaom libwebp))
290 $(call rules,$(call std-build,fftw))
291 $(call rules,$(call std-build,flac,libogg))
292 $(call rules,$(call std-build,giflib))
293 $(call rules,$(call std-build,ilmbase))
294 $(call rules,$(call std-build,ladspa))
295 $(call rules,$(call std-build,lame))
296 $(call rules,$(call std-build,libaom))
297 $(call rules,$(call std-build,libwebp))
298 $(call rules,$(call std-build,libavc1394,libraw1394))
299 $(call rules,$(call std-build,libdv))
300 $(call rules,$(call std-build,libiec61883,libraw1394))
301 $(call rules,$(call std-build,libjpeg))
302 $(call rules,$(call std-build,libogg))
303 $(call rules,$(call std-build,libraw1394))
304 $(call rules,$(call std-build,libsndfile))
305 $(call rules,$(call std-build,libtheora, libogg libvorbis))
306 $(call rules,$(call std-build,libuuid))
307 $(call rules,$(call std-build,libvorbis))
308 $(call rules,$(call std-build,mjpegtools, libjpeg))
309 $(call rules,$(call std-build,opencv))
310 $(call rules,$(call std-build,openexr, ilmbase))
311 $(call rules,$(call std-build,openjpeg))
312 $(call rules,$(call std-build,opus))
313 $(call rules,$(call std-build,speech_tools))
314 $(call rules,$(call std-build,tiff))
315 $(call rules,$(call std-build,twolame))
316 $(call rules,$(call std-build,x264))
317 $(call rules,$(call std-build,x265))
318 $(call rules,$(call std-build,libvpx))
319 $(call rules,$(call std-build,lv2))
320 $(call rules,$(call std-build,serd))
321 $(call rules,$(call std-build,sord, serd))
322 $(call rules,$(call std-build,sratom, serd sord lv2))
323 $(call rules,$(call std-build,lilv, lv2 sratom serd sord))
324 $(call rules,$(call std-build,suil, lv2))
326 # specialize festival, multiple tarballs
328 .PHONY: festival festival-configure festival-src
329 festival: $(call pkg-built,festival)
330 festival-configure: $(call pkg-config,festival)
331 festival-src: $(call pkg-source,festival)
333 rm -rf festival* $(BLD)/festival.*
335 $(call pkg-source,festival):
336 for f in src/festival* src/festlex_* src/festvox_*; do tar -xJf $$f; done
339 $(call pkg-config,festival): $(call pkg-source,festival) $(call pkg-built,speech_tools)
340 cd festival* && [ -f ./configure ] && \
344 $(call pkg-built,festival): $(call pkg-config,festival)
345 $(MAKE) -C festival* -j1
349 for f in $(static_pkgs); do rm -rf $$f*; done
353 cp -a $(ver_mjpegtools)/mpeg2enc/mpeg2enc $(BINDIR)/.
354 cp -a $(ver_mjpegtools)/mplex/mplex $(BINDIR)/.
356 # not WANT_CIN_3RDPARTY
363 @echo $($(subst val-,,$@))