Blame view

trunk/auto/options.sh 18.0 KB
1 2
#!/bin/bash
3 4
# variables, parent script must set it:
5 6 7 8 9 10 11 12 13
#####################################################################################
#####################################################################################
# parse user options, do this at first
#####################################################################################
#####################################################################################

#####################################################################################
# output variables
#####################################################################################
14 15 16
help=no

SRS_HLS=RESERVED
17
SRS_NGINX=RESERVED
18
SRS_SSL=RESERVED
winlin authored
19
SRS_FFMPEG=RESERVED
20
SRS_HTTP_CALLBACK=RESERVED
winlin authored
21
SRS_LIBRTMP=RESERVED # srs-librtmp
22
SRS_BWTC=RESERVED # srs-bandwidth-test client
23
SRS_RESEARCH=RESERVED
winlin authored
24
SRS_UTEST=RESERVED
winlin authored
25 26 27 28
SRS_GPERF=RESERVED # tcmalloc
SRS_GPERF_MC=RESERVED # gperf memory check
SRS_GPERF_MP=RESERVED # gperf memory profile
SRS_GPERF_CP=RESERVED # gperf cpu profile
winlin authored
29
SRS_GPROF=RESERVED # gprof
30
SRS_ARM_UBUNTU12=RESERVED # armhf(v7cpu) built on ubuntu12
winlin authored
31
# arguments
32
SRS_PREFIX=/usr/local/srs
winlin authored
33
SRS_JOBS=1
34
SRS_STATIC=RESERVED
winlin authored
35 36 37
# private internal
# dev, open all features for dev, no gperf/prof/arm.
SRS_DEV=NO
winlin authored
38 39
# raspberry-pi, open hls/ssl/static
SRS_PI=NO
40
41 42 43
#####################################################################################
# parse options
#####################################################################################
44 45 46 47 48 49 50
opt=

for option
do
    opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"

    case "$option" in
winlin authored
51
        -*=*) 
52 53
            value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'` 
            option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/]*||'`
winlin authored
54
        ;;
55 56 57 58 59 60 61 62
           *) value="" ;;
    esac

    case "$option" in
        --help)                         help=yes                  ;;
        
        --with-ssl)                     SRS_SSL=YES               ;;
        --with-hls)                     SRS_HLS=YES               ;;
63
        --with-nginx)                   SRS_NGINX=YES             ;;
winlin authored
64
        --with-ffmpeg)                  SRS_FFMPEG=YES            ;;
65
        --with-http-callback)           SRS_HTTP_CALLBACK=YES     ;;
winlin authored
66
        --with-librtmp)                 SRS_LIBRTMP=YES           ;;
67
        --with-bwtc)                    SRS_BWTC=YES              ;;
winlin authored
68 69
        --with-research)                SRS_RESEARCH=YES          ;;
        --with-utest)                   SRS_UTEST=YES             ;;
winlin authored
70
        --with-gperf)                   SRS_GPERF=YES             ;;
71 72 73
        --with-gmc)                     SRS_GPERF_MC=YES          ;;
        --with-gmp)                     SRS_GPERF_MP=YES          ;;
        --with-gcp)                     SRS_GPERF_CP=YES          ;;
winlin authored
74
        --with-gprof)                   SRS_GPROF=YES             ;;
75
        --with-arm-ubuntu12)            SRS_ARM_UBUNTU12=YES      ;;
76 77 78
        
        --without-ssl)                  SRS_SSL=NO                ;;
        --without-hls)                  SRS_HLS=NO                ;;
79
        --without-nginx)                SRS_NGINX=NO              ;;
winlin authored
80
        --without-ffmpeg)               SRS_FFMPEG=NO             ;;
81
        --without-http-callback)        SRS_HTTP_CALLBACK=NO      ;;
winlin authored
82
        --without-librtmp)              SRS_LIBRTMP=NO            ;;
83
        --without-bwtc)                 SRS_BWTC=NO               ;;
winlin authored
84 85
        --without-research)             SRS_RESEARCH=NO           ;;
        --without-utest)                SRS_UTEST=NO              ;;
