]> git.sesse.net Git - x264/blob - configure
copy current macroblock to a smaller buffer, to improve cache coherency and reduce...
[x264] / configure
1 #! /bin/sh
2
3 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
4
5 echo "Usage: ./configure [options]"
6 echo ""
7 echo "available options:"
8 echo ""
9 echo "  --help                   print this message"
10 echo "  --enable-avis-input      enables avisynth input (win32 only)"
11 echo "  --enable-mp4-output      enables mp4 output (using gpac)"
12 echo "  --enable-vfw             compiles the VfW frontend"
13 echo "  --enable-pthread         enables multithreaded encoding"
14 echo "  --enable-debug           adds -g, doesn't strip"
15 echo "  --enable-gprof           adds -pg, doesn't strip"
16 echo "  --enable-visualize       enables visualization (X11 only)"
17 echo "  --enable-pic             build position-independent code"
18 echo "  --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS"
19 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS"
20 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS"
21 echo ""
22 exit 1
23 fi
24
25 cc_check() {
26     rm -f conftest*
27     cat > conftest.c << EOF
28 #include <$1>
29 int main () { $3 return 0; }
30 EOF
31     $CC $CFLAGS $LDFLAGS $2 conftest.c -o conftest 2>$DEVNULL
32     TMP="$?"
33     rm -f conftest.c conftest*
34     return $TMP
35 }
36
37 rm -f config.h config.mak x264.pc
38
39 prefix='/usr/local'
40 exec_prefix='${prefix}'
41 bindir='${exec_prefix}/bin'
42 libdir='${exec_prefix}/lib'
43 includedir='${prefix}/include'
44 DEVNULL='/dev/null'
45
46 avis_input="auto"
47 mp4_output="auto"
48 pthread="auto"
49 debug="no"
50 gprof="no"
51 pic="no"
52 vfw="no"
53 vis="no"
54
55 CC="gcc"
56 CFLAGS="-Wall -I. -O4 -ffast-math -D__X264__"
57 LDFLAGS=""
58 HAVE_GETOPT_LONG=1
59
60 AS="nasm"
61 ASFLAGS="-f elf -DFORMAT_ELF"
62
63 EXE=""
64
65 UNAMES="`uname -s`"
66 case "$UNAMES" in
67   BeOS)
68     SYS="BEOS"
69     CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
70     ;;
71   Darwin)
72     SYS="MACOSX"
73     CFLAGS="$CFLAGS -falign-loops=16"
74     LDFLAGS="$LDFLAGS -lm -lmx"
75     ;;
76   FreeBSD)
77     SYS="FREEBSD"
78     LDFLAGS="$LDFLAGS -lm"
79     ;;
80   NetBSD)
81     SYS="NETBSD"
82     LDFLAGS="$LDFLAGS -lm"
83     ;;
84   Linux)
85     SYS="LINUX"
86     CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
87     LDFLAGS="$LDFLAGS -lm"
88     ;;
89   CYGWIN*)
90     SYS="CYGWIN"
91     CFLAGS="$CFLAGS -mno-cygwin"
92     LDFLAGS="$LDFLAGS -mno-cygwin"
93     ASFLAGS="-f win32 -DPREFIX"
94     EXE=".exe"
95     DEVNULL="NUL"
96     vfw="yes"
97     ;;
98   MINGW*)
99     SYS="MINGW"
100     ASFLAGS="-f win32 -DPREFIX"
101     EXE=".exe"
102     DEVNULL="NUL"
103     vfw="yes"
104     ;;
105   SunOS)
106     SYS="SunOS"
107     CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
108     LDFLAGS="$LDFLAGS -lm"
109     HAVE_GETOPT_LONG=0
110     ;;
111   *)
112     echo "Unknown system $UNAMES, edit the configure"
113     exit 1
114     ;;
115 esac
116
117 UNAMEM="`uname -m`"
118 case "$UNAMEM" in
119   i386|i486|i586|i686|BePC)
120     ARCH="X86"
121     CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
122     if [ "$SYS" = MACOSX ]; then
123       ASFLAGS="-f macho -DPREFIX -DFORMAT_MACHO"
124     fi
125     if [ "$SYS" = FREEBSD -o "$SYS" = NETBSD ]; then
126       ASFLAGS="-f aoutb -DFORMAT_AOUTB"
127     fi
128     ;;
129   x86_64)
130     ARCH="X86_64"
131     CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
132     AS="yasm"
133     ASFLAGS="-f elf -m amd64"
134     ;;
135   "Power Macintosh"|ppc)
136     ARCH="PPC"
137     if [ $SYS = MACOSX ]
138     then
139       CFLAGS="$CFLAGS -faltivec"
140     else
141       CFLAGS="$CFLAGS -maltivec -mabi=altivec"
142     fi
143     ;;
144   sun4m|sun4d|sparc|sparc64)
145     ARCH="Sparc"
146     ;;
147   sun4u)
148     ARCH="UltraSparc"
149     CFLAGS="$CFLAGS -mcpu=ultrasparc"
150     LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
151     AS="as"
152     ASFLAGS="-xarch=v8plusa"
153     ;;
154   ia64)
155     ARCH="IA64"
156     ;;
157   alpha)
158     ARCH="ALPHA"
159     ;;
160   mips|mipsel)
161     ARCH="MIPS"
162     ;;
163   m68k)
164     ARCH="M68K"
165     ;;
166   arm|armv5tel)
167     ARCH="ARM"
168     ;;
169   s390|s390x)
170     ARCH="S390"
171     ;;
172   parisc|parisc64)
173     ARCH="PARISC"
174     ;;
175   *)
176     echo "Unknown platform $UNAMEM, edit the configure"
177     exit 1
178     ;;
179 esac
180
181 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
182
183 # parse options
184
185 for opt do
186     optarg="${opt#*=}"
187     case "$opt" in
188         --prefix=*)
189             prefix="$optarg"
190             ;;
191         --exec-prefix=*)
192             exec_prefix="$optarg"
193             ;;
194         --bindir=*)
195             bindir="$optarg"
196             ;;
197         --libdir=*)
198             libdir="$optarg"
199             ;;
200         --includedir=*)
201             includedir="$optarg"
202             ;;
203         --enable-avis-input)
204             avis_input="yes"
205             ;;
206         --disable-avis-input)
207             avis_input="no"
208             ;;
209         --enable-mp4-output)
210             mp4_output="yes"
211             ;;
212         --disable-mp4-output)
213             mp4_output="no"
214             ;;
215         --extra-asflags=*)
216             ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
217             ;;
218         --extra-cflags=*)
219             CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
220             VFW_CFLAGS="${opt#--extra-cflags=}"
221             ;;
222         --extra-ldflags=*)
223             LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
224             VFW_LDFLAGS="${opt#--extra-ldflags=}"
225             ;;
226         --enable-pthread)
227             pthread="yes"
228             ;;
229         --disable-pthread)
230             pthread="no"
231             ;;
232         --enable-debug)
233             CFLAGS="$CFLAGS -g"
234             debug="yes"
235             ;;
236         --enable-gprof)
237             CFLAGS="$CFLAGS -pg"
238             LDFLAGS="$LDFLAGS -pg"
239             gprof="yes"
240             ;;
241         --enable-pic)
242             CFLAGS="$CFLAGS -fPIC"
243             ASFLAGS="$ASFLAGS -D__PIC__"
244             pic="yes"
245             ;;
246         --enable-vfw)
247             vfw="yes"
248             ;;
249         --disable-vfw)
250             vfw="no"
251             ;;
252         --enable-visualize)
253             LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
254             CFLAGS="$CFLAGS -DVISUALIZE=1"
255             vis="yes"
256             ;;
257         *)
258             echo "Unknown option $opt, ignored"
259             ;;
260     esac
261 done
262
263 # autodetect options that weren't forced nor disabled
264
265 if test "$pthread" = "auto" ; then
266     case $SYS in
267         MINGW|CYGWIN|BEOS)
268             pthread="yes"
269             ;;
270         *)
271             pthread="no"
272             cc_check pthread.h -lpthread && pthread="yes"
273             ;;
274     esac
275 fi
276 if test "$pthread" = "yes" ; then
277     CFLAGS="$CFLAGS -DHAVE_PTHREAD=1"
278     case $SYS in
279         MINGW|CYGWIN|BEOS)
280             ;;
281         *) LDFLAGS="$LDFLAGS -lpthread"
282             ;;
283     esac
284 fi
285
286 MP4_LDFLAGS="-lgpac_static"
287 if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
288     MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
289 fi
290 if [ "$mp4_output" = "auto" ] ; then
291     mp4_output="no"
292     cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
293 fi
294 if [ "$mp4_output" = "yes" ] ; then
295     echo "#define MP4_OUTPUT" >> config.h
296     LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
297 fi
298
299 if [ "$avis_input" = "auto" ] ; then
300     if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
301         avis_input="yes"
302     else
303         avis_input="no";
304     fi
305 fi
306 if [ "$avis_input" = "yes" ] ; then
307     echo "#define AVIS_INPUT" >> config.h
308     LDFLAGS="$LDFLAGS -lvfw32"
309 fi
310
311 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
312     CFLAGS="$CFLAGS -s -fomit-frame-pointer"
313     LDFLAGS="$LDFLAGS -s"
314     VFW_LDFLAGS="$VFW_LDFLAGS -s"
315 fi
316
317 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
318     echo "#define fseek fseeko" >> config.h
319     echo "#define ftell ftello" >> config.h
320 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
321     echo "#define fseek fseeko64" >> config.h
322     echo "#define ftell ftello64" >> config.h
323 fi
324
325 # generate config files
326
327 cat > config.mak << EOF
328 prefix=$prefix
329 exec_prefix=$exec_prefix
330 bindir=$bindir
331 libdir=$libdir
332 includedir=$includedir
333 ARCH=$ARCH
334 SYS=$SYS
335 CC=$CC
336 CFLAGS=$CFLAGS
337 LDFLAGS=$LDFLAGS
338 AS=$AS
339 ASFLAGS=$ASFLAGS
340 VFW=$vfw
341 EXE=$EXE
342 VIS=$vis
343 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
344 DEVNULL=$DEVNULL
345 CONFIGURE_ARGS=$@
346 EOF
347
348 if [ "$vfw" = "yes" ]; then
349     rm -f vfw/build/cygwin/config.mak
350     cat > vfw/build/cygwin/config.mak << EOF
351 CFLAGS=$VFW_CFLAGS
352 LDFLAGS=$VFW_LDFLAGS
353 EOF
354     echo "default: x264vfw.dll" >> config.mak
355 fi
356
357 ./version.sh
358
359 cat > x264.pc << EOF
360 prefix=$prefix
361 exec_prefix=$exec_prefix
362 libdir=$libdir
363 includedir=$includedir
364
365 Name: x264
366 Description: H.264 (MPEG4 AVC) encoder library
367 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
368 Libs: -L$libdir -lx264
369 Cflags: -I$includedir
370 EOF
371
372
373 echo "Platform:   $ARCH"
374 echo "System:     $SYS"
375 echo "avis input: $avis_input"
376 echo "mp4 output: $mp4_output"
377 echo "pthread:    $pthread"
378 echo "vfw:        $vfw"
379 echo "debug:      $debug"
380 echo "gprof:      $gprof"
381 echo "PIC:        $pic"
382 echo "visualize:  $vis"
383 echo
384 echo "You can run 'make' or 'make fprofiled' now."
385