aio: fix aio ssl support
[jimtcl.git] / auto.def
blob4625b63f3b91439e49a232afc1872a16aa2582fe
1 # vim:se syn=tcl:
4 define JIM_VERSION 76
6 # Note: modules which support options *must* be included before 'options'
7 use cc cc-shared cc-db cc-lib
8 use local
10 options {
11 utf8 => "include support for utf8-encoded strings"
12 lineedit=1 => "disable line editing"
13 references=1 => "disable support for references"
14 math => "include support for math functions"
15 ssl => "include ssl/tls support in the aio extension"
16 ipv6 => "include ipv6 support in the aio extension"
17 maintainer => {enable the [debug] command and JimPanic}
18 full => "Enable some optional features: ipv6, ssl, math, utf8, binary, oo, tree"
19 with-jim-shared shared => "build a shared library instead of a static library"
20 jim-regexp=1 => "prefer POSIX regex if over the the built-in (Tcl-compatible) regex"
21 docs=1 => "don't build or install the documentation"
22 docdir:path => "path to install docs (if built)"
23 random-hash => "randomise hash tables. more secure but hash table results are not predicable"
24 with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
25 Specify additional jim extensions to include.
26 These are enabled by default:
28 aio - ANSI I/O, including open and socket
29 eventloop - after, vwait, update
30 array - Tcl-compatible array command
31 clock - Tcl-compatible clock command
32 exec - Tcl-compatible exec command
33 file - Tcl-compatible file command
34 glob - Tcl-compatible glob command
35 history - Tcl access to interactive history
36 readdir - Required for glob
37 package - Package management with the package command
38 load - Load binary extensions at runtime with load or package
39 posix - Posix APIs including os.fork, os.wait, pid
40 regexp - Tcl-compatible regexp, regsub commands
41 signal - Signal handling
42 stdlib - Built-in commands including lassign, lambda, alias
43 syslog - System logging with syslog
44 tclcompat - Tcl compatible read, gets, puts, parray, case, ...
45 namespace - Tcl compatible namespace support
47 These are disabled by default:
49 oo - Jim OO extension
50 tree - OO tree structure, similar to tcllib ::struct::tree
51 binary - Tcl-compatible 'binary' command
52 readline - Interface to libreadline
53 rlprompt - Tcl wrapper around the readline extension
54 mk - Interface to Metakit
55 tclprefix - Support for the tcl::prefix command
56 sqlite3 - Interface to sqlite3
57 win32 - Interface to win32
59 with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
60 Specify jim extensions to exclude.
61 If 'default' is given, the default extensions will not be added.
63 with-jim-extmod: {with-mod:"ext1 ext2 ..."} => {
64 Specify jim extensions to build as separate modules (either C or Tcl).
65 Note that not all extensions can be built as loadable modules.
67 # To help out openocd with automake
68 install-jim=1
71 # Save the user-specified LIBS
72 # We add detected libs to LDLIBS explicitly
73 set LIBS [get-define LIBS]
75 cc-check-types "long long"
77 define CCOPTS ""
78 define CXXOPTS ""
79 if {[cctest -cflags -fno-unwind-tables]} {
80 define-append CCOPTS -fno-unwind-tables
82 if {[cctest -cflags -fno-asynchronous-unwind-tables]} {
83 define-append CCOPTS -fno-asynchronous-unwind-tables
86 cc-check-includes sys/time.h sys/socket.h netinet/in.h arpa/inet.h netdb.h
87 cc-check-includes sys/un.h dlfcn.h unistd.h dirent.h crt_externs.h
89 define LDLIBS ""
91 # Haiku needs -lnetwork, Solaris needs -lnsl
92 if {[cc-check-function-in-lib inet_ntop {nsl network}]} {
93 # This does nothing if no libs are needed
94 cc-with [list -libs [get-define lib_inet_ntop]]
95 define-append LDLIBS [get-define lib_inet_ntop]
97 # Solaris needs -lsocket, Windows needs -lwsock32
98 if {[cc-check-function-in-lib socket socket]} {
99 define-append LDLIBS [get-define lib_socket]
102 cc-check-functions ualarm lstat fork vfork system select execvpe
103 cc-check-functions backtrace geteuid mkstemp realpath strptime isatty
104 cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
105 cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
106 cc-check-functions shutdown socketpair isinf isnan link symlink fsync dup
108 if {[cc-check-functions sysinfo]} {
109 cc-with {-includes sys/sysinfo.h} {
110 cc-check-members "struct sysinfo.uptime"
114 cc-check-lfs
115 cc-check-functions fseeko ftello
117 define TCL_LIBRARY [get-define prefix]/lib/jim
119 lassign [split [get-define host] -] host_cpu host_vendor host_os
120 # Scrub revision from the host_os
121 regsub -all {[0-9.]} $host_os {} host_os
123 switch -glob -- $host_os {
124 mingw* {
125 # We provide our own implementation of dlopen for mingw32
126 define-feature dlopen-compat
127 define-feature winconsole
128 define TCL_PLATFORM_OS $host_os
129 define TCL_PLATFORM_PLATFORM windows
130 define TCL_PLATFORM_PATH_SEPARATOR {;}
132 default {
133 # Note that cygwin is considered a unix platform
134 define TCL_PLATFORM_OS $host_os
135 define TCL_PLATFORM_PLATFORM unix
136 define TCL_PLATFORM_PATH_SEPARATOR :
140 # Find some tools
141 cc-check-tools ar ranlib strip
142 define tclsh [info nameofexecutable]
144 if {![cc-check-functions _NSGetEnviron]} {
145 msg-checking "Checking environ declared in unistd.h..."
146 if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} {
147 define NO_ENVIRON_EXTERN
148 msg-result "yes"
149 } else {
150 msg-result "no"
154 # Windows has a mkdir with no permission arg
155 cc-check-includes sys/types.h sys/stat.h
156 msg-checking "Checking for mkdir with one arg..."
157 if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
158 define HAVE_MKDIR_ONE_ARG
159 msg-result yes
160 } else {
161 msg-result no
164 set extra_objs {}
165 set jimregexp 0
167 if {[opt-bool utf8 full]} {
168 msg-result "Enabling UTF-8"
169 define JIM_UTF8
170 incr jimregexp
171 } else {
172 define JIM_UTF8 0
174 if {[opt-bool maintainer]} {
175 msg-result "Enabling maintainer settings"
176 define JIM_MAINTAINER
178 if {[opt-bool math full]} {
179 msg-result "Enabling math functions"
180 define JIM_MATH_FUNCTIONS
181 cc-check-function-in-lib sin m
182 define-append LDLIBS [get-define lib_sin]
184 if {[opt-bool ipv6 full]} {
185 msg-result "Enabling IPv6"
186 define JIM_IPV6
188 if {[opt-bool ssl full]} {
189 if {[cc-check-includes openssl/ssl.h] && [cc-check-function-in-lib ERR_error_string crypto] && [cc-check-function-in-lib TLSv1_2_method ssl]} {
190 msg-result "Enabling SSL"
191 define JIM_SSL
192 define-append LDLIBS [get-define lib_ERR_error_string] [get-define lib_TLSv1_2_method]
193 } elseif {[opt-bool ssl]} {
194 user-error "SSL support requires OpenSSL"
197 if {[opt-bool lineedit full]} {
198 if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
199 msg-result "Enabling line editing"
200 define USE_LINENOISE
201 lappend extra_objs linenoise.o
204 if {[opt-bool references]} {
205 msg-result "Enabling references"
206 define JIM_REFERENCES
208 if {[opt-bool shared with-jim-shared]} {
209 msg-result "Building shared library"
210 } else {
211 msg-result "Building static library"
212 define JIM_STATICLIB
214 define LIBSOEXT [format [get-define SH_SOEXTVER] [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]]
215 define JIM_INSTALL [opt-bool install-jim]
216 define JIM_DOCS [opt-bool docs]
217 define JIM_RANDOMISE_HASH [opt-bool random-hash]
218 if {[opt-val docdir] ne ""} {
219 define docdir [opt-val docdir]
220 } else {
221 define docdir {${prefix}/docs/jim}
224 # Attributes of the extensions
225 # tcl=Pure Tcl extension
226 # static=Can't be built as a module
227 # optional=Not selected by default
228 # cpp=Is a C++ extension
229 global extdb
230 dict set extdb attrs {
231 aio { static }
232 array {}
233 binary { tcl }
234 clock {}
235 eventloop { static }
236 exec { static }
237 file {}
238 glob { tcl }
239 history {}
240 load { static }
241 mk { cpp optional }
242 namespace { static }
243 nshelper { tcl optional }
244 oo { tcl }
245 pack {}
246 package { static }
247 posix {}
248 readdir {}
249 readline { optional }
250 regexp {}
251 rlprompt { tcl optional }
252 sdl { optional }
253 signal { static }
254 sqlite3 { optional }
255 stdlib { tcl static }
256 syslog {}
257 tclcompat { tcl static }
258 tclprefix {}
259 tree { tcl }
260 win32 { optional }
263 # Additional information about certain extensions
264 # dep=list of extensions which are required for this extension
265 # check=[expr] expression to evaluate to determine if the extension can be used
266 # libdep=list of 'define' symbols for dependent libraries
267 dict set extdb info {
268 binary { dep pack }
269 exec { check {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]} }
270 glob { dep readdir }
271 load { check {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]} libdep lib_dlopen }
272 mk { check {[check-metakit]} libdep lib_mk }
273 namespace { dep nshelper }
274 posix { check {[have-feature waitpid]} }
275 readdir { check {[have-feature opendir]} }
276 readline { check {[cc-check-function-in-lib readline readline]} libdep lib_readline}
277 rlprompt { dep readline }
278 tree { dep oo }
279 sdl { check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]}
280 libdep {lib_SDL_SetVideoMode lib_rectangleRGBA}
282 signal { check {[have-feature sigaction] && [have-feature vfork]} }
283 sqlite3 { check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 }
284 syslog { check {[have-feature syslog]} }
285 tree { dep oo }
286 win32 { check {[have-feature windows]} }
289 # autosetup cc-check-function-in-library can't handle C++ libraries
290 proc check-metakit {} {
291 set found 0
292 msg-checking "Checking for Metakit..."
293 cc-with {-lang c++} {
294 if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} {
295 msg-result ok
296 define lib_mk -lmk4
297 incr found
298 } else {
299 msg-result "not found"
302 return $found
305 # Set up the withinfo array based on what the user selected
306 global withinfo
307 set withinfo(without) [join [opt-val {without-ext with-out-jim-ext}]]
308 set withinfo(ext) [join [opt-val {with-ext with-jim-ext}]]
309 set withinfo(mod) [join [opt-val {with-mod with-jim-extmod}]]
310 set withinfo(nodefault) 0
311 if {$withinfo(without) eq "default"} {
312 set withinfo(without) {}
313 set withinfo(nodefault) 1
316 # Now go check everything - see autosetup/local.tcl
317 array set extinfo [check-extensions]
319 # Now special checks
320 if {[have-feature windows]} {
321 lappend extra_objs jim-win32compat.o
323 if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} {
324 user-error "cygwin/mingw require --shared for dynamic modules"
328 if {[ext-get-status regexp] in {y m}} {
329 if {![have-feature regcomp]} {
330 # No regcomp means we need to use the built-in version
331 incr jimregexp
335 if {$jimregexp || [opt-bool jim-regexp]} {
336 msg-result "Using built-in regexp"
337 define JIM_REGEXP
339 # If the built-in regexp overrides the system regcomp, etc.
340 # jim must be built shared so that the correct symbols are found
341 if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} {
342 user-error "Must use --shared with regexp module and built-in regexp"
346 if {[ext-get-status load] eq "n"} {
347 # If we don't have load, no need to support shared objects
348 define SH_LINKFLAGS ""
351 msg-result "Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
352 if {[llength $extinfo(module-tcl)]} {
353 msg-result "Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
355 if {[llength $extinfo(module-c)]} {
356 msg-result "Jim dynamic extensions: [lsort $extinfo(module-c)]"
359 define STATIC_EXTS [concat $extinfo(static-c) $extinfo(static-tcl)]
360 define C_EXT_OBJS [prefix jim- [suffix .o $extinfo(static-c)]]
361 define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)]
362 define C_EXT_SHOBJS [suffix .so $extinfo(module-c)]
363 define TCL_EXTS [suffix .tcl $extinfo(module-tcl)]
364 define EXTRA_OBJS $extra_objs
366 # Restore the user-specified LIBS
367 define LIBS $LIBS
369 make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
370 make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*}
371 make-template Makefile.in
372 make-template build-jim-ext.in
374 catch {exec chmod +x build-jim-ext}