winlin authored
86
        --without-gperf)                SRS_GPERF=NO              ;;
87 88 89
        --without-gmc)                  SRS_GPERF_MC=NO           ;;
        --without-gmp)                  SRS_GPERF_MP=NO           ;;
        --without-gcp)                  SRS_GPERF_CP=NO           ;;
winlin authored
90
        --without-gprof)                SRS_GPROF=NO              ;;
91
        --without-arm-ubuntu12)         SRS_ARM_UBUNTU12=NO       ;;
winlin authored
92 93
        
        --jobs)                         SRS_JOBS=${value}         ;;
94
        --prefix)                       SRS_PREFIX=${value}       ;;
95
        --static)                       SRS_STATIC=YES            ;;
winlin authored
96
        --dev)                          SRS_DEV=YES               ;;
winlin authored
97
        --pi)                           SRS_PI=YES                ;;
98 99 100 101 102 103 104 105

        *)
            echo "$0: error: invalid option \"$option\""
            exit 1
        ;;
    esac
done
106 107 108 109 110 111
#####################################################################################
# apply the default value when user donot specified.
#####################################################################################
# if arm specified, set some default to disabled.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
    if [ $SRS_HLS = RESERVED ]; then SRS_HLS=NO; fi
112
    if [ $SRS_NGINX = RESERVED ]; then SRS_NGINX=NO; fi
113 114 115 116 117 118 119 120 121 122 123 124 125
    if [ $SRS_SSL = RESERVED ]; then SRS_SSL=NO; fi
    if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=NO; fi
    if [ $SRS_HTTP_CALLBACK = RESERVED ]; then SRS_HTTP_CALLBACK=NO; fi
    if [ $SRS_LIBRTMP = RESERVED ]; then SRS_LIBRTMP=NO; fi
    if [ $SRS_BWTC = RESERVED ]; then SRS_BWTC=NO; fi
    if [ $SRS_RESEARCH = RESERVED ]; then SRS_RESEARCH=NO; fi
    if [ $SRS_UTEST = RESERVED ]; then SRS_UTEST=NO; fi
    if [ $SRS_GPERF = RESERVED ]; then SRS_GPERF=NO; fi
    if [ $SRS_GPERF_MC = RESERVED ]; then SRS_GPERF_MC=NO; fi
    if [ $SRS_GPERF_MP = RESERVED ]; then SRS_GPERF_MP=NO; fi
    if [ $SRS_GPERF_CP = RESERVED ]; then SRS_GPERF_CP=NO; fi
    if [ $SRS_GPROF = RESERVED ]; then SRS_GPROF=NO; fi
    if [ $SRS_ARM_UBUNTU12 = RESERVED ]; then SRS_ARM_UBUNTU12=NO; fi
winlin authored
126
    if [ $SRS_DEV = RESERVED ]; then SRS_DEV=NO; fi
winlin authored
127
    if [ $SRS_PI = RESERVED ]; then SRS_PI=NO; fi
128 129
    # for arm, always set to static link.
    SRS_STATIC=YES
130 131
else
    if [ $SRS_HLS = RESERVED ]; then SRS_HLS=YES; fi
132
    if [ $SRS_NGINX = RESERVED ]; then SRS_NGINX=NO; fi
133
    if [ $SRS_SSL = RESERVED ]; then SRS_SSL=YES; fi
134 135 136
    if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=NO; fi
    if [ $SRS_HTTP_CALLBACK = RESERVED ]; then SRS_HTTP_CALLBACK=NO; fi
    if [ $SRS_LIBRTMP = RESERVED ]; then SRS_LIBRTMP=NO; fi
137 138
    if [ $SRS_BWTC = RESERVED ]; then SRS_BWTC=NO; fi
    if [ $SRS_RESEARCH = RESERVED ]; then SRS_RESEARCH=NO; fi
139
    if [ $SRS_UTEST = RESERVED ]; then SRS_UTEST=NO; fi
