Add basic support for [format %b]
[jimtcl.git] / auto.def
blob556361a41e60f9d46a46b8513c12f61492f3adcf
1 # vim:se syn=tcl:
4 define JIM_VERSION 75
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 ipv6 => "include ipv6 support in the aio extension"
16 maintainer => {enable the [debug] command and JimPanic}
17 full => "Enable some optional features: ipv6, math, utf8, binary, oo, tree"
18 with-jim-shared shared => "build a shared library instead of a static library"
19 jim-regexp=1 => "prefer POSIX regex if over the the built-in (Tcl-compatible) regex"
20 docs=1 => "don't build or install the documentation"
21 with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
22 Specify additional jim extensions to include.
23 These are enabled by default:
25 aio - ANSI I/O, including open and socket
26 eventloop - after, vwait, update
27 array - Tcl-compatible array command
28 clock - Tcl-compatible clock command
29 exec - Tcl-compatible exec command
30 file - Tcl-compatible file command
31 glob - Tcl-compatible glob command
32 history - Tcl access to interactive history
33 readdir - Required for glob
34 package - Package management with the package command
35 load - Load binary extensions at runtime with load or package
36 posix - Posix APIs including os.fork, os.wait, pid
37 regexp - Tcl-compatible regexp, regsub commands
38 signal - Signal handling
39 stdlib - Built-in commands including lassign, lambda, alias
40 syslog - System logging with syslog
41 tclcompat - Tcl compatible read, gets, puts, parray, case, ...
42 namespace - Tcl compatible namespace support
44 These are disabled by default:
46 oo - Jim OO extension
47 tree - OO tree structure, similar to tcllib ::struct::tree
48 binary - Tcl-compatible 'binary' command
49 readline - Interface to libreadline
50 rlprompt - Tcl wrapper around the readline extension
51 mk - Interface to Metakit
52 tclprefix - Support for the tcl::prefix command
53 sqlite3 - Interface to sqlite3
54 win32 - Interface to win32
56 with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
57 Specify jim extensions to exclude.
58 If 'default' is given, the default extensions will not be added.
60 with-jim-extmod: {with-mod:"ext1 ext2 ..."} => {
61 Specify jim extensions to build as separate modules (either C or Tcl).
62 Note that not all extensions can be built as loadable modules.
64 # To help out openocd with automake
65 install-jim=1
68 cc-check-types "long long"
70 cc-check-includes sys/time.h sys/socket.h netinet/in.h arpa/inet.h netdb.h
71 cc-check-includes sys/un.h dlfcn.h unistd.h dirent.h crt_externs.h
73 define LDLIBS ""
75 # Haiku needs -lnetwork, Solaris needs -lnsl
76 if {[cc-check-function-in-lib inet_ntop {nsl network}]} {
77 # This does nothing if no libs are needed
78 cc-with [list -libs [get-define lib_inet_ntop]]
79 define-append LDLIBS [get-define lib_inet_ntop]
81 # Solaris needs -lsocket, Windows needs -lwsock32
82 if {[cc-check-function-in-lib socket socket]} {
83 define-append LDLIBS [get-define lib_socket]
86 cc-check-functions ualarm lstat fork vfork system select execvpe
87 cc-check-functions backtrace geteuid mkstemp realpath strptime isatty
88 cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
89 cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
90 if {[cc-check-functions sysinfo]} {
91 cc-with {-includes sys/sysinfo.h} {
92 cc-check-members "struct sysinfo.uptime"
96 cc-check-lfs
97 cc-check-functions fseeko ftello
99 define TCL_LIBRARY [get-define prefix]/lib/jim
101 lassign [split [get-define host] -] host_cpu host_vendor host_os
102 # Scrub revision from the host_os
103 regsub -all {[0-9.]} $host_os {} host_os
105 switch -glob -- $host_os {
106 mingw* {
107 # We provide our own implementation of dlopen for mingw32
108 define-feature dlopen-compat
109 define-feature winconsole
110 define TCL_PLATFORM_OS $host_os
111 define TCL_PLATFORM_PLATFORM windows
112 define TCL_PLATFORM_PATH_SEPARATOR {;}
114 default {
115 # Note that cygwin is considered a unix platform
116 define TCL_PLATFORM_OS $host_os
117 define TCL_PLATFORM_PLATFORM unix
118 define TCL_PLATFORM_PATH_SEPARATOR :
122 # Find some tools
123 cc-check-tools ar ranlib strip
124 define tclsh [info nameofexecutable]
126 if {![cc-check-functions _NSGetEnviron]} {
127 msg-checking "Checking environ declared in unistd.h..."
128 if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} {
129 define NO_ENVIRON_EXTERN
130 msg-result "yes"
131 } else {
132 msg-result "no"
136 # Windows has a mkdir with no permission arg
137 cc-check-includes sys/types.h sys/stat.h
138 msg-checking "Checking for mkdir with one arg..."
139 if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
140 define HAVE_MKDIR_ONE_ARG
141 msg-result yes
142 } else {
143 msg-result no
146 set extra_objs {}
147 set jimregexp 0
149 if {[opt-bool utf8 full]} {
150 msg-result "Enabling UTF-8"
151 define JIM_UTF8
152 incr jimregexp
153 } else {
154 define JIM_UTF8 0
156 if {[opt-bool maintainer]} {
157 msg-result "Enabling maintainer settings"
158 define JIM_MAINTAINER
160 if {[opt-bool math full]} {
161 msg-result "Enabling math functions"
162 define JIM_MATH_FUNCTIONS
163 cc-check-function-in-lib sin m
164 define-append LDLIBS [get-define lib_sin]
166 if {[opt-bool ipv6 full]} {
167 msg-result "Enabling IPv6"
168 define JIM_IPV6
170 if {[opt-bool lineedit full]} {
171 if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
172 msg-result "Enabling line editing"
173 define USE_LINENOISE
174 lappend extra_objs linenoise.o
177 if {[opt-bool references]} {
178 msg-result "Enabling references"
179 define JIM_REFERENCES
181 if {[opt-bool shared with-jim-shared]} {
182 msg-result "Building shared library"
183 } else {
184 msg-result "Building static library"
185 define JIM_STATICLIB
187 define LIBSOEXT [format [get-define SH_SOEXTVER] [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]]
188 define JIM_INSTALL [opt-bool install-jim]
189 define JIM_DOCS [opt-bool docs]
191 # Attributes of the extensions
192 # tcl=Pure Tcl extension
193 # static=Can't be built as a module
194 # optional=Not selected by default
195 # cpp=Is a C++ extension
196 global extdb
197 dict set extdb attrs {
198 aio { static }
199 array {}
200 binary { tcl }
201 clock {}
202 eventloop { static }
203 exec { static }
204 file {}
205 glob { tcl }
206 history {}
207 load { static }
208 mk { cpp optional }
209 namespace { static }
210 nshelper { tcl optional }
211 oo { tcl }
212 pack {}
213 package { static }
214 posix {}
215 readdir {}
216 readline { optional }
217 regexp {}
218 rlprompt { tcl optional }
219 sdl { optional }
220 signal { static }
221 sqlite3 { optional }
222 stdlib { tcl static }
223 syslog {}
224 tclcompat { tcl static }
225 tclprefix {}
226 tree { tcl }
227 win32 { optional }
230 # Additional information about certain extensions
231 # dep=list of extensions which are required for this extension
232 # check=[expr] expression to evaluate to determine if the extension can be used
233 # libdep=list of 'define' symbols for dependent libraries
234 dict set extdb info {
235 binary { dep pack }
236 exec { check {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]} }
237 glob { dep readdir }
238 load { check {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]} libdep lib_dlopen }
239 mk { check {[check-metakit]} libdep lib_mk }
240 namespace { dep nshelper }
241 posix { check {[have-feature waitpid]} }
242 readdir { check {[have-feature opendir]} }
243 readline { check {[cc-check-function-in-lib readline readline]} libdep lib_readline}
244 rlprompt { dep readline }
245 tree { dep oo }
246 sdl { check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]}
247 libdep {lib_SDL_SetVideoMode lib_rectangleRGBA}
249 signal { check {[have-feature sigaction] && [have-feature vfork]} }
250 sqlite3 { check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 }
251 syslog { check {[have-feature syslog]} }
252 tree { dep oo }
253 win32 { check {[have-feature windows]} }
256 # autosetup cc-check-function-in-library can't handle C++ libraries
257 proc check-metakit {} {
258 set found 0
259 msg-checking "Checking for Metakit..."
260 cc-with {-lang c++} {
261 if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} {
262 msg-result ok
263 define lib_mk -lmk4
264 incr found
265 } else {
266 msg-result "not found"
269 return $found
272 # Set up the withinfo array based on what the user selected
273 global withinfo
274 set withinfo(without) [join [opt-val {without-ext with-out-jim-ext}]]
275 set withinfo(ext) [join [opt-val {with-ext with-jim-ext}]]
276 set withinfo(mod) [join [opt-val {with-mod with-jim-extmod}]]
277 set withinfo(nodefault) 0
278 if {$withinfo(without) eq "default"} {
279 set withinfo(without) {}
280 set withinfo(nodefault) 1
283 # Now go check everything - see autosetup/local.tcl
284 array set extinfo [check-extensions]
286 # Now special checks
287 if {[have-feature windows]} {
288 lappend extra_objs jim-win32compat.o
290 if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} {
291 user-error "cygwin/mingw require --shared for dynamic modules"
295 if {[ext-get-status regexp] in {y m}} {
296 if {![have-feature regcomp]} {
297 # No regcomp means we need to use the built-in version
298 incr jimregexp
302 if {$jimregexp || [opt-bool jim-regexp]} {
303 msg-result "Using built-in regexp"
304 define JIM_REGEXP
306 # If the built-in regexp overrides the system regcomp, etc.
307 # jim must be built shared so that the correct symbols are found
308 if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} {
309 user-error "Must use --shared with regexp module and built-in regexp"
313 if {[ext-get-status load] eq "n"} {
314 # If we don't have load, no need to support shared objects
315 define SH_LINKFLAGS ""
318 msg-result "Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
319 if {[llength $extinfo(module-tcl)]} {
320 msg-result "Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
322 if {[llength $extinfo(module-c)]} {
323 msg-result "Jim dynamic extensions: [lsort $extinfo(module-c)]"
326 define STATIC_EXTS [concat $extinfo(static-c) $extinfo(static-tcl)]
327 define C_EXT_OBJS [prefix jim- [suffix .o $extinfo(static-c)]]
328 define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)]
329 define C_EXT_SHOBJS [suffix .so $extinfo(module-c)]
330 define TCL_EXTS [suffix .tcl $extinfo(module-tcl)]
331 define EXTRA_OBJS $extra_objs
333 make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
334 make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*}
335 make-template Makefile.in
336 make-template build-jim-ext.in
338 catch {exec chmod +x build-jim-ext}