-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·265 lines (239 loc) · 8.49 KB
/
configure
File metadata and controls
executable file
·265 lines (239 loc) · 8.49 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/sh
# configure:
# Makefile configuration script for Scid.
#
# This program tries to determine system-specific details needed
# for compiling Scid (such as the version of Tcl/Tk you have
# installed, and where to find the Tcl/Tk header and library
# files), and creates the file "Makefile".
# Execute this script using tclsh
# The backslash at the end of this line is needed: \
exec tclsh "$0" ${1+"$@"}
# Default values for Makefile settings:
#
set var(BINDIR) /usr/local/bin
set var(COMPILE) g++
set var(DEBUG) {-DNDEBUG}
set var(OBJS) {$(SCIDOBJS)}
set var(THREADS) {-pthread}
set var(OPTIMIZE) {-std=c++20 -O3 -fno-rtti -fno-exceptions}
set var(PROFILE) {}
set var(SCIDFLAGS) {}
set var(SHAREDIR) /usr/local/share/scid
set var(TCL_VERSION) [info tclversion]
set var(WARNINGS) "-Wall -Wno-deprecated-declarations"
set var(MAKEFILE) Makefile.conf
set var(INSTALL) {install_scid install_engines}
set var(LIBS) {}
set defaultVar(TCL_INCLUDE) {/usr/include}
# findDir:
# Returns the first directory in the list "path" that contains a
# readable file matching the wildcard pattern "f".
# If exp is provided, the directory of the first such file that also
# has a line containing the regular expression "exp" is returned. If
# none of the found files contains the expression, the first file
# found is returned.
#
proc findDir {f path {exp ""}} {
# Expand the path list to include immediate subdirectories.
set subpath {}
foreach d $path {
lappend subpath $d {*}[glob -nocomplain -type {d r} -directory $d *]
}
set best ""
foreach dir $subpath {
set p [file join $dir $f]
if {[llength [glob -nocomplain $p]] > 0} {
if {$best == ""} { set best $p }
if {$exp != ""} {
if {[catch {exec grep -c $exp $p}] == 0} { return $dir } else {
# puts "$p skipped, not right version"
}
} else {
return $dir
}
}
}
return $best
}
# findTclTkPaths:
# Finds all details of the Tcl/Tk installation.
# Returns 1 on success, 0 on failure.
#
proc findTclTkPaths {} {
# headerPath: List of possible locations for tcl.h
set headerPath {
/usr/local/include
/usr/include
/usr/local/tcl/include
/usr/X11/include
/usr/X11R6/include
/usr/local/X11/include
/opt/tcltk/include
/usr/X11R/include
}
# libraryPath: List of possible locations of Tcl/Tk library.
set libraryPath {
/usr/lib
/usr/lib64
/usr/local/tcl/lib
/usr/local/lib
/usr/X11R6/lib
/opt/tcltk/lib
}
# Use meta variables from the current Tcl interpreter
# in case the user has a non-standard Tcl/Tk library location:
set metaPath {}
foreach e $::auto_path {
if {"native" ni [file system $e]} continue
lappend metaPath [file dirname [file normalize $e]]
}
set headerPath [linsert $headerPath 0 {*}$metaPath]
set libraryPath [linsert $libraryPath 0 {*}$metaPath]
global var
set success 1
set tclv $var(TCL_VERSION)
if {! [info exists var(TCL_INCLUDE)] && ! [info exists var(TCL_LIBRARY)]} {
set fw_path [findDir "Tcl.framework" $libraryPath]
if {$fw_path ne ""} {
set var(TCL_INCLUDE) "-F$fw_path/Tcl.framework"
set var(TCL_LIBRARY) {-framework Tcl}
puts " Location of Tcl/Tk frameworks: $fw_path"
return 1
}
}
if {! [info exists var(TCL_INCLUDE)]} {
puts -nonewline { Location of "tcl.h": }
set tcl_h [findDir "tcl.h" $headerPath "TCL_VERSION.*$tclv"]
if {$tcl_h == ""} {
set var(TCL_INCLUDE) ""
puts "not found"
puts "headerPath: $headerPath"
set success 0
} else {
set var(TCL_INCLUDE) "-I$tcl_h"
puts $tcl_h
}
}
if {! [info exists var(TCL_LIBRARY)]} {
puts -nonewline " Location of Tcl $tclv library: "
set tcl_lib [findDir "libtcl${tclv}.*" $libraryPath]
if {$tcl_lib == ""} {
set tclv [expr round($tclv * 10)]
set tcl_lib [findDir "libtcl${tclv}.*" $libraryPath]
if {$tcl_lib == ""} {
set tcl_lib [findDir "tcl${tclv}.*" $libraryPath]
}
}
if {$tcl_lib == ""} {
set var(TCL_LIBRARY) ""
puts "not found"
puts "libraryPath: $libraryPath"
set success 0
} else {
set var(TCL_LIBRARY) "-L$tcl_lib -ltcl${tclv}"
puts $tcl_lib
}
}
return $success
}
# writeMakefile:
# Creates the Makefile using Makefile.conf and the configured
# settings.
# Also creates tcl/config.tcl
#
proc writeMakefile {} {
global var
set success [findTclTkPaths]
if {[catch {set from [open $var(MAKEFILE) r]}]} {
puts "Error opening file for reading: $var(MAKEFILE)"
exit 1
}
puts " Using $var(MAKEFILE)."
if {[catch {set to [open "Makefile" w]}]} {
puts "Error opening file for writing: Makefile"
exit 1
}
set line [gets $from]
while {1} {
set line [gets $from]
if {[eof $from]} { break }
foreach sub [array names var] {
set first [string first "@$sub@" $line]
if {$first >= 0} {
set last [expr $first + [string length $sub] + 1]
set pre [string range $line 0 [expr $first - 1]]
set post [string range $line [expr $last + 1] end]
set line $pre
append line $var($sub)
append line $post
}
}
if {[string compare "!" [string index $line 0]]} {
puts $to $line
}
}
close $from
close $to
# Summary info
if {$success} {
puts {The Makefile configured for your system was written.}
puts {Now just type "make" to compile Scid.}
} else {
puts {Not all settings could be determined!}
puts {You may need to edit it before you can compile Scid.}
}
}
# usage:
# Explains the usage of this script, then exits
#
proc usage {} {
puts {Valid options are:}
puts { BINDIR The location for scid executables for "make install".}
puts { COMPILE Your C++ compiler. Default: "g++".}
puts { DEBUG Debugging flags. Defaut: "-DNDEBUG"}
puts { LANGUAGES Multi-language support. Use LANGUAGES="" for English only.}
puts { LINK Your C++ linker. Default: "g++".}
puts { LIBS Extra libraries to link with (e.g. -lz).}
puts { OPTIMIZE C++ optimizations. Default: "-O3 -fno-rtti -fno-exceptions".}
puts { PROFILE Used for profiling the source code. Default: none.}
puts { SCIDFLAGS Scid customization flags. Default: none.}
puts { SHAREDIR Location of Scid data (ECO, spelling) files for "make install".}
puts { TCL_INCLUDE Compiler directives for including Tcl.}
puts { TCL_LIBRARY Compiler directives for linking Tcl.}
puts { TCL_VERSION Your Tcl/Tk version. Example: TCL_VERSION="8.3".}
puts { THREADS Flags for c++11 threads. Default: "-pthread".}
puts { WARNINGS C++ compiler warnings. Default: "-Wall".}
puts { MAKEFILE Makefile configuration file. Default: "Makefile.conf".}
puts {}
puts { This configure program should find the proper values for the options}
puts { starting with TCL_ and TK_ automatically, so you should only use those}
puts { options if it fails to find your Tcl/Tk installation.}
puts {}
puts {Example usage:}
puts { ./configure LANGUAGES="tcl/francais.tcl" BINDIR="/usr/local/bin"}
puts {}
exit 1
}
########################################
puts "configure: Makefile configuration program for Scid"
# Parse command-line arguments:
foreach arg $argv {
set temp_idx [string first "=" $arg]
if {$temp_idx > 0} {
set temp_var [string range $arg 0 [expr $temp_idx - 1]]
set temp_value [string range $arg [expr $temp_idx + 1] end]
set var($temp_var) $temp_value
} else {
puts "Invalid argument: $arg"
usage
}
}
if {![info exists var(LINK)]} { set var(LINK) "$var(COMPILE)" }
if {[file readable "Makefile"]} {
puts { Renaming "Makefile" to "Makefile.bak"}
catch {file rename -force "Makefile" "Makefile.bak"}
}
puts " Tcl/Tk version: $var(TCL_VERSION)"
puts " Your operating system is: $tcl_platform(os) $tcl_platform(osVersion)"
writeMakefile