140 141 142 143 144 145
    if [ $SRS_GPERF = RESERVED ]; then SRS_GPERF=NO; fi
    if [ $SRS_GPERF_MC = RESERVED ]; then SRS_GPERF_MC=NO; fi
    if [ $SRS_GPERF_MP = RESERVED ]; then SRS_GPERF_MP=NO; fi
    if [ $SRS_GPERF_CP = RESERVED ]; then SRS_GPERF_CP=NO; fi
    if [ $SRS_GPROF = RESERVED ]; then SRS_GPROF=NO; fi
    if [ $SRS_ARM_UBUNTU12 = RESERVED ]; then SRS_ARM_UBUNTU12=NO; fi
146
    if [ $SRS_STATIC = RESERVED ]; then SRS_STATIC=NO; fi
winlin authored
147
    if [ $SRS_DEV = RESERVED ]; then SRS_DEV=NO; fi
winlin authored
148
    if [ $SRS_PI = RESERVED ]; then SRS_PI=NO; fi
winlin authored
149 150 151 152 153 154 155 156 157 158 159 160 161
fi

# if dev specified, open features if possible.
if [ $SRS_DEV = YES ]; then
    SRS_HLS=YES
    SRS_NGINX=YES
    SRS_SSL=YES
    SRS_FFMPEG=YES
    SRS_HTTP_CALLBACK=YES
    SRS_LIBRTMP=YES
    SRS_BWTC=YES
    SRS_RESEARCH=YES
    SRS_UTEST=YES
162 163 164 165 166
    if [ $SRS_GPERF = RESERVED ]; then SRS_GPERF=NO; fi
    if [ $SRS_GPERF_MC = RESERVED ]; then SRS_GPERF_MC=NO; fi
    if [ $SRS_GPERF_MP = RESERVED ]; then SRS_GPERF_MP=NO; fi
    if [ $SRS_GPERF_CP = RESERVED ]; then SRS_GPERF_CP=NO; fi
    if [ $SRS_GPROF = RESERVED ]; then SRS_GPROF=NO; fi
winlin authored
167 168 169
    SRS_ARM_UBUNTU12=NO
    # for arm, always set to static link.
    SRS_STATIC=NO
170 171
fi
winlin authored
172 173 174 175 176 177 178 179 180 181 182
# if raspberry-pi specified, open ssl/hls/static features
if [ $SRS_PI = YES ]; then
    SRS_HLS=YES
    SRS_NGINX=NO
    SRS_SSL=YES
    SRS_FFMPEG=NO
    SRS_HTTP_CALLBACK=NO
    SRS_LIBRTMP=NO
    SRS_BWTC=NO
    SRS_RESEARCH=NO
    SRS_UTEST=NO
183 184 185 186 187
    if [ $SRS_GPERF = RESERVED ]; then SRS_GPERF=NO; fi
    if [ $SRS_GPERF_MC = RESERVED ]; then SRS_GPERF_MC=NO; fi
    if [ $SRS_GPERF_MP = RESERVED ]; then SRS_GPERF_MP=NO; fi
    if [ $SRS_GPERF_CP = RESERVED ]; then SRS_GPERF_CP=NO; fi
    if [ $SRS_GPROF = RESERVED ]; then SRS_GPROF=NO; fi
winlin authored
188 189 190 191 192
    SRS_ARM_UBUNTU12=NO
    # for arm, always set to static link.
    SRS_STATIC=YES
fi
winlin authored
193 194 195 196 197 198 199
# parse the jobs for make
if [[ "" -eq SRS_JOBS ]]; then 
    export SRS_JOBS="--jobs" 
else
    export SRS_JOBS="--jobs=${SRS_JOBS}"
fi
200
# save all config options to macro to write to auto headers file
201 202
SRS_CONFIGURE="$opt"
203 204 205
#####################################################################################
# show help and exit
#####################################################################################
206
if [ $help = yes ]; then
207
    cat << END
208 209 210 211 212

  --help                   print this message

  --with-ssl               enable rtmp complex handshake, requires openssl-devel installed.
                           to delivery h264 video and aac audio to flash player.
winlin authored
213
  --with-hls               enable hls streaming, build nginx as http server for hls.
