Blame view

trunk/auto/options.sh 34.2 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
help=no
16 17
################################################################
# feature options
18
SRS_HLS=RESERVED
19
SRS_DVR=RESERVED
20
SRS_NGINX=RESERVED
21
SRS_SSL=RESERVED
22
SRS_FFMPEG_TOOL=RESERVED
23
SRS_TRANSCODE=RESERVED
winlin authored
24
SRS_INGEST=RESERVED
25
SRS_STAT=RESERVED
26
SRS_HTTP_CALLBACK=RESERVED
winlin authored
27
SRS_HTTP_SERVER=RESERVED
winlin authored
28
SRS_HTTP_API=RESERVED
29
SRS_LIBRTMP=RESERVED
30
SRS_RESEARCH=RESERVED
winlin authored
31
SRS_UTEST=RESERVED
32 33 34 35 36 37 38 39 40 41
# tcmalloc
SRS_GPERF=RESERVED
# gperf memory check
SRS_GPERF_MC=RESERVED
# gperf memory profile
SRS_GPERF_MP=RESERVED
# gperf cpu profile
SRS_GPERF_CP=RESERVED
# gprof
SRS_GPROF=RESERVED
42
# 
43
################################################################
44 45 46
# libraries
SRS_FFMPEG_STUB=RESERVED
SRS_HTTP_PARSER=RESERVED
winlin authored
47
# arguments
48
SRS_PREFIX=/usr/local/srs
winlin authored
49
SRS_JOBS=1
50
SRS_STATIC=RESERVED
51 52 53 54 55
# whether enable the log verbose/info/trace level.
# always enable the warn/error level.
SRS_LOG_VERBOSE=RESERVED
SRS_LOG_INFO=RESERVED
SRS_LOG_TRACE=RESERVED
56
#
57
################################################################
58 59 60
# experts
# donot compile ssl, use system ssl(-lssl) if required.
SRS_USE_SYS_SSL=NO
61 62 63 64
# export the srs-librtmp to specified project, NO to disable it.
SRS_EXPORT_LIBRTMP_PROJECT=NO
# export the srs-librtmp to a single .h and .c, NO to disable it.
SRS_EXPORT_LIBRTMP_SINGLE=NO
65
#
66
################################################################
67 68 69 70 71
# presets
# for x86/x64 pc/servers
SRS_X86_X64=NO
# armhf(v7cpu) built on ubuntu12
SRS_ARM_UBUNTU12=NO
winlin authored
72 73
# mips built on ubuntu12
SRS_MIPS_UBUNTU12=NO
winlin authored
74 75
# dev, open all features for dev, no gperf/prof/arm.
SRS_DEV=NO
76
# dev, open main server feature for dev, no utest/research/librtmp
77
SRS_FAST_DEV=NO
78
# demo, for the demo of srs, @see: https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SampleDemo
winlin authored
79
SRS_DEMO=NO
winlin authored
80 81
# raspberry-pi, open hls/ssl/static
SRS_PI=NO
82 83
# cubieboard, donot open ffmpeg/nginx.
SRS_CUBIE=NO
84 85 86 87 88 89
# the most fast compile, nothing, only support vp6 RTMP.
SRS_FAST=NO
# only support RTMP with ssl.
SRS_PURE_RTMP=NO
# only support RTMP+HLS with ssl.
SRS_RTMP_HLS=NO
90 91
# the most fast compile, nothing, only support vp6 RTMP.
SRS_DISABLE_ALL=NO
92 93
# all features is on
SRS_ENABLE_ALL=NO
winlin authored
94
#
95
################################################################
winlin authored
96 97 98
# calc
# whether embed cpu, arm/mips
SRS_EMBEDED_CPU=NO
99
100
#####################################################################################
101
# menu
102
#####################################################################################
103 104
function show_help() {
    cat << END
105
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
Options:
  -h, --help                print this message
                          
  --with-ssl                enable rtmp complex handshake, requires openssl-devel installed.
                            to delivery h264 video and aac audio to flash player.
  --with-hls                enable hls streaming, mux RTMP to m3u8/ts files.
  --with-dvr                enable dvr, mux RTMP to flv files.
  --with-nginx              enable delivery HTTP stream with nginx.
                            build nginx at: ./objs/nginx/sbin/nginx
  --with-http-callback      enable http hooks, build cherrypy as demo api server.
  --with-http-server        enable http server to delivery http stream.
  --with-http-api           enable http api, to manage SRS by http api.
  --with-ffmpeg             enable transcoding tool ffmpeg.
                            build ffmpeg at: ./objs/ffmpeg/bin/ffmpeg
  --with-transcode          enable transcoding features.
                            user must specifies the transcode tools in conf.
  --with-ingest             enable ingest features.
                            user must specifies the ingest tools in conf.
124
  --with-stat               enable the data statistic, for http api.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
  --with-librtmp            enable srs-librtmp, library for client.
  --with-research           build the research tools.
  --with-utest              build the utest for SRS.
  --with-gperf              build SRS with gperf tools(no gmc/gmp/gcp, with tcmalloc only).
  --with-gmc                build memory check for SRS with gperf tools.
  --with-gmp                build memory profile for SRS with gperf tools.
  --with-gcp                build cpu profile for SRS with gperf tools.
  --with-gprof              build SRS with gprof(GNU profile tool).
  --with-arm-ubuntu12       build SRS on ubuntu12 for armhf(v7cpu).
                          
  --without-ssl             disable rtmp complex handshake.
  --without-hls             disable hls, rtmp streaming only.
  --without-dvr             disable dvr, donot support record RTMP stream to flv.
  --without-nginx           disable delivery HTTP stream with nginx.
  --without-http-callback   disable http, http hooks callback.
  --without-http-server     disable http server, use external server to delivery http stream.
  --without-http-api        disable http api, only use console to manage SRS process.
  --without-ffmpeg          disable the ffmpeg transcode tool feature.
  --without-transcode       disable the transcoding feature.
  --without-ingest          disable the ingest feature.
145
  --without-stat            disable the data statistic feature.
146 147 148 149 150 151 152 153 154 155 156
  --without-librtmp         disable srs-librtmp, library for client.
  --without-research        do not build the research tools.
  --without-utest           do not build the utest for SRS.
  --without-gperf           do not build SRS with gperf tools(without tcmalloc and gmc/gmp/gcp).
  --without-gmc             do not build memory check for SRS with gperf tools.
  --without-gmp             do not build memory profile for SRS with gperf tools.
  --without-gcp             do not build cpu profile for SRS with gperf tools.
  --without-gprof           do not build srs with gprof(GNU profile tool).
  --without-arm-ubuntu12    do not build srs on ubuntu12 for armhf(v7cpu).
                          
  --prefix=<path>           the absolute install path for srs.
winlin authored
157
  --static                  whether add '-static' to link options.
158 159
  --jobs[=N]                Allow N jobs at once; infinite jobs with no arg.
                            used for make in the configure, for example, to make ffmpeg.
160 161 162
  --log-verbose             whether enable the log verbose level. default: no.
  --log-info                whether enable the log info level. default: no.
  --log-trace               whether enable the log trace level. default: yes.
163
164
Presets:
165
  --x86-x64                 [default] for x86/x64 cpu, common pc and servers.
166
  --pi                      for raspberry-pi(directly build), open features hls/ssl/static.
167 168 169
  --cubie                   for cubieboard(directly build), open features except ffmpeg/nginx.
  --arm                     alias for --with-arm-ubuntu12, for ubuntu12, arm crossbuild
  --mips                    alias for --with-mips-ubuntu12, for ubuntu12, mips crossbuild
170 171 172
  --fast                    the most fast compile, nothing, only support vp6 RTMP.
  --pure-rtmp               only support RTMP with ssl.
  --rtmp-hls                only support RTMP+HLS with ssl.
173
  --disable-all             disable all features, only support vp6 RTMP.
winlin authored
174
  --dev                     for dev, open all features, no nginx/gperf/gprof/arm.
175
  --fast-dev                for dev fast compile, the RTMP server, without librtmp/utest/research.
176
  --demo                    for srs demo, @see: https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SampleDemo
winlin authored
177
  --full                    enable all features, no gperf/gprof/arm.
178 179
  
Conflicts:
winlin authored
180
  1. --with-gmc vs --with-gmp: 
181
        @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html
winlin authored
182
  2. --with-gperf/gmc/gmp vs --with-gprof:
183
        gperftools not compatible with gprof.
184
  3. --arm vs --with-ffmpeg/gperf/gmc/gmp/gprof:
185 186
        the complex tools not available for arm.
187
Experts:
188 189 190
  --use-sys-ssl                     donot compile ssl, use system ssl(-lssl) if required.
  --export-librtmp-project=<path>   export srs-librtmp to specified project in path.
  --export-librtmp-single=<path>    export srs-librtmp to a single file(.h+.cpp) in path.
191
192 193 194 195 196 197 198 199
Workflow:
  1. apply "Presets". if not specified, use default preset.
  2. apply "Options". user specified option will override the preset.
  3. check conflicts. @see Conflicts section.
  4. generate detail features.

END
}
200
201
function parse_user_option() {
202
    case "$option" in
203
        -h)                             help=yes                    ;;
