]> git.sesse.net Git - mlt/blob - configure
configure
[mlt] / configure
1 #!/bin/sh
2
3 function show_help
4 {
5         cat << EOF
6 Non-autotool config script for MLT.
7
8 Help options:
9
10   --help                  - this information
11
12 General build options:
13
14   --prefix=directory      - install prefix for path (default: $prefix)
15   --enable-gpl            - Enable GPL components
16   --enable-motion-est     - Enable motion estimation components
17   --disable-debug         - Compile without debug support (default: on)
18   --disable-mmx           - Compile without MMX support (default: on)
19   --cpu='cpu'             - Compile for a specific CPU/architectre (default: none)
20
21 Module disables options:
22
23 EOF
24
25         for i in src/modules/*
26         do
27                 [ -d $i ] && [ "`basename $i`" != "CVS" ] && echo `basename $i` `[ -f $i/gpl ] && echo [GPL]`
28         done |
29         awk '{ printf( "  --disable-%-14.14s- Disable the %s module %s\n", $1, $1, $2 ); }'
30
31         echo
32         echo "  NOTE: libraries marked [GPL] will not be built unless --enable-gpl is stipulated."
33         echo
34 }
35
36 function build_config
37 {
38         (
39                 echo "version=$version"
40                 echo "prefix=$prefix"
41                 echo "bindir=$prefix/bin"
42                 echo "targetos=$targetos"
43
44                 [ "$mmx" = "true" ] && 
45                 echo "MMX_FLAGS=-DUSE_MMX"
46
47                 [ "$debug" = "true" ] && 
48                 echo "DEBUG_FLAGS=-g"
49
50                 echo "LARGE_FILE=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
51
52                 [ "$cpu" != "" ] &&
53                 echo "TARGETARCH=-march=$cpu" &&
54                 echo "TARGETCPU=-mcpu=$cpu"
55
56                 echo "OPTIMISATIONS=-O4 -pipe -ffast-math -fomit-frame-pointer"
57                 echo "CFLAGS+=-Wall -fPIC -DPIC \$(TARGETARCH) \$(TARGETCPU) \$(OPTIMISATIONS) \$(MMX_FLAGS) \$(DEBUG_FLAGS) \$(LARGE_FILE)"
58
59                 case $targetos in
60                 Darwin)
61                 echo "CFLAGS+=-D__DARWIN__ `sdl-config --cflags`"
62                 echo "SHFLAGS=-dynamiclib"
63                 echo "LDFLAGS+=`sdl-config --libs`"
64                 ;;
65                 Linux)
66                 echo "CFLAGS+=-pthread"
67                 echo "SHFLAGS=-shared"
68                 echo "LIBDL=-ldl"
69                 echo "RDYNAMIC=-rdynamic"
70                 ;;
71                 *)
72                 ;;
73                 esac
74                 echo "LIBSUF=$LIBSUF"
75         ) > config.mak
76
77         echo "#!/bin/sh" > mlt-config
78         (
79                 echo export version=$version
80                 echo export prefix=$prefix
81                 echo export bindir=$prefix/bin
82         ) >> mlt-config
83
84         cat < mlt-config-template >> mlt-config
85
86         echo -n > packages.dat
87 }
88
89 function build_pkgconfig
90 {
91         for i in framework valerie miracle
92         do
93                 echo "prefix=$prefix" >mlt-$i.pc
94                 echo "exec_prefix=$prefix" >>mlt-$i.pc
95                 echo "libdir=$prefix/lib" >>mlt-$i.pc
96                 echo "includedir=$prefix/include" >>mlt-$i.pc
97                 echo "version=$version" >>mlt-$i.pc
98                 echo "cflags=`grep ^$i packages.dat | cut -f 2`" >>mlt-$i.pc
99                 echo "libs=`grep ^$i packages.dat | cut -f 3`" >>mlt-$i.pc
100                 cat mlt-$i.pc.in >>mlt-$i.pc
101         done
102 }
103
104 # Debug mode
105 set +x
106
107 # Define build directory for scripts called
108 export build_dir=`dirname $0`
109 export prefix=/usr/local
110 export help=0
111 export version=0.1.1
112 export debug=true
113 export mmx=true
114 export gpl=false
115 export cpu=
116 export motionest=false
117
118 # Determine OS
119 targetos=$(uname -s)
120 # Chose appropriate suffix for libraries
121 case $targetos in
122         Darwin)
123         LIBSUF=".dylib"
124         mmx=false
125         ;;
126         Linux)
127         LIBSUF=".so"
128         ;;
129         *)
130         LIBSUF=".so"
131         ;;
132 esac
133 export LIBSUF
134
135 # Iterate through arguments
136 for i in "$@"
137 do
138         case $i in
139                 --help )                        help=1 ;;
140                 --prefix=* )            prefix="${i#--prefix=}" ;;
141                 --disable-debug )       debug=false ;;
142                 --disable-mmx )         mmx=false ;;
143                 --enable-gpl )          gpl=true ;;
144                 --enable-motion-est )   motionest=true ;;
145                 --cpu=* )                       cpu="${i#--cpu=}" ;;
146         esac
147 done
148
149 # Double check mmx (may end up disabling mmx on non-linux platforms incorrectly)
150 if [ "$mmx" = "true" ]
151 then
152         grep mmx /proc/cpuinfo > /dev/null 2>&1 || mmx=false
153 fi
154
155 # Show help if requested
156 [ $help = 1 ] && show_help || build_config
157
158 # Iterate through each of the components
159 for i in framework modules inigo valerie miracle humperdink
160 do
161         if [ -x src/$i/configure ]
162         then
163                 [ $help = 0 ] && echo "Configuring `basename $i`:"
164                 olddir=`pwd`
165                 cd src/$i
166                 ./configure "$@"
167                 [ $? != 0 ] && exit 1
168                 cd $olddir
169         fi
170 done
171
172 # Build the pkg-config files
173 build_pkgconfig
174
175 # Report GPL Usage
176 [ $help != 1 ] && 
177 ( [ "$gpl" = "false" ] && 
178 echo "GPL Components are disabled" || 
179 echo "GPL License Used" )
180
181 if [ "$motionest" = "true" -a "$gpl" = "false" ]
182 then
183         echo "Add the --enable-gpl flag to build the motion estimation components."
184 fi