214
  --with-http-callback     enable http hooks, build cherrypy as demo api server.
215
                           srs will call the http hooks, such as: on_connect.
winlin authored
216
  --with-ffmpeg            enable transcoding with ffmpeg.
winlin authored
217
  --with-librtmp           enable srs-librtmp, library for client.
218
  --with-bwtc              enable srs bandwidth test client tool.
219
  --with-research          build the research tools.
winlin authored
220
  --with-utest             build the utest for srs.
winlin authored
221
  --with-gperf             build srs with gperf tools(no gmc/gmp/gcp, with tcmalloc only).
222
  --with-gmc               build memory check for srs with gperf tools.
223 224
  --with-gmp               build memory profile for srs with gperf tools.
  --with-gcp               build cpu profile for srs with gperf tools.
winlin authored
225
  --with-gprof             build srs with gprof(GNU profile tool).
226
  --with-arm-ubuntu12      build srs on ubuntu12 for armhf(v7cpu).
227 228 229

  --without-ssl            disable rtmp complex handshake.
  --without-hls            disable hls, rtmp streaming only.
230
  --without-http-callback  disable http, http hooks callback.
winlin authored
231
  --without-ffmpeg         disable the ffmpeg transcoding feature.
winlin authored
232
  --without-librtmp        disable srs-librtmp, library for client.
233
  --without-bwtc           disable srs bandwidth test client tool.
234
  --without-research       do not build the research tools.
winlin authored
235
  --without-utest          do not build the utest for srs.
winlin authored
236
  --without-gperf          do not build srs with gperf tools(without tcmalloc and gmc/gmp/gcp).
237
  --without-gmc            do not build memory check for srs with gperf tools.
238 239
  --without-gmp            do not build memory profile for srs with gperf tools.
  --without-gcp            do not build cpu profile for srs with gperf tools.
winlin authored
240
  --without-gprof          do not build srs with gprof(GNU profile tool).
241
  --without-arm-ubuntu12   do not build srs on ubuntu12 for armhf(v7cpu).
winlin authored
242
  
243
  --static                 whether add '-static' to link options. always set this option for arm.
winlin authored
244 245
  --jobs[=N]               Allow N jobs at once; infinite jobs with no arg.
                           used for make in the configure, for example, to make ffmpeg.
winlin authored
246 247
  --prefix=<path>          the absolute install path for srs.
  --dev                    for dev, open all features, no gperf/gprof/arm.
winlin authored
248
  --pi                     for raspberry-pi(directly build), open features hls/ssl/static.
249 250

END
251
    exit 0
252 253
fi
254 255 256
#####################################################################################
# check user options
#####################################################################################
257
__check_ok=YES
winlin authored
258 259
# check conflict
if [ $SRS_GPERF = NO ]; then
260 261 262
    if [ $SRS_GPERF_MC = YES ]; then echo "gperf-mc depends on gperf, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPERF_MP = YES ]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPERF_CP = YES ]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
winlin authored
263
fi
264 265 266 267 268 269 270 271
if [ $SRS_GPERF_MC = YES ]; then
    if [ $SRS_GPERF_MP = YES ]; then
        echo "gperf-mc not compatible with gperf-mp, see: ./configure --help";
        echo "@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html";
        echo "Note that since the heap-checker uses the heap-profiling framework internally, it is not possible to run both the heap-checker and heap profiler at the same time";
        __check_ok=NO
    fi
fi
winlin authored
272 273
# generate the group option: SRS_GPERF
__gperf_slow=NO
274 275 276 277 278 279 280
if [ $SRS_GPERF_MC = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [ $SRS_GPERF_MP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [ $SRS_GPERF_CP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
if [ $__gperf_slow = YES ]; then if [ $SRS_GPROF = YES ]; then 
    echo "gmc/gmp/gcp not compatible with gprof, see: ./configure --help"; __check_ok=NO; 
fi fi
281 282 283 284 285 286 287 288 289 290 291 292 293 294
# check arm, if arm enabled, only allow st/ssl/librtmp,
# user should disable all other features
if [ $SRS_ARM_UBUNTU12 = YES ]; then
    if [ $SRS_FFMPEG = YES ]; then echo "ffmpeg for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_HTTP_CALLBACK = YES ]; then echo "http-callback for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_BWTC = YES ]; then echo "bwtc for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_RESEARCH = YES ]; then echo "research for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPERF = YES ]; then echo "gperf for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPERF_MC = YES ]; then echo "gmc for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPERF_MP = YES ]; then echo "gmp for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPERF_CP = YES ]; then echo "gcp for arm is not available, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_GPROF = YES ]; then echo "gprof for arm is not available, see: ./configure --help"; __check_ok=NO; fi
