sams folder icons, snap drag, sort folders, in/out ptr bug, interp bg fix, filebox...
[goodguy/history.git] / cinelerra-5.1 / thirdparty / Makefile
1 # to see the make rules:
2 #   make rules
3 #
4 # command uses:
5 #   make <name>-clean
6 #   make <name>
7 #   make rules
8 #   make val-<var>
9 #
10 # to add a new library:
11 #   vi ../configure.ac
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
19 #   vi Makefile
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 #
25
26 TOPDIR ?= $(CURDIR)/..
27 include $(TOPDIR)/global_config
28 -include $(TOPDIR)/cin_config
29 BLD := $(THIRDPARTY)/build
30
31 # package build flags, if needed
32 # need frame pointer for debugs and helps with profiling
33 # NOTE: the trailing blank is MANDITORY or the builds fail
34 # due to bugs in the build scripts from auto*
35 CFLAGS_ ?= -g -O2 -fno-omit-frame-pointer
36 CFLAGS ?= $(CFLAGS_) 
37 LDFLAGS += $(LDFLAGS_) 
38 CXXFLAGS += $(CXXFLAGS_) 
39
40 pkg-source=$(BLD)/$(1).source
41 pkg-config=$(BLD)/$(1).configure
42 pkg-built=$(BLD)/$(1).built
43
44 ext=$(lastword $(subst ., ,$(1)))
45 tarball=$(lastword $(sort $(wildcard src/$(1)*.tar.*)))
46 unpack=$(call unpack_$(call ext,$(1)),$(1))
47 unpack_gz=tar -xzf $(1)
48 unpack_bz2=tar -xjf $(1)
49 unpack_xz=tar -xJf $(1)
50 bld_depends=$(if $(ver_$(1)),$(call pkg-built,$(1)))
51 bld_path=$(ver_$(1))/$(2)
52 inc_path=$(inc_$(1))
53 ld_path=$(if $(ver_$(1)),-L$(call bld_path,$(1),$(2)))
54
55 #$(eval $(call std-build,pkg,deps...))
56 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
57 #$(pkg.cppflags) added as CPPFLAGS+=$(cppflags) to pkg.vars
58 #$(pkg.cfg_vars) prepended to configure
59 #$(pkg.cfg_params) appended to configure
60 #$(pkg.mak_vars) prepended to make
61 #$(pkg.mak_params) appended to make
62
63 define std-build
64 # $(1)
65 .PHONY: $(1) $(1)-configure $(1)-src $(1)-clean
66 $(1): $(call pkg-built,$(1))
67 $(1)-configure: $(call pkg-config,$(1))
68 $(1)-src: $(call pkg-source,$(1))
69 $(1)-clean:
70         rm -rf $(1)* $(BLD)/$(1).*
71
72 $(call pkg-source,$(1)):
73         $(call unpack,$(call tarball,$(1))) \
74         $(foreach pch,$(sort $(wildcard src/$(1).patch*)),
75                 patch -d $(1)* -p1 < $(pch))
76         touch $$@
77
78 $(call pkg-config,$(1)): $(call pkg-source,$(1)) $(foreach dep,$(2),$(call bld_depends,$(dep)))
79         @echo "CONFIGURING $(1)"
80         cd $(1)* && \
81                 $($(1).cfg_vars) $(CFG_VARS) ./configure $($(1).cfg_params) $(CFG_PARAMS)
82         touch $$@
83
84 $(call pkg-built,$(1)): $(call pkg-config,$(1))
85         +$($(1).mak_vars) $(MAK_VARS) $(MAKE) -C $(1)* $($(1).mak_params) $(MAK_PARAMS)
86         touch $$@
87
88 endef
89
90 TARGETS := $(static_blds)
91
92 all:    $(TARGETS)
93
94 $(TARGETS):     $(BLD)
95
96 $(BLD):
97         mkdir $(BLD)
98
99 # vars first
100 encore.cfg_vars= true ||
101 esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile,libaudiofile) -laudiofile"
102 esound.cfg_vars+= AUDIOFILE_LIBS="$(call ld_path,audiofile,libaudiofile/.libs)"
103 esound.cfg_params= --enable-shared=no --with-pic
104 esound.mak_vars+= CFLAGS="" 
105 esound.ldflags=" -lm -lstdc++"
106 faac.cfg_params= --enable-shared=no --without-mp4v2
107 faad2.cfg_params= --enable-shared=no
108 #fdk.cfg_vars= ./autogen.sh ; CFLAGS+=" -Wno-narrowing" CXXFLAGS+=" -Wno-narrowing"
109 fdk.cfg_params= --enable-shared=no
110 fdk.mak_params= ; for f in $(call bld_path,fdk,/lib*/include); do ln -s . $$$$f/fdk-aac; done
111 fftw.cfg_params= --disable-fortran --enable-shared=no
112 ffmpeg.cfg_params= \
113         --enable-pthreads --enable-gpl \
114         --disable-ffserver --disable-ffplay \
115         --disable-vaapi \
116         --enable-libfdk-aac \
117         --enable-libtwolame \
118         --enable-libopenjpeg \
119         --enable-libmp3lame \
120         --enable-libvorbis \
121         --enable-libtheora \
122         --enable-libvpx \
123         --enable-libx264 \
124         --enable-libx265 \
125         --enable-nonfree \
126         --extra-cflags="\
127                 $(call inc_path,faad2,include) \
128                 $(call inc_path,faac,include) \
129                 $(call inc_path,twolame,libtwolame) \
130                 $(call inc_path,lame,include) \
131                 $(call inc_path,openjpeg,src/lib/openjp2) \
132                 $(call inc_path,libvorbis,include) \
133                 $(call inc_path,libtheora,include) \
134                 $(call inc_path,libvpx) \
135                 $(call inc_path,x264) \
136                 $(call inc_path,x265) \
137                 $(call inc_path,x265,source) \
138                 $(call inc_path,fdk,libAACdec) \
139                 $(call inc_path,fdk,libAACenc) \
140                 $(call inc_path,fdk,libSYS) \
141                 $(call inc_path,fdk,libSYS/include)" \
142         --extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
143         --extra-libs="\
144                 $(call ld_path,faad2,libfaad/.libs) \
145                 $(call ld_path,faac,libfaac/.libs) \
146                 $(call ld_path,twolame,libtwolame/.libs) \
147                 $(call ld_path,lame,libmp3lame/.libs) \
148                 $(call ld_path,openjpeg,bin) \
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                 $(call ld_path,fdk,.libs) \
155                 $(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
156
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 mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,.libs)"
177 mjpegtools.mak_params?=; ln -s . $(call bld_path,mjpegtools,utils)/mjpegtools 
178 mjpegtools.cfg_params?= --enable-shared=no
179 ladspa.cfg_vars?= CFLAGS+=' -Dinline="" '
180 ladspa.mak_params?=; $(MAKE) -C ladspa* install DESTDIR=$(call bld_path,ladspa)
181 libavc1394.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
182 libavc1394.cflags?="$(call inc_path,libraw1394)"
183 libavc1394.ldflags?="$(call ld_path,libraw1394,src/.libs)"
184 libavc1394.cfg_params?= --enable-shared=no
185 libavc1394.mak_params?=; cd $(call bld_path,libavc1394); ln -sf ../librom1394/rom1394.h libavc1394/.
186 libdv.cfg_params?= --disable-gtk --enable-shared=no
187 libiec61883.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libraw1394)
188 libiec61883.cflags?="$(call inc_path,libraw1394)"
189 libiec61883.ldflags?="$(call ld_path,libraw1394,src/.libs)"
190 libiec61883.cfg_params?= --enable-shared=no
191 libiec61883.mak_params?=; cd $(call bld_path,libiec61883,src); ln -sf . libiec61883
192 libjpeg.cfg_params?= --enable-shared=no
193 libogg.cfg_params?= --enable-shared=no
194 libraw1394.cfg_params?=  --enable-shared=no; ln -sf src libraw1394
195 libtheora.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libogg):$(call bld_path,libvorbis)
196 libtheora.cflags?="$(call inc_path,libogg,include) $(call inc_path,libogg,src) $(call inc_path,libvorbis,include)"
197 libtheora.ldflags?="$(call ld_path,libvorbis,lib/.libs) $(call ld_path,libogg,src/.libs)"
198 libtheora.cfg_params?= --disable-examples --disable-spec --enable-shared=no
199 libuuid.cfg_params?=--enable-shared=no
200 libvorbis.cfg_params?= --disable-oggtest --enable-shared=no
201 openjpeg.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
202 openjpeg.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
203 openjpeg.cfg_vars?=$(call cmake_config,.)
204 openjpeg.mak_params?= ; cd $(call bld_path,openjpeg,src/lib/openjp2); ln -sf . openjpeg-2.1
205 opencv.cfg_vars?=$(call cmake_config,.)
206 opencv.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
207 openexr.cfg_vars?=LD_LIBRARY_PATH=$(call bld_path,ilmbase,usr/lib)
208 openexr.cfg_params?=--enable-shared=no --with-ilmbase-prefix=$(call bld_path,ilmbase,usr)
209 speech_tools.mak_params?=-j1
210 twolame.cfg_params?=--enable-shared=no
211 x264.cfg_params?= --enable-static --enable-pic
212 x265.cfg_vars?=$(call cmake_config,source)
213 x265.cfg_params?= -DENABLE_SHARED=no
214 libvpx.cfg_params?= --enable-pic
215
216 # compile flag vars
217 $(foreach tgt,$(TARGETS), \
218         $(if $($(tgt).cflags),$(eval $(tgt).cfg_vars+=CFLAGS+=$($(tgt).cflags))))
219 $(foreach tgt,$(TARGETS), \
220         $(if $($(tgt).cppflags),$(eval $(tgt).cfg_vars+=CPPFLAGS+=$($(tgt).cppflags))))
221 $(foreach tgt,$(TARGETS), \
222         $(if $($(tgt).ldflags),$(eval $(tgt).cfg_vars+=LDFLAGS+=$($(tgt).ldflags))))
223
224 # build rules
225 .PHONY: rules
226 rules:
227
228 #$(eval $(call std-build,pkg,deps...))
229
230 ifeq ($(MAKECMDGOALS),rules)
231 rules=$(info $(1))
232 else
233 rules=$(eval $(1))
234 endif
235
236 $(call rules,$(call std-build,a52dec,djbfft))
237 $(call rules,$(call std-build,djbfft))
238 $(call rules,$(call std-build,audiofile))
239 $(call rules,$(call std-build,encore))
240 $(call rules,$(call std-build,esound,audiofile))
241 $(call rules,$(call std-build,faac))
242 $(call rules,$(call std-build,faad2))
243 $(call rules,$(call std-build,fdk))
244 $(call rules,$(call std-build,ffmpeg, faad2 faac fdk twolame lame openjpeg libtheora x264 x265 libvpx))
245 $(call rules,$(call std-build,fftw))
246 $(call rules,$(call std-build,flac,libogg))
247 $(call rules,$(call std-build,giflib))
248 $(call rules,$(call std-build,ilmbase))
249 $(call rules,$(call std-build,ladspa))
250 $(call rules,$(call std-build,lame))
251 $(call rules,$(call std-build,libavc1394,libraw1394))
252 $(call rules,$(call std-build,libdv))
253 $(call rules,$(call std-build,libiec61883,libraw1394))
254 $(call rules,$(call std-build,libjpeg))
255 $(call rules,$(call std-build,libogg))
256 $(call rules,$(call std-build,libraw1394))
257 $(call rules,$(call std-build,libsndfile))
258 $(call rules,$(call std-build,libtheora, libogg libvorbis))
259 $(call rules,$(call std-build,libuuid))
260 $(call rules,$(call std-build,libvorbis))
261 $(call rules,$(call std-build,mjpegtools, libjpeg))
262 $(call rules,$(call std-build,opencv))
263 $(call rules,$(call std-build,openexr, ilmbase))
264 $(call rules,$(call std-build,openjpeg))
265 $(call rules,$(call std-build,speech_tools))
266 $(call rules,$(call std-build,tiff))
267 $(call rules,$(call std-build,twolame))
268 $(call rules,$(call std-build,x264))
269 $(call rules,$(call std-build,x265))
270 $(call rules,$(call std-build,libvpx))
271
272 # specialize festival, multiple tarballs
273 festival:
274 .PHONY: festival festival-configure festival-src
275 festival: $(call pkg-built,festival)
276 festival-configure: $(call pkg-config,festival)
277 festival-src: $(call pkg-source,festival)
278 festival-clean:
279         rm -rf festival* $(BLD)/festival.*
280
281 $(call pkg-source,festival):
282         for f in src/festival* src/festlex_* src/festvox_*; do tar -xJf $$f; done
283         touch $@
284
285 $(call pkg-config,festival): $(call pkg-source,festival) $(call pkg-built,speech_tools)
286         cd festival* && [ -f ./configure ] && \
287                 ./configure
288         touch $@
289
290 $(call pkg-built,festival): $(call pkg-config,festival)
291         $(MAKE) -C festival* -j1
292         touch $@
293
294 clean:
295         for f in $(static_pkgs); do rm -rf $$f*; done
296         rm -rf $(BLD)
297
298 install:
299         cp -a $(ver_mjpegtools)/mpeg2enc/mpeg2enc $(BINDIR)/.
300         cp -a $(ver_mjpegtools)/mplex/mplex $(BINDIR)/.
301
302 val-%:
303         @echo $($(subst val-,,$@))
304