OSDN Git Service

Disable ssse3 h264_qpel optimizations to workaround a crash in h.264 decoder on OS X.
[handbrake-jp/handbrake-jp-git.git] / contrib / Jamfile
1 SubDir TOP contrib ;
2
3 # Use curl on Mac OS X since it's always installed, and assume wget
4 # is installed for all other systems
5 if $(OS) = MACOSX
6 {
7     WGET = curl -q -L -o ;
8 }
9 else
10 {
11     WGET = wget -O ;
12 }
13
14 if $(OS) = UNKNOWN
15 {
16     OS = CYGWIN ;
17 }
18
19 if $(OS) = SOLARIS
20 {
21     PATCH = gpatch ;
22     STRIP = echo ;
23 }
24 else
25 {
26     PATCH = patch ;
27     STRIP = strip -S ;
28 }
29
30 # Wget rule: downloads $(<) from the link in $(>)
31 rule Wget
32 {
33     Depends $(<) : $(>) ;
34 }
35 actions Wget
36 {
37     $(RM) $(<) &&
38     $(WGET) $(<) `cat $(>)` &&
39     ( touch $(<) || true )
40 }
41
42 # liba52
43 rule LibA52
44 {
45     Depends $(<) : $(>) ;
46     Depends lib  : $(<) ;
47 }
48 actions LibA52
49 {
50
51     cd `dirname $(>)` && CONTRIB=`pwd` &&
52     rm -rf a52dec && (gzip -dc a52dec.tar.gz | tar xf -) && 
53     cd a52dec && $(PATCH) -p1 < ../patch-a52dec.patch &&
54     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache && $(MAKE) && $(MAKE) install &&
55     $(STRIP) $CONTRIB/lib/liba52.a
56 }
57 Wget   $(SUBDIR)/a52dec.tar.gz : $(SUBDIR)/version_a52dec.txt ;
58 LibA52 $(SUBDIR)/lib/liba52.a  : $(SUBDIR)/a52dec.tar.gz ;
59
60 # FAAD2
61 rule LibFaad2
62 {
63     Depends $(<) : $(>) ;
64     Depends lib  : $(<) ;
65 }
66
67 actions LibFaad2
68 {
69     cd `dirname $(>)` && CONTRIB=`pwd` &&
70     rm -rf faad2 && (gzip -dc faad2.tar.gz | tar xf -) &&
71     cd faad2 && $(PATCH) -p1 < ../patch-faad2-libtool22.patch &&
72     ./bootstrap && ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared && $(MAKE) && $(MAKE) install
73 }
74 Wget     $(SUBDIR)/faad2.tar.gz    : $(SUBDIR)/version_faad2.txt ;
75 LibFaad2 $(SUBDIR)/lib/libfaad.a : $(SUBDIR)/faad2.tar.gz ;
76
77 # libavcodec
78 rule LibAvCodec
79 {
80     FFMPEG_PATCH = "$(PATCH) -p0 < ../patch-ffmpeg.patch" ;
81     FFMPEG_PATCH += " && $(PATCH) -p0 < ../patch-ffmpeg-latm.patch " ;
82     FFMPEG_PATCH += " && $(PATCH) -p0 < ../patch-ffmpeg-mpegleak.patch " ;
83     if $(OS) = CYGWIN
84     {
85         FFMPEG_PATCH += " && $(PATCH) -p1 < ../patch-ffmpeg-cygwin.patch " ;
86     }
87     else if $(OS) = SOLARIS
88     {
89         FFMPEG_PATCH += " && $(PATCH) -p1 < ../patch-ffmpeg-solaris.patch " ;
90     }
91     else if $(OS) = MACOSX
92     {
93         FFMPEG_PATCH += " && $(PATCH) -p1 < ../patch-ffmpeg-h264dsp-crash.diff " ;
94     }
95
96     if $(OS) = SOLARIS
97     {
98        #
99        # Not all of ffmpeg works on Solaris - disable the bits that
100        # don't. When we get new versions of FFMPEG we can try enabling
101        # then again.
102        #
103        FFMPEG_EXTRA_OPTIONS = "--disable-vis --disable-demuxer=mpc8 --disable-vhook --disable-network" ;
104     }
105
106     Depends $(<) : $(>) ;
107     Depends lib  : $(<) ;
108 }
109 actions LibAvCodec
110 {
111     cd `dirname $(>)` && CONTRIB=`pwd` &&
112     rm -rf ffmpeg && (gzip -dc ffmpeg.tar.gz | tar xf -) &&
113     cd ffmpeg && $(FFMPEG_PATCH) &&
114     ./configure --prefix=$CONTRIB --enable-gpl --enable-pthreads --enable-swscale \
115         --disable-shared --enable-static --disable-encoders \
116         --enable-encoder=mpeg4 --enable-encoder=ac3 --enable-encoder=snow \
117         --enable-libfaad --disable-ffmpeg --disable-ffserver \
118         --disable-muxers --enable-muxer=ipod --disable-bsfs --disable-vhook \
119         --extra-cflags="-I$CONTRIB/include" \
120         --extra-ldflags="-L$CONTRIB/lib" $(FFMPEG_EXTRA_OPTIONS) &&
121     $(MAKE) && $(MAKE) install &&
122     $(STRIP) $CONTRIB/lib/libavcodec.a
123 }
124 Wget       $(SUBDIR)/ffmpeg.tar.gz    : $(SUBDIR)/version_ffmpeg.txt ;
125 LibAvCodec $(SUBDIR)/lib/libavcodec.a : $(SUBDIR)/ffmpeg.tar.gz ;
126
127 rule LibAvUtil
128 {
129     Depends $(<) : $(>) ;
130     Depends lib  : $(<) ;
131 }
132 actions LibAvUtil
133 {
134     $(STRIP) $(<)
135 }
136 LibAvUtil $(SUBDIR)/lib/libavutil.a : $(SUBDIR)/lib/libavcodec.a ;
137 LibAvUtil $(SUBDIR)/lib/libavformat.a : $(SUBDIR)/lib/libavcodec.a ;
138 LibAvUtil $(SUBDIR)/lib/libswscale.a : $(SUBDIR)/lib/libavcodec.a ;
139
140 # HandBrake does not include a DVD decrypting library,
141 # so if a user requests it, let them download and compile it from a 3rd party
142 if $(CSS) = 1
143 {
144     # libdvdcss
145     # We need libdvdcss.so for libdvdread's configure to work...
146     rule LibDvdCss
147     {
148         Depends $(<) : $(>) ;
149         Depends lib  : $(<) ;
150     }
151     actions LibDvdCss
152     {
153         cd `dirname $(>)` && CONTRIB=`pwd` &&
154         rm -rf libdvdcss-1.2.9 && (gzip -dc libdvdcss.tar.gz | tar xf - ) && 
155         cd libdvdcss-1.2.9 &&
156         ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache && $(MAKE) && $(MAKE) install &&
157         $(STRIP) $CONTRIB/lib/libdvdcss.a
158     }
159     Wget      $(SUBDIR)/libdvdcss.tar.gz : $(SUBDIR)/version_libdvdcss.txt ;
160     LibDvdCss $(SUBDIR)/lib/libdvdcss.a  : $(SUBDIR)/libdvdcss.tar.gz ;
161 }
162
163 # libdca
164 rule LibDCA
165 {
166     Depends $(<) : $(>) ;
167     Depends lib  : $(<) ;
168 }
169 actions LibDCA
170 {
171     cd `dirname $(>)` && CONTRIB=`pwd` &&
172     rm -rf libdca && (gzip -dc libdca.tar.gz | tar xf - ) && 
173     cd libdca && $(PATCH) -p1 < ../patch-libdca.patch &&
174     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache && $(MAKE) && $(MAKE) install &&
175     $(STRIP) $CONTRIB/lib/libdca.a
176 }
177 Wget   $(SUBDIR)/libdca.tar.gz : $(SUBDIR)/version_libdca.txt ;
178 LibDCA $(SUBDIR)/lib/libdca.a  : $(SUBDIR)/libdca.tar.gz ;
179
180 # libdvdread
181 rule LibDvdRead
182 {
183     Depends $(<) : $(>) ;
184     Depends lib  : $(<) ;
185     
186     if $(OS) = MACOSX
187     {
188         DVDREAD_PATCH = "$(PATCH) -p0 < ../patch-libdvdread-css-vlc-dylib.patch &&" ;
189     }
190         
191     if $(OS) = CYGWIN
192     {
193         DVDREAD_PATCH = "$(PATCH) -p1 < ../patch-libdvdread-cygwin.patch &&" ;
194     }
195     
196 }
197 if $(CSS) = 1 # Include CSS support in libdvdread if requested
198 {
199     actions LibDvdRead
200     {
201         cd `dirname $(>)` && CONTRIB=`pwd` &&
202         rm -rf libdvdread && (gzip -dc libdvdread.tar.gz | tar xf - ) && 
203         cd libdvdread &&
204         ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared --with-libdvdcss=$CONTRIB &&
205         $(MAKE) && $(MAKE) install &&
206         $(STRIP) $CONTRIB/lib/libdvdread.a
207     }
208 }
209 else {
210     # Cygwin/Windows doesn't use CSS as of now, so don't include it on the
211     # configure line.
212     # MacOSX uses a dylib for CSS, so it doesn't need including there either.
213     actions LibDvdRead
214     {
215         cd `dirname $(>)` && CONTRIB=`pwd` &&
216         rm -rf libdvdread && (gzip -dc libdvdread.tar.gz | tar xf - ) &&
217         cd libdvdread && $(DVDREAD_PATCH)
218         ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared &&
219         $(MAKE) && $(MAKE) install &&
220         $(STRIP) $CONTRIB/lib/libdvdread.a
221     }
222 }
223 Wget       $(SUBDIR)/libdvdread.tar.gz : $(SUBDIR)/version_libdvdread.txt ;
224 LibDvdRead $(SUBDIR)/lib/libdvdread.a  : $(SUBDIR)/libdvdread.tar.gz ;
225
226 # libfaac
227 rule LibFaac
228 {
229     Depends $(<) : $(>) ;
230     Depends lib  : $(<) ;
231         if $(OS) = CYGWIN
232     {
233         CYGWIN_PATCH = "$(PATCH) -p1 < ../patch-faac-cygwin.patch &&" ;
234     }
235 }
236 actions LibFaac
237 {
238     cd `dirname $(>)` && CONTRIB=`pwd` &&
239     rm -rf faac && (gzip -dc faac.tar.gz | tar xf - ) && cd faac && $(CYGWIN_PATCH) ./bootstrap &&
240     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared --enable-static --without-mp4v2 &&
241     $(MAKE) && $(MAKE) install &&
242     $(STRIP) $CONTRIB/lib/libfaac.a
243 }
244 Wget    $(SUBDIR)/faac.tar.gz   : $(SUBDIR)/version_faac.txt ;
245 LibFaac $(SUBDIR)/lib/libfaac.a : $(SUBDIR)/faac.tar.gz ;
246
247 # libmp3lame
248 rule LibMp3Lame
249 {
250     Depends $(<) : $(>) ;
251     Depends lib  : $(<) ;
252 }
253 actions LibMp3Lame
254 {
255     cd `dirname $(>)` && CONTRIB=`pwd` &&
256     rm -rf lame && (gzip -dc lame.tar.gz | tar xf - ) && cd lame &&
257     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared &&
258     $(MAKE) && $(MAKE) install &&
259     $(STRIP) $CONTRIB/lib/libmp3lame.a
260 }
261 Wget       $(SUBDIR)/lame.tar.gz      : $(SUBDIR)/version_lame.txt ;
262 LibMp3Lame $(SUBDIR)/lib/libmp3lame.a : $(SUBDIR)/lame.tar.gz ;
263
264 # libmp4v2
265 rule LibMp4v2
266 {
267     LIBMP4V2_PATCH = "" ;
268     Depends $(<) : $(>) ;
269     Depends lib  : $(<) ;
270 }
271 actions LibMp4v2
272 {
273     cd `dirname $(>)` && CONTRIB=`pwd` &&
274     rm -rf libmp4v2 && (gzip -dc libmp4v2.tar.gz | tar xf - ) &&
275     cd libmp4v2 && $(LIBMP4V2_PATCH) rm -rf build && mkdir build && cd build &&
276     ../configure --disable-shared --disable-debug --prefix=$CONTRIB && $(MAKE) && make install &&
277     $(STRIP) $CONTRIB/lib/libmp4v2.a
278 }
279 Wget     $(SUBDIR)/libmp4v2.tar.gz : $(SUBDIR)/version_libmp4v2.txt ;
280 LibMp4v2 $(SUBDIR)/lib/libmp4v2.a : $(SUBDIR)/libmp4v2.tar.gz ;
281
282 rule LibMkv
283 {
284     Depends $(<) : $(>) ;
285     Depends lib  : $(<) ;
286 }
287 actions LibMkv
288 {
289     cd `dirname $(>)` && CONTRIB=`pwd` &&
290     rm -rf libmkv && (gzip -dc libmkv.tar.gz | tar xf - ) && 
291     cd libmkv &&
292     ./configure --disable-shared --enable-static --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache &&
293     $(MAKE) && $(MAKE) install &&
294     $(STRIP) $CONTRIB/lib/libmkv.a
295 }
296 Wget    $(SUBDIR)/libmkv.tar.gz : $(SUBDIR)/version_libmkv.txt ;
297 LibMkv  $(SUBDIR)/lib/libmkv.a  : $(SUBDIR)/libmkv.tar.gz ;
298
299 # libmpeg2
300 rule LibMpeg2
301 {
302     Depends $(<) : $(>) ;
303     Depends lib  : $(<) ;
304 }
305 actions LibMpeg2
306 {
307     cd `dirname $(>)` && CONTRIB=`pwd` &&
308     rm -rf mpeg2dec && (gzip -dc mpeg2dec.tar.gz | tar xf - ) && 
309     cd mpeg2dec &&
310     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared --disable-sdl --without-x &&
311     $(MAKE) && $(MAKE) install &&
312     $(STRIP) $CONTRIB/lib/libmpeg2.a
313 }
314 Wget     $(SUBDIR)/mpeg2dec.tar.gz : $(SUBDIR)/version_mpeg2dec.txt ;
315 LibMpeg2 $(SUBDIR)/lib/libmpeg2.a  : $(SUBDIR)/mpeg2dec.tar.gz ;
316
317 # libogg
318 rule LibOgg
319 {
320     Depends $(<) : $(>) ;
321     Depends lib  : $(<) ;
322 }
323 actions LibOgg
324 {
325     cd `dirname $(>)` && CONTRIB=`pwd` &&
326     rm -rf libogg && (gzip -dc libogg.tar.gz | tar xf - ) && 
327     cd libogg &&
328     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared &&
329     $(MAKE) && $(MAKE) install &&
330     $(STRIP) $CONTRIB/lib/libogg.a
331 }
332 Wget   $(SUBDIR)/libogg.tar.gz : $(SUBDIR)/version_libogg.txt ;
333 LibOgg $(SUBDIR)/lib/libogg.a  : $(SUBDIR)/libogg.tar.gz ;
334
335 # libsamplerate
336 rule LibSampleRate
337 {
338     Depends $(<) : $(>) ;
339     Depends lib  : $(<) ;
340 }
341 actions LibSampleRate
342 {
343     cd `dirname $(>)` && CONTRIB=`pwd` &&
344     rm -rf libsamplerate && (gzip -dc libsamplerate.tar.gz | tar xf - ) && 
345     cd libsamplerate &&
346     ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared &&
347     $(MAKE) && $(MAKE) install &&
348     $(STRIP) $CONTRIB/lib/libsamplerate.a
349 }
350 Wget          $(SUBDIR)/libsamplerate.tar.gz : $(SUBDIR)/version_libsamplerate.txt ;
351 LibSampleRate $(SUBDIR)/lib/libsamplerate.a  : $(SUBDIR)/libsamplerate.tar.gz ;
352
353 # libvorbis
354 rule LibVorbis
355 {
356     Depends $(<) : $(>) ;
357     Depends lib  : $(<) ;
358 }
359 actions LibVorbis
360 {
361     cd `dirname $(>)` && CONTRIB=`pwd` &&
362     rm -rf libvorbis && (gzip -dc libvorbis.tar.gz | tar xf - ) &&
363     cd libvorbis &&
364     ./configure --prefix=$CONTRIB --with-ogg=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared &&
365     $(MAKE) && $(MAKE) install &&
366     $(STRIP) $CONTRIB/lib/libvorbis.a
367 }
368 Wget      $(SUBDIR)/libvorbis.tar.gz : $(SUBDIR)/version_libvorbis.txt ;
369 LibVorbis $(SUBDIR)/lib/libvorbis.a  : $(SUBDIR)/libvorbis.tar.gz ;
370
371 rule LibVorbisEnc
372 {
373     Depends $(<) : $(>) ;
374     Depends lib  : $(<) ;
375 }
376 actions LibVorbisEnc
377 {
378     $(STRIP) $(<)
379 }
380 LibVorbisEnc $(SUBDIR)/lib/libvorbisenc.a : $(SUBDIR)/lib/libvorbis.a ;
381
382 # libtheora
383 rule LibTheora
384 {
385     Depends $(<) : $(>) ;
386     Depends lib  : $(<) ;
387 }
388 actions LibTheora
389 {
390     cd `dirname $(>)` && CONTRIB=`pwd` && rm -rf libtheora &&
391     (gzip -dc libtheora.tar.gz | tar xf - ) && cd libtheora &&
392     HAVE_PKG_CONFIG="no" && export HAVE_PKG_CONFIG &&
393     ./configure --prefix=$CONTRIB --with-ogg=$CONTRIB --with-vorbis=$CONTRIB --cache-file=$CONTRIB/config.cache --disable-shared \
394             --disable-oggtest --disable-vorbistest --disable-sdltest --disable-examples &&
395     $(MAKE) && $(MAKE) install &&
396     $(STRIP) $CONTRIB/lib/libtheora.a
397 }
398 Wget      $(SUBDIR)/libtheora.tar.gz : $(SUBDIR)/version_libtheora.txt ;
399 LibTheora $(SUBDIR)/lib/libtheora.a  : $(SUBDIR)/libtheora.tar.gz ;
400
401 # libx264
402 rule LibX264
403 {
404     LIBX264_PATCH = "" ;
405     if $(OS) = CYGWIN
406     {
407         LIBX264_PATCH += "$(PATCH) -p1 < ../patch-x264-cygwin.patch && " ;
408     }
409     else if $(OS) = SOLARIS
410     {
411         LIBX264_PATCH += " $(PATCH) -p1 < ../patch-x264-solaris.patch && " ;
412     }
413     LIBX264_PATCH += "$(PATCH) -p0 < ../patch-x264-idr.patch && " ;
414         Depends $(<) : $(>) ;
415     Depends lib  : $(<) ;
416 }
417 actions LibX264
418 {
419     cd `dirname $(>)` && CONTRIB=`pwd` &&
420     rm -rf x264 && (gzip -dc x264.tar.gz | tar xf - ) && 
421     cd x264 && $(LIBX264_PATCH)
422     bash ./configure --prefix=$CONTRIB --enable-pthread &&
423     $(MAKE) libx264.a && cp libx264.a $CONTRIB/lib/ && cp x264.h $CONTRIB/include/ && $(STRIP) $CONTRIB/lib/libx264.a
424 }
425 Wget    $(SUBDIR)/x264.tar.gz   : $(SUBDIR)/version_x264.txt ;
426 LibX264 $(SUBDIR)/lib/libx264.a : $(SUBDIR)/x264.tar.gz ;
427
428 # libxvidcore
429 rule LibXvidCore
430 {
431     LIBXVIDCORE_PATCH = "" ;
432     if $(OS) = MACOSX
433     {
434         LIBXVIDCORE_PATCH = "$(PATCH) -p1 < ../patch-xvidcore-macosx.patch && " ;
435     }
436     else if $(OS) = CYGWIN
437     {
438         LIBXVIDCORE_PATCH = "$(PATCH) -p1 < ../patch-xvidcore-cygwin.patch && " ;
439     }
440     LIBXVIDCORE_PATCH += "$(PATCH) -p1 < ../patch-xvidcore-nasm-2.00-configure.patch && " ;
441     LIBXVIDCORE_PATCH += "$(PATCH) -p1 < ../patch-xvidcore-fdct.patch && " ;
442     Depends $(<) : $(>) ;
443     Depends lib  : $(<) ;
444 }
445 actions LibXvidCore
446 {
447     cd `dirname $(>)` && CONTRIB=`pwd` &&
448     rm -rf xvidcore && (gzip -dc xvidcore.tar.gz | tar xf - ) &&
449     cd xvidcore && $(LIBXVIDCORE_PATCH)
450     cd build/generic/ && ./configure --prefix=$CONTRIB --cache-file=$CONTRIB/config.cache && $(MAKE) libxvidcore.a &&
451     cp ./=build/libxvidcore.a $CONTRIB/lib/ &&
452     cp ../../src/xvid.h $CONTRIB/include/ &&
453     $(STRIP) $CONTRIB/lib/libxvidcore.a
454 }
455 Wget        $(SUBDIR)/xvidcore.tar.gz   : $(SUBDIR)/version_xvidcore.txt ;
456 LibXvidCore $(SUBDIR)/lib/libxvidcore.a : $(SUBDIR)/xvidcore.tar.gz ;
457
458 # zlib
459 if $(OS) = CYGWIN
460 {
461     rule Zlib
462     {
463         Depends $(<) : $(>) ;
464         Depends lib  : $(<) ;
465     }
466     actions Zlib
467     {
468         cd `dirname $(>)` && CONTRIB=`pwd` &&
469         rm -rf zlib && (gzip -dc zlib.tar.gz | tar xf - ) &&
470         cd zlib && ./configure --prefix=$CONTRIB &&
471         $(MAKE) && $(MAKE) install && touch $CONTRIB/.contrib &&
472         $(STRIP) $CONTRIB/lib/libz.a
473     }
474     Wget  $(SUBDIR)/zlib.tar.gz : $(SUBDIR)/version_zlib.txt ;
475     Zlib  $(SUBDIR)/lib/libz.a  : $(SUBDIR)/zlib.tar.gz ;
476 }
477
478 # bzip2
479 if $(OS) = CYGWIN
480 {
481     rule BZip2
482     {
483         Depends $(<) : $(>) ;
484         Depends lib  : $(<) ;
485     }
486     actions BZip2
487     {
488         cd `dirname $(>)` && CONTRIB=`pwd` &&
489         rm -rf bzip2 && (gzip -dc bzip2.tar.gz | tar xf - ) &&
490         cd bzip2 && $(MAKE) && $(MAKE) install && cp libbz2.a $CONTRIB/lib/ &&
491         $(STRIP) $CONTRIB/lib/libbz2.a
492     }
493     Wget  $(SUBDIR)/bzip2.tar.gz : $(SUBDIR)/version_bzip2.txt ;
494     BZip2  $(SUBDIR)/lib/libbz2.a  : $(SUBDIR)/bzip2.tar.gz ;
495 }