]> git.sesse.net Git - x264/blob - configure
* common/i386/i386inc.asm: got PIC to work for real on OS X x86.
[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=""
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     EXE=".exe"
94     DEVNULL="NUL"
95     vfw="yes"
96     ;;
97   MINGW*)
98     SYS="MINGW"
99     EXE=".exe"
100     DEVNULL="NUL"
101     vfw="yes"
102     ;;
103   SunOS)
104     SYS="SunOS"
105     CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
106     LDFLAGS="$LDFLAGS -lm"
107     HAVE_GETOPT_LONG=0
108     ;;
109   *)
110     echo "Unknown system $UNAMES, edit the configure"
111     exit 1
112     ;;
113 esac
114
115 UNAMEM="`uname -m`"
116 case "$UNAMEM" in
117   i386|i486|i586|i686|BePC)
118     ARCH="X86"
119     CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
120     AS="nasm"
121     ASFLAGS="-O2"
122     if [ "$SYS" = MACOSX ]; then
123       ASFLAGS="$ASFLAGS -f macho -DPREFIX"
124     elif [ "$SYS" = CYGWIN -o "$SYS" = MINGW ]; then
125       ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
126     elif [ "$SYS" = FREEBSD -o "$SYS" = NETBSD ]; then
127       ASFLAGS="$ASFLAGS -f aoutb"
128     else
129       ASFLAGS="$ASFLAGS -f elf"
130     fi
131     ;;
132   x86_64)
133     ARCH="X86_64"
134     CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
135     AS="yasm"
136     ASFLAGS="-f elf -m amd64"
137     ;;
138   "Power Macintosh"|ppc)
139     ARCH="PPC"
140     if [ $SYS = MACOSX ]
141     then
142       CFLAGS="$CFLAGS -faltivec"
143     else
144       CFLAGS="$CFLAGS -maltivec -mabi=altivec"
145     fi
146     ;;
147   sun4m|sun4d|sparc|sparc64)
148     ARCH="Sparc"
149     ;;
150   sun4u)
151     ARCH="UltraSparc"
152     CFLAGS="$CFLAGS -mcpu=ultrasparc"
153     LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
154     AS="as"
155     ASFLAGS="-xarch=v8plusa"
156     ;;
157   ia64)
158     ARCH="IA64"
159     ;;
160   alpha)
161     ARCH="ALPHA"
162     ;;
163   mips|mipsel)
164     ARCH="MIPS"
165     ;;
166   m68k)
167     ARCH="M68K"
168     ;;
169   arm|armv5tel)
170     ARCH="ARM"
171     ;;
172   s390|s390x)
173     ARCH="S390"
174     ;;
175   parisc|parisc64)
176     ARCH="PARISC"
177     ;;
178   *)
179     echo "Unknown platform $UNAMEM, edit the configure"
180     exit 1
181     ;;
182 esac
183
184 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
185
186 # parse options
187
188 for opt do
189     optarg="${opt#*=}"
190     case "$opt" in
191         --prefix=*)
192             prefix="$optarg"
193             ;;
194         --exec-prefix=*)
195             exec_prefix="$optarg"
196             ;;
197         --bindir=*)
198             bindir="$optarg"
199             ;;
200         --libdir=*)
201             libdir="$optarg"
202             ;;
203         --includedir=*)
204             includedir="$optarg"
205             ;;
206         --enable-avis-input)
207             avis_input="yes"
208             ;;
209         --disable-avis-input)
210             avis_input="no"
211             ;;
212         --enable-mp4-output)
213             mp4_output="yes"
214             ;;
215         --disable-mp4-output)
216             mp4_output="no"
217             ;;
218         --extra-asflags=*)
219             ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
220             ;;
221         --extra-cflags=*)
222             CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
223             VFW_CFLAGS="${opt#--extra-cflags=}"
224             ;;
225         --extra-ldflags=*)
226             LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
227             VFW_LDFLAGS="${opt#--extra-ldflags=}"
228             ;;
229         --enable-pthread)
230             pthread="yes"
231             ;;
232         --disable-pthread)
233             pthread="no"
234             ;;
235         --enable-debug)
236             CFLAGS="$CFLAGS -g"
237             debug="yes"
238             ;;
239         --enable-gprof)
240             CFLAGS="$CFLAGS -pg"
241             LDFLAGS="$LDFLAGS -pg"
242             gprof="yes"
243             ;;
244         --enable-pic)
245             CFLAGS="$CFLAGS -fPIC"
246             ASFLAGS="$ASFLAGS -D__PIC__"
247             pic="yes"
248             ;;
249         --enable-vfw)
250             vfw="yes"
251             ;;
252         --disable-vfw)
253             vfw="no"
254             ;;
255         --enable-visualize)
256             LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
257             CFLAGS="$CFLAGS -DVISUALIZE=1"
258             vis="yes"
259             ;;
260         *)
261             echo "Unknown option $opt, ignored"
262             ;;
263     esac
264 done
265
266 # autodetect options that weren't forced nor disabled
267
268 if test "$pthread" = "auto" ; then
269     case $SYS in
270         MINGW|CYGWIN|BEOS)
271             pthread="yes"
272             ;;
273         *)
274             pthread="no"
275             cc_check pthread.h -lpthread && pthread="yes"
276             ;;
277     esac
278 fi
279 if test "$pthread" = "yes" ; then
280     CFLAGS="$CFLAGS -DHAVE_PTHREAD=1"
281     case $SYS in
282         MINGW|CYGWIN|BEOS)
283             ;;
284         *) LDFLAGS="$LDFLAGS -lpthread"
285             ;;
286     esac
287 fi
288
289 MP4_LDFLAGS="-lgpac_static"
290 if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
291     MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
292 fi
293 if [ "$mp4_output" = "auto" ] ; then
294     mp4_output="no"
295     cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
296 fi
297 if [ "$mp4_output" = "yes" ] ; then
298     echo "#define MP4_OUTPUT" >> config.h
299     LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
300 fi
301
302 if [ "$avis_input" = "auto" ] ; then
303     if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
304         avis_input="yes"
305     else
306         avis_input="no";
307     fi
308 fi
309 if [ "$avis_input" = "yes" ] ; then
310     echo "#define AVIS_INPUT" >> config.h
311     LDFLAGS="$LDFLAGS -lvfw32"
312 fi
313
314 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
315     CFLAGS="$CFLAGS -s -fomit-frame-pointer"
316     LDFLAGS="$LDFLAGS -s"
317     VFW_LDFLAGS="$VFW_LDFLAGS -s"
318 fi
319
320 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
321     echo "#define fseek fseeko" >> config.h
322     echo "#define ftell ftello" >> config.h
323 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
324     echo "#define fseek fseeko64" >> config.h
325     echo "#define ftell ftello64" >> config.h
326 fi
327
328 # generate config files
329
330 cat > config.mak << EOF
331 prefix=$prefix
332 exec_prefix=$exec_prefix
333 bindir=$bindir
334 libdir=$libdir
335 includedir=$includedir
336 ARCH=$ARCH
337 SYS=$SYS
338 CC=$CC
339 CFLAGS=$CFLAGS
340 LDFLAGS=$LDFLAGS
341 AS=$AS
342 ASFLAGS=$ASFLAGS
343 VFW=$vfw
344 EXE=$EXE
345 VIS=$vis
346 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
347 DEVNULL=$DEVNULL
348 CONFIGURE_ARGS=$@
349 EOF
350
351 if [ "$vfw" = "yes" ]; then
352     rm -f vfw/build/cygwin/config.mak
353     cat > vfw/build/cygwin/config.mak << EOF
354 CFLAGS=$VFW_CFLAGS
355 LDFLAGS=$VFW_LDFLAGS
356 EOF
357     echo "default: x264vfw.dll" >> config.mak
358 fi
359
360 ./version.sh
361
362 cat > x264.pc << EOF
363 prefix=$prefix
364 exec_prefix=$exec_prefix
365 libdir=$libdir
366 includedir=$includedir
367
368 Name: x264
369 Description: H.264 (MPEG4 AVC) encoder library
370 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
371 Libs: -L$libdir -lx264
372 Cflags: -I$includedir
373 EOF
374
375
376 echo "Platform:   $ARCH"
377 echo "System:     $SYS"
378 echo "avis input: $avis_input"
379 echo "mp4 output: $mp4_output"
380 echo "pthread:    $pthread"
381 echo "vfw:        $vfw"
382 echo "debug:      $debug"
383 echo "gprof:      $gprof"
384 echo "PIC:        $pic"
385 echo "visualize:  $vis"
386 echo
387 echo "You can run 'make' or 'make fprofiled' now."
388