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