winlin authored
204
        --help)                         help=yes                    ;;
205
        
winlin authored
206 207
        --with-ssl)                     SRS_SSL=YES                 ;;
        --with-hls)                     SRS_HLS=YES                 ;;
208
        --with-dvr)                     SRS_DVR=YES                 ;;
winlin authored
209
        --with-nginx)                   SRS_NGINX=YES               ;;
210
        --with-ffmpeg)                  SRS_FFMPEG_TOOL=YES         ;;
211
        --with-transcode)               SRS_TRANSCODE=YES           ;;
winlin authored
212
        --with-ingest)                  SRS_INGEST=YES              ;;
213
        --with-stat)                    SRS_STAT=YES                ;;
winlin authored
214 215 216 217 218 219 220 221 222 223 224 225
        --with-http-callback)           SRS_HTTP_CALLBACK=YES       ;;
        --with-http-server)             SRS_HTTP_SERVER=YES         ;;
        --with-http-api)                SRS_HTTP_API=YES            ;;
        --with-librtmp)                 SRS_LIBRTMP=YES             ;;
        --with-research)                SRS_RESEARCH=YES            ;;
        --with-utest)                   SRS_UTEST=YES               ;;
        --with-gperf)                   SRS_GPERF=YES               ;;
        --with-gmc)                     SRS_GPERF_MC=YES            ;;
        --with-gmp)                     SRS_GPERF_MP=YES            ;;
        --with-gcp)                     SRS_GPERF_CP=YES            ;;
        --with-gprof)                   SRS_GPROF=YES               ;;
        --with-arm-ubuntu12)            SRS_ARM_UBUNTU12=YES        ;;
