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