Fix previous commit, wasn't actually setting up a symbolic link
[platform/upstream/gst-libav.git] / autogen.sh
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3
4 DIE=0
5 package=gst-ffmpeg
6 srcfile=configure.ac
7 have_svn=`which svn`
8 # FFMPEG specific properties
9 . ./ffmpegrev
10
11 # make sure we have common
12 if test ! -f common/gst-autogen.sh; 
13 then 
14   echo "+ Setting up common submodule"
15   git submodule init
16 fi
17 git submodule update
18
19 if test -x $have_svn && [ $have_svn ];
20 then
21     if test ! -f $FFMPEG_CO_DIR/configure
22     then
23         # checkout ffmpeg from its repository
24         rm -rf $FFMPEG_CO_DIR
25         echo "+ getting ffmpeg from svn"
26         svn -r $FFMPEG_REVISION co $FFMPEG_SVN $FFMPEG_CO_DIR
27         echo "+ updating externals"
28         svn update -r $FFMPEG_EXTERNALS_REVISION $FFMPEG_CO_DIR/libswscale
29     else
30         # update ffmpeg from its repository
31         echo "+ updating ffmpeg checkout"
32         svn -r $FFMPEG_REVISION up $FFMPEG_CO_DIR
33         echo "+ updating externals"
34         svn update -r $FFMPEG_EXTERNALS_REVISION $FFMPEG_CO_DIR/libswscale
35     fi
36 else
37     echo "Subversion needed for ffmpeg checkout, please install and/or add to \$PATH"
38     exit 0
39 fi
40
41 # source helper functions
42 if test ! -f common/gst-autogen.sh;
43 then
44   echo There is something wrong with your source tree.
45   echo You are missing common/gst-autogen.sh
46   exit 1
47 fi
48 . common/gst-autogen.sh
49
50 # install pre-commit hook for doing clean commits
51 if test ! \( -x .git/hooks/pre-commit -a -L .git/hooks/pre-commit \);
52 then
53     rm -f .git/hooks/pre-commit
54     ln -s ../../common/hooks/pre-commit.hook .git/hooks/pre-commit
55 fi
56
57
58 # Let's check if we can disable the building of the ffmpeg binary
59 can_disable=`$FFMPEG_CO_DIR/configure --help | grep 'disable-ffmpeg' | wc -l`
60
61 if [ $can_disable != "0" ]
62 then
63     CONFIGURE_DEF_OPT="--disable-ffmpeg"
64 fi
65
66 # Let's clear the 'exit 1' command when we post an Unknown option
67 echo "Patching ffmpeg ./configure"
68 sed -e '/Unknown option/ {
69 N
70 N
71 s/exit 1/#/
72 }' $FFMPEG_CO_DIR/configure > $FFMPEG_CO_DIR/configure.tmp
73 mv $FFMPEG_CO_DIR/configure.tmp $FFMPEG_CO_DIR/configure
74 chmod +x $FFMPEG_CO_DIR/configure
75
76 autogen_options $@
77
78 echo -n "+ check for build tools"
79 if test ! -z "$NOCHECK"; then echo " skipped"; else  echo; fi
80 version_check "autoconf" "$AUTOCONF autoconf autoconf-2.54 autoconf-2.53 autoconf-2.52" \
81               "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 52 || DIE=1
82 version_check "automake" "$AUTOMAKE automake automake-1.9 automake-1.7 automake-1.6 automake-1.5" \
83               "ftp://ftp.gnu.org/pub/gnu/automake/" 1 6 || DIE=1
84 version_check "libtoolize" "$LIBTOOLIZE libtoolize libtoolize14 glibtoolize" \
85               "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 4 0 || DIE=1
86 version_check "pkg-config" "" \
87               "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
88
89 die_check $DIE
90
91 autoconf_2_52d_check || DIE=1
92 aclocal_check || DIE=1
93 autoheader_check || DIE=1
94
95 die_check $DIE
96
97 # if no arguments specified then this will be printed
98 if test -z "$*"; then
99   echo "+ checking for autogen.sh options"
100   echo "  This autogen script will automatically run ./configure as:"
101   echo "  ./configure $CONFIGURE_DEF_OPT"
102   echo "  To pass any additional options, please specify them on the $0"
103   echo "  command line."
104 fi
105
106 toplevel_check $srcfile
107
108 tool_run "$aclocal" "-I common/m4 $ACLOCAL_FLAGS"
109 tool_run "$libtoolize" "--copy --force"
110 tool_run "$autoheader"
111
112 # touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
113 echo timestamp > stamp-h.in 2> /dev/null
114
115 tool_run "$autoconf"
116 tool_run "$automake" "-a -c -Wno-portability"
117
118 # if enable exists, add an -enable option for each of the lines in that file
119 if test -f enable; then
120   for a in `cat enable`; do
121     CONFIGURE_FILE_OPT="--enable-$a"
122   done
123 fi
124
125 # if disable exists, add an -disable option for each of the lines in that file
126 if test -f disable; then
127   for a in `cat disable`; do
128     CONFIGURE_FILE_OPT="$CONFIGURE_FILE_OPT --disable-$a"
129   done
130 fi
131
132 test -n "$NOCONFIGURE" && {
133   echo "+ skipping configure stage for package $package, as requested."
134   echo "+ autogen.sh done."
135   exit 0
136 }
137
138 echo "+ running configure ... "
139 test ! -z "$CONFIGURE_DEF_OPT" && echo "  ./configure default flags: $CONFIGURE_DEF_OPT"
140 test ! -z "$CONFIGURE_EXT_OPT" && echo "  ./configure external flags: $CONFIGURE_EXT_OPT"
141 test ! -z "$CONFIGURE_FILE_OPT" && echo "  ./configure enable/disable flags: $CONFIGURE_FILE_OPT"
142 echo
143
144 ./configure $CONFIGURE_DEF_OPT $CONFIGURE_EXT_OPT $CONFIGURE_FILE_OPT || {
145         echo "  configure failed"
146         exit 1
147 }
148
149 echo
150 echo "Now type 'make' to compile $package."