winlin authored
226
        --with-mips-ubuntu12)           SRS_MIPS_UBUNTU12=YES       ;;
winlin authored
227 228 229
                                                                 
        --without-ssl)                  SRS_SSL=NO                  ;;
        --without-hls)                  SRS_HLS=NO                  ;;
230
        --without-dvr)                  SRS_DVR=NO                  ;;
winlin authored
231
        --without-nginx)                SRS_NGINX=NO                ;;
232
        --without-ffmpeg)               SRS_FFMPEG_TOOL=NO          ;;
233
        --without-transcode)            SRS_TRANSCODE=NO            ;;
winlin authored
234
        --without-ingest)               SRS_INGEST=NO               ;;
235
        --without-stat)                 SRS_STAT=NO                 ;;
winlin authored
236 237 238 239 240 241 242 243 244 245 246 247
        --without-http-callback)        SRS_HTTP_CALLBACK=NO        ;;
        --without-http-server)          SRS_HTTP_SERVER=NO          ;;
        --without-http-api)             SRS_HTTP_API=NO             ;;
        --without-librtmp)              SRS_LIBRTMP=NO              ;;
        --without-research)             SRS_RESEARCH=NO             ;;
        --without-utest)                SRS_UTEST=NO                ;;
        --without-gperf)                SRS_GPERF=NO                ;;
        --without-gmc)                  SRS_GPERF_MC=NO             ;;
        --without-gmp)                  SRS_GPERF_MP=NO             ;;
        --without-gcp)                  SRS_GPERF_CP=NO             ;;
        --without-gprof)                SRS_GPROF=NO                ;;
        --without-arm-ubuntu12)         SRS_ARM_UBUNTU12=NO         ;;
winlin authored
248
        --without-mips-ubuntu12)        SRS_MIPS_UBUNTU12=NO        ;;
249
        
winlin authored
250 251 252
        --jobs)                         SRS_JOBS=${value}           ;;
        --prefix)                       SRS_PREFIX=${value}         ;;
        --static)                       SRS_STATIC=YES              ;;
253 254 255
        --log-verbose)                  SRS_LOG_VERBOSE=YES         ;;
        --log-info)                     SRS_LOG_INFO=YES            ;;
        --log-trace)                    SRS_LOG_TRACE=YES           ;;
256
        
257
        --x86-x64)                      SRS_X86_X64=YES             ;;
258
        --arm)                          SRS_ARM_UBUNTU12=YES        ;;
winlin authored
259
        --mips)                         SRS_MIPS_UBUNTU12=YES       ;;
winlin authored
260
        --pi)                           SRS_PI=YES                  ;;
261
        --cubie)                        SRS_CUBIE=YES               ;;
262
        --dev)                          SRS_DEV=YES                 ;;
263
        --fast-dev)                     SRS_FAST_DEV=YES            ;;
winlin authored
264
        --demo)                         SRS_DEMO=YES                ;;
265
        --fast)                         SRS_FAST=YES                ;;
266
        --disable-all)                  SRS_DISABLE_ALL=YES         ;;
267 268
        --pure-rtmp)                    SRS_PURE_RTMP=YES           ;;
        --rtmp-hls)                     SRS_RTMP_HLS=YES            ;;
269
        --full)                         SRS_ENABLE_ALL=YES          ;;
270 271
        
        --use-sys-ssl)                  SRS_USE_SYS_SSL=YES         ;;
272 273
        --export-librtmp-project)       SRS_EXPORT_LIBRTMP_PROJECT=${value}     ;;
        --export-librtmp-single)        SRS_EXPORT_LIBRTMP_SINGLE=${value}      ;;
274 275 276 277 278 279

        *)
            echo "$0: error: invalid option \"$option\""
            exit 1
        ;;
    esac
280
}
281
282 283 284 285
function parse_user_option_to_value_and_option() {
    case "$option" in
        -*=*) 
            value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'` 
niesongsong authored
286
            option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/.]*||'`
287 288 289 290 291
        ;;
           *) value="" ;;
    esac
}
292
#####################################################################################
293
# parse preset options
294
#####################################################################################
295 296 297 298 299
opt=

for option
do
    opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
300
    parse_user_option_to_value_and_option
301 302 303
    parse_user_option
done
304 305 306 307 308 309
if [ $help = yes ]; then
    show_help
    exit 0
fi

