forked from Haivision/srt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·207 lines (168 loc) · 4.64 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/tclsh
#
# SRT - Secure, Reliable, Transport
# Copyright (c) 2017 Haivision Systems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; If not, see <http://www.gnu.org/licenses/>
#
# This is a general-purpose configure script, which is a user-friendly
# wrapper to call the cmake. Note that --help shows you only the options
# that are explicitly defined, but which exactly options are really
# supported, depends on what is defined in CMakeLists.txt. Just every
# case of --long-option is changed into LONG_OPTION cmake variable.
# However some of options MENTIONED IN THE HELP TEXT may be handled
# by the configure script before passing to cmake (and maybe turned
# into something else).
#
# The build-specific option processing is done in configure-data.tcl file.
#
# The idea is that CMakeLists.txt contains things that are highly
# customizable, but no system or option autodetection AWA "sensible
# defaults" are provided. This is done by this script.
set here [file dirname $argv0]
set options ""
set toolchain_changers ""
source $here/configure-data.tcl
# Update alias with default alias
dict set alias --prefix --cmake-install-prefix=
proc resolve opt {
set type arg
set pos [string first $opt =]
if { $pos == -1 } {
set type bool
set mark ""
} else {
set type arg
set mark [string range $opt $pos+1 end]
set opt [string range $opt 0 $pos-1]
}
set var [string toupper [string map {- _ + x} $opt]]
return [list --$opt $var $type $mark]
}
foreach {o desc} $options {
lassign [resolve $o] optname optvar opttype optmark
set opt($optname) [list $optvar $opttype $optmark]
set info($optname) $desc
}
if { $argv == "--help" } {
puts stderr "Usage: ./configure \[options\]"
puts stderr "OPTIONS:"
foreach o [lsort [array names opt]] {
lassign $opt($o) unu type mark
set imark ""
if { $mark != "" } {
set imark "=$mark"
}
puts stderr "\t$o$imark - $info($o)"
}
exit 1
}
if { [info proc init] != "" } {
init
}
#parray opt
set saveopt ""
set optkeys ""
set dryrun 0
set type ""
foreach a $argv {
if { [info exists val] } { unset val }
if { $saveopt != "" } {
set optval($saveopt) $a
set saveopt ""
continue
}
if { [string range $a 0 1] != "--" } {
error "Unexpected argument '$a'. Options must start with --"
}
if { $a == "--dryrun" } {
set dryrun 1
continue
}
set type ""
if { [string first = $a] != -1 } {
lassign [split $a =] a val
}
if { [dict exists $::alias $a] } {
set aname [dict get $::alias $a]
if { [string first = $aname] != -1 } {
lassign [split $aname =] a aval
set type arg
}
}
if { ![info exists opt($a)] } {
#puts stderr "WARNING: Unknown option: $a"
# But still, simply turn the option to assign-based use.
lassign [resolve [string range $a 2 end]] oname var
if { ![info exists val] && $type == "" } {
set type bool
}
} else {
lassign $opt($a) var type
}
if { $type == "bool" } {
if { ![info exists val] } {
set val 1
}
set optval($a) $val
} elseif { [info exists val] } {
set optval($a) $val
} else {
set saveopt $a
}
lappend optkeys $a
}
if { $saveopt != "" } {
error "Extra unhandled argument: $saveopt"
}
set cmakeopt ""
if { [info proc preprocess] != "" } {
preprocess
}
# Check if there were new values added not added to optkeys
foreach a [array names optval] {
if { $a ni $optkeys } {
lappend optkeys $a
}
}
foreach a $optkeys {
if { ![info exists optval($a)] } {
continue ;# user action might have removed it.
}
if { ![info exists opt($a)] } {
#puts stderr "WARNING: Unknown option: $a"
# But still, simply turn the option to assign-based use.
lassign [resolve [string range $a 2 end]] oname var
if { ![info exists val] && $type == "" } {
set type bool
}
} else {
lassign $opt($a) var type
}
set val $optval($a)
lappend cmakeopt "-D$var=$val"
}
if { [info proc postprocess] != "" } {
postprocess
}
#puts "VARSPEC: $cmakeopt"
set cmd [list cmake $here {*}$cmakeopt]
puts "Running: $cmd"
if { !$dryrun} {
if { [catch {exec 2>@stderr >@stdout {*}$cmd} result] } {
puts "CONFIGURE: cmake reported error: $result"
}
} else {
puts "(not really - dry run)"
}