fi
winlin authored
295
# check variable neccessary
296
if [ $SRS_HLS = RESERVED ]; then echo "you must specifies the hls, see: ./configure --help"; __check_ok=NO; fi
297
if [ $SRS_NGINX = RESERVED ]; then echo "you must specifies the nginx, see: ./configure --help"; __check_ok=NO; fi
298 299
if [ $SRS_SSL = RESERVED ]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_FFMPEG = RESERVED ]; then echo "you must specifies the ffmpeg, see: ./configure --help"; __check_ok=NO; fi
300
if [ $SRS_HTTP_CALLBACK = RESERVED ]; then echo "you must specifies the http, see: ./configure --help"; __check_ok=NO; fi
301 302 303 304 305 306 307 308 309
if [ $SRS_LIBRTMP = RESERVED ]; then echo "you must specifies the librtmp, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_BWTC = RESERVED ]; then echo "you must specifies the bwtc, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_RESEARCH = RESERVED ]; then echo "you must specifies the research, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_UTEST = RESERVED ]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_GPERF = RESERVED ]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_GPERF_MC = RESERVED ]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_GPERF_MP = RESERVED ]; then echo "you must specifies the gperf-mp, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_GPERF_CP = RESERVED ]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi
if [ $SRS_GPROF = RESERVED ]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi
310
if [ $SRS_ARM_UBUNTU12 = RESERVED ]; then echo "you must specifies the arm-ubuntu12, see: ./configure --help"; __check_ok=NO; fi
311
if [[ -z $SRS_PREFIX ]]; then echo "you must specifies the prefix, see: ./configure --prefix"; __check_ok=NO; fi
312 313
if [ $__check_ok = NO ]; then
    exit 1;
314
fi
315 316 317

# regenerate the options for default values.
SRS_CONFIGURE=""
winlin authored
318 319
if [ $SRS_DEV = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --dev"; fi
if [ $SRS_PI = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --pi"; fi
320
if [ $SRS_HLS = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-hls"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-hls"; fi
321
if [ $SRS_NGINX = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-nginx"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-nginx"; fi
322 323
if [ $SRS_SSL = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-ssl"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-ssl"; fi
if [ $SRS_FFMPEG = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-ffmpeg"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-ffmpeg"; fi
324
if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-http-callback"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-http-callback"; fi
325 326 327 328 329 330 331 332 333
if [ $SRS_LIBRTMP = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-librtmp"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-librtmp"; fi
if [ $SRS_BWTC = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-bwtc"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-bwtc"; fi
if [ $SRS_RESEARCH = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-research"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-research"; fi
if [ $SRS_UTEST = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-utest"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-utest"; fi
if [ $SRS_GPERF = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-gperf"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-gperf"; fi
if [ $SRS_GPERF_MC = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-gmc"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-gmc"; fi
if [ $SRS_GPERF_MP = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-gmp"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-gmp"; fi
if [ $SRS_GPERF_CP = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-gcp"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-gcp"; fi
if [ $SRS_GPROF = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-gprof"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-gprof"; fi
334
if [ $SRS_ARM_UBUNTU12 = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-arm-ubuntu12"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-arm-ubuntu12"; fi
335
if [ $SRS_STATIC = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --static"; fi
336
SRS_CONFIGURE="${SRS_CONFIGURE} ${SRS_JOBS} --prefix=${SRS_PREFIX}"
337
echo "regenerate config: ${SRS_CONFIGURE}"