function apply_user_presets() {
310 311 312 313 314
    # always set the log level for all presets.
    SRS_LOG_VERBOSE=NO
    SRS_LOG_INFO=NO
    SRS_LOG_TRACE=YES
    
315 316 317 318
    # set default preset if not specifies
    if [ $SRS_RTMP_HLS = NO ]; then
        if [ $SRS_PURE_RTMP = NO ]; then
            if [ $SRS_FAST = NO ]; then
319
                if [ $SRS_DISABLE_ALL = NO ]; then
320 321
                    if [ $SRS_ENABLE_ALL = NO ]; then
                        if [ $SRS_DEV = NO ]; then
322
                            if [ $SRS_FAST_DEV = NO ]; then
winlin authored
323 324 325 326 327 328
                                if [ $SRS_DEMO = NO ]; then
                                    if [ $SRS_ARM_UBUNTU12 = NO ]; then
                                        if [ $SRS_MIPS_UBUNTU12 = NO ]; then
                                            if [ $SRS_PI = NO ]; then
                                                if [ $SRS_CUBIE = NO ]; then
                                                    if [ $SRS_X86_X64 = NO ]; then
329
														SRS_X86_X64=YES; opt="--x86-x64 $opt";
winlin authored
330
                                                    fi
331
                                                fi
332
                                            fi
333
                                        fi
winlin authored
334
                                    fi
335
                                fi
336 337 338 339
                            fi
                        fi
                    fi
                fi
340 341 342
            fi
        fi
    fi
winlin authored
343 344 345 346 347 348 349 350
    
    # whether embeded cpu.
    if [ $SRS_ARM_UBUNTU12 = YES ]; then
        SRS_EMBEDED_CPU=YES
    fi
    if [ $SRS_MIPS_UBUNTU12 = YES ]; then
        SRS_EMBEDED_CPU=YES
    fi
winlin authored
351
352
    # all disabled.
353 354 355 356 357 358 359 360
    if [ $SRS_DISABLE_ALL = YES ]; then
        SRS_HLS=NO
        SRS_DVR=NO
        SRS_NGINX=NO
        SRS_SSL=NO
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=NO
        SRS_INGEST=NO
361
        SRS_STAT=NO
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
        SRS_HTTP_PARSER=NO
        SRS_HTTP_CALLBACK=NO
        SRS_HTTP_SERVER=NO
        SRS_HTTP_API=NO
        SRS_LIBRTMP=NO
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
377 378 379 380 381 382 383 384 385
    # all enabled.
    if [ $SRS_ENABLE_ALL = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=YES
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=YES
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
386
        SRS_STAT=YES
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=YES
        SRS_RESEARCH=YES
        SRS_UTEST=YES
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
402
    # only rtmp vp6
403 404 405 406 407 408 409 410
    if [ $SRS_FAST = YES ]; then
        SRS_HLS=NO
        SRS_DVR=NO
        SRS_NGINX=NO
        SRS_SSL=NO
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=NO
        SRS_INGEST=NO
411
        SRS_STAT=NO
412 413 414 415 416 417 418 419 420 421 422 423 424 425
        SRS_HTTP_PARSER=NO
        SRS_HTTP_CALLBACK=NO
        SRS_HTTP_SERVER=NO
        SRS_HTTP_API=NO
        SRS_LIBRTMP=NO
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
426
427 428 429 430 431 432 433 434 435
    # all disabled.
    if [ $SRS_RTMP_HLS = YES ]; then
        SRS_HLS=YES
        SRS_DVR=NO
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=NO
        SRS_INGEST=NO
436
        SRS_STAT=NO
437 438 439 440 441 442 443 444 445 446 447 448 449 450
        SRS_HTTP_PARSER=NO
        SRS_HTTP_CALLBACK=NO
        SRS_HTTP_SERVER=NO
        SRS_HTTP_API=NO
        SRS_LIBRTMP=NO
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
winlin authored
451
452 453 454 455 456 457 458 459 460
    # only ssl for RTMP with complex handshake.
    if [ $SRS_PURE_RTMP = YES ]; then
        SRS_HLS=NO
        SRS_DVR=NO
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=NO
        SRS_INGEST=NO
461
        SRS_STAT=NO
462 463 464 465 466 467 468 469 470 471 472 473 474 475
        SRS_HTTP_PARSER=NO
        SRS_HTTP_CALLBACK=NO
        SRS_HTTP_SERVER=NO
        SRS_HTTP_API=NO
        SRS_LIBRTMP=NO
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
476
477 478 479 480 481 482 483 484 485
    # if arm specified, set some default to disabled.
    if [ $SRS_ARM_UBUNTU12 = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
486
        SRS_STAT=YES
487 488 489 490
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
491
        SRS_LIBRTMP=YES
492 493 494 495 496 497 498
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
winlin authored
499
        # TODO: FIXME: need static? maybe donot.
500 501 502
        SRS_STATIC=YES
    fi
winlin authored
503 504 505 506 507 508 509 510 511
    # if mips specified, set some default to disabled.
    if [ $SRS_MIPS_UBUNTU12 = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
512
        SRS_STAT=YES
winlin authored
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=YES
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
528 529 530 531 532 533 534 535 536
    # defaults for x86/x64
    if [ $SRS_X86_X64 = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
537
        SRS_STAT=YES
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=YES
        SRS_RESEARCH=NO
        SRS_UTEST=YES
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi

    # if dev specified, open features if possible.
    if [ $SRS_DEV = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=YES
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
562
        SRS_STAT=YES
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=YES
        SRS_RESEARCH=YES
        SRS_UTEST=YES
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
578 579 580 581 582 583 584 585 586
    # if fast dev specified, open main server features.
    if [ $SRS_FAST_DEV = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
587
        SRS_STAT=YES
588 589 590 591 592 593 594 595 596 597 598 599 600 601
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=NO
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
602
	
winlin authored
603 604 605 606 607 608 609 610 611
    # for srs demo
    if [ $SRS_DEMO = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=YES
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
612
        SRS_STAT=YES
winlin authored
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=YES
        SRS_RESEARCH=NO
        SRS_UTEST=YES
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
628 629 630 631 632 633 634 635 636
    # if raspberry-pi specified, open ssl/hls/static features
    if [ $SRS_PI = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
637
        SRS_STAT=YES
638 639 640 641
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
642
        SRS_LIBRTMP=YES
643 644 645 646 647 648 649
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
650
        SRS_STATIC=NO
651
    fi
652 653 654 655 656 657 658 659 660 661

    # if cubieboard specified, open features except ffmpeg/nginx.
    if [ $SRS_CUBIE = YES ]; then
        SRS_HLS=YES
        SRS_DVR=YES
        SRS_NGINX=NO
        SRS_SSL=YES
        SRS_FFMPEG_TOOL=YES
        SRS_TRANSCODE=YES
        SRS_INGEST=YES
662
        SRS_STAT=YES
663 664 665 666 667 668 669 670 671 672 673 674 675 676
        SRS_HTTP_PARSER=YES
        SRS_HTTP_CALLBACK=YES
        SRS_HTTP_SERVER=YES
        SRS_HTTP_API=YES
        SRS_LIBRTMP=YES
        SRS_RESEARCH=NO
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
677 678
}
apply_user_presets
winlin authored
679
680 681 682 683 684
#####################################################################################
# parse detail feature options
#####################################################################################
for option
do
685
    parse_user_option_to_value_and_option
686 687 688
    parse_user_option
done
689 690 691 692 693
function apply_user_detail_options() {
    # if transcode/ingest specified, requires the ffmpeg stub classes.
    SRS_FFMPEG_STUB=NO
    if [ $SRS_TRANSCODE = YES ]; then SRS_FFMPEG_STUB=YES; fi
    if [ $SRS_INGEST = YES ]; then SRS_FFMPEG_STUB=YES; fi
694
695 696 697 698 699
    # if http-xxxx specified, open the SRS_HTTP_PARSER
    SRS_HTTP_PARSER=NO
    if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_PARSER=YES; fi
    if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi
    if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi
winlin authored
700
701 702 703 704 705 706
    # parse the jobs for make
    if [[ "" -eq SRS_JOBS ]]; then 
        export SRS_JOBS="--jobs=1" 
    else
        export SRS_JOBS="--jobs=${SRS_JOBS}"
    fi
707
    
708 709 710 711 712
    # if specified export single file, export project first.
    if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
        SRS_EXPORT_LIBRTMP_PROJECT=$SRS_EXPORT_LIBRTMP_SINGLE
    fi
    
713
    # disable almost all features for export srs-librtmp.
714
    if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
        SRS_HLS=NO
        SRS_DVR=NO
        SRS_NGINX=NO
        SRS_SSL=NO
        SRS_FFMPEG_TOOL=NO
        SRS_TRANSCODE=NO
        SRS_INGEST=NO
        SRS_STAT=NO
        SRS_HTTP_PARSER=NO
        SRS_HTTP_CALLBACK=NO
        SRS_HTTP_SERVER=NO
        SRS_HTTP_API=NO
        SRS_LIBRTMP=YES
        SRS_RESEARCH=YES
        SRS_UTEST=NO
        SRS_GPERF=NO
        SRS_GPERF_MC=NO
        SRS_GPERF_MP=NO
        SRS_GPERF_CP=NO
        SRS_GPROF=NO
        SRS_STATIC=NO
    fi
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
}
apply_user_detail_options

function regenerate_options() {
    # save all config options to macro to write to auto headers file
    SRS_AUTO_USER_CONFIGURE="$opt"
    # regenerate the options for default values.
    SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}"
    if [ $SRS_HLS = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-hls"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-hls"; fi
    if [ $SRS_DVR = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-dvr"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-dvr"; fi
    if [ $SRS_NGINX = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-nginx"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-nginx"; fi
    if [ $SRS_SSL = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-ssl"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-ssl"; fi
    if [ $SRS_FFMPEG_TOOL = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-ffmpeg"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-ffmpeg"; fi
    if [ $SRS_TRANSCODE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-transcode"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-transcode"; fi
    if [ $SRS_INGEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-ingest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-ingest"; fi
752
    if [ $SRS_STAT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-stat"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-stat"; fi
753 754 755 756 757 758 759 760 761 762 763 764
    if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-http-callback"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-http-callback"; fi
    if [ $SRS_HTTP_SERVER = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-http-server"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-http-server"; fi
    if [ $SRS_HTTP_API = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-http-api"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-http-api"; fi
    if [ $SRS_LIBRTMP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-librtmp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-librtmp"; fi
    if [ $SRS_RESEARCH = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-research"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-research"; fi
    if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi
    if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi
    if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi
    if [ $SRS_GPERF_MP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmp"; fi
    if [ $SRS_GPERF_CP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gcp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gcp"; fi
    if [ $SRS_GPROF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gprof"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gprof"; fi
    if [ $SRS_ARM_UBUNTU12 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-arm-ubuntu12"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-arm-ubuntu12"; fi
winlin authored
765
    if [ $SRS_MIPS_UBUNTU12 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-mips-ubuntu12"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-mips-ubuntu12"; fi
766
    if [ $SRS_STATIC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --static"; fi
767 768 769
    if [ $SRS_LOG_VERBOSE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-verbose"; fi
    if [ $SRS_LOG_INFO = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info"; fi
    if [ $SRS_LOG_TRACE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace"; fi
770 771 772
    echo "regenerate config: ${SRS_AUTO_CONFIGURE}"
}
regenerate_options
773
774 775 776
#####################################################################################
# check user options
#####################################################################################
777 778 779 780 781 782 783
function check_option_conflicts() {
    __check_ok=YES
    # check conflict
    if [ $SRS_GPERF = NO ]; then
        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
784
    fi
785 786 787 788 789 790
    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
791
        fi
792
    fi
793 794 795 796 797 798 799 800
    # generate the group option: SRS_GPERF
    __gperf_slow=NO
    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
801
winlin authored
802
    # check embeded(arm/mips), if embeded enabled, only allow st/ssl/librtmp,
803
    # user should disable all other features
winlin authored
804
    if [ $SRS_EMBEDED_CPU = YES ]; then
805 806 807 808 809 810 811 812 813 814
        if [ $SRS_FFMPEG_TOOL = YES ]; then echo "ffmpeg 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

    # if x86/x64 or directly build, never use static
winlin authored
815 816 817
    if [ $SRS_X86_X64 = YES ]; then
        if [ $SRS_STATIC = YES ]; then
            echo "x86/x64 should never use static, see: ./configure --help"; __check_ok=NO;
818 819
        fi
    fi
820 821
    
    # TODO: FIXME: check more os.
822
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
    # check variable neccessary
    if [ $SRS_HLS = RESERVED ]; then echo "you must specifies the hls, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_DVR = RESERVED ]; then echo "you must specifies the dvr, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_NGINX = RESERVED ]; then echo "you must specifies the nginx, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_SSL = RESERVED ]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_FFMPEG_TOOL = RESERVED ]; then echo "you must specifies the ffmpeg, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_HTTP_CALLBACK = RESERVED ]; then echo "you must specifies the http-callback, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_HTTP_SERVER = RESERVED ]; then echo "you must specifies the http-server, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_HTTP_API = RESERVED ]; then echo "you must specifies the http-api, see: ./configure --help"; __check_ok=NO; fi
    if [ $SRS_LIBRTMP = RESERVED ]; then echo "you must specifies the librtmp, 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
    if [ $SRS_ARM_UBUNTU12 = RESERVED ]; then echo "you must specifies the arm-ubuntu12, see: ./configure --help"; __check_ok=NO; fi
winlin authored
841
    if [ $SRS_MIPS_UBUNTU12 = RESERVED ]; then echo "you must specifies the mips-ubuntu12, see: ./configure --help"; __check_ok=NO; fi
842 843 844 845 846 847
    if [[ -z $SRS_PREFIX ]]; then echo "you must specifies the prefix, see: ./configure --prefix"; __check_ok=NO; fi
    if [ $__check_ok = NO ]; then
        exit 1;
    fi
}
check_option_conflicts