Remove autosetup/jimsh0.exe on distclean
[jimtcl.git] / auto.def
blob1e1c495ab5dc6bca8d68611321f0eae5df9a7887
1 # vim:se syn=tcl:
4 # Note: modules which support options *must* be included before 'options'
5 use cc cc-shared
7 options {
8 utf8 => "include support for utf8-encoded strings"
9 lineedit=1 => "disable line editing"
10 references=1 => "disable support for references"
11 math => "include support for math functions"
12 ipv6 => "include ipv6 support in the aio extension"
13 maintainer => {enable the [debug] command and JimPanic}
14 with-jim-shared shared => "build a shared library instead of a static library"
15 jim-regexp => "use the built-in (Tcl-compatible) regexp, even if POSIX regex is available"
16 with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
17 Specify additional jim extensions to include.
18 These are enabled by default:
20 aio - ANSI I/O, including open and socket
21 eventloop - after, vwait, update
22 array - Tcl-compatible array command
23 clock - Tcl-compatible clock command
24 exec - Tcl-compatible exec command
25 file - Tcl-compatible file command
26 glob - Tcl-compatible glob command
27 readdir - Required for glob
28 package - Package management with the package command
29 load - Load binary extensions at runtime with load or package
30 posix - Posix APIs including os.fork, os.wait, pid
31 regexp - Tcl-compatible regexp, regsub commands
32 signal - Signal handling
33 stdlib - Built-in commands including lassign, lambda, alias
34 syslog - System logging with syslog
35 tclcompat - Tcl compatible read, gets, puts, parray, case, ...
37 These are disabled by default:
39 nvp - Name-value pairs C-only API
40 oo - Jim OO extension
41 tree - OO tree structure, similar to tcllib ::struct::tree
42 binary - Tcl-compatible 'binary' command
43 readline - Interface to libreadline
44 rlprompt - Tcl wrapper around the readline extension
45 sqlite - Interface to sqlite
46 sqlite3 - Interface to sqlite3
47 win32 - Interface to win32
49 with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
50 Specify jim extensions to exclude.
51 If 'default' is given, the default extensions will not be added.
53 with-jim-extmod: {with-mod:"ext1 ext2 ..."} => {
54 Specify jim extensions to build as separate modules (either C or Tcl).
55 Note that not all extensions can be built as loadable modules.
59 cc-check-types "long long"
61 cc-check-includes sys/socket.h netinet/in.h arpa/inet.h netdb.h
62 cc-check-includes sys/un.h dlfcn.h unistd.h crt_externs.h
64 cc-check-functions ualarm sysinfo lstat fork vfork system select
65 cc-check-functions backtrace geteuid mkstemp realpath strptime gettimeofday
66 cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist
67 cc-check-functions syslog opendir readlink sleep usleep pipe inet_ntop getaddrinfo
69 switch -glob -- [get-define host] {
70 *-*-ming* {
71 # We provide our own implementation of dlopen for mingw32
72 define-feature dlopen-compat
76 # Find some tools
77 cc-check-tools ar ranlib strip
78 define tclsh [info nameofexecutable]
80 if {![cc-check-functions _NSGetEnviron]} {
81 msg-checking "Checking environ declared in unistd.h..."
82 if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} {
83 define NO_ENVIRON_EXTERN
84 msg-result "yes"
85 } else {
86 msg-result "no"
90 # Windows has a mkdir with no permission arg
91 cc-check-includes sys/types.h sys/stat.h
92 msg-checking "Checking for mkdir with one arg..."
93 if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
94 define HAVE_MKDIR_ONE_ARG
95 msg-result yes
96 } else {
97 msg-result no
100 set extra_objs {}
101 set jimregexp 0
103 if {[opt-bool utf8]} {
104 msg-result "Enabling UTF-8"
105 define JIM_UTF8
106 incr jimregexp
108 if {[opt-bool maintainer]} {
109 msg-result "Enabling maintainer settings"
110 define JIM_MAINTAINER
112 if {[opt-bool math]} {
113 msg-result "Enabling math functions"
114 define JIM_MATH_FUNCTIONS
115 define-append LIBS -lm
117 if {[opt-bool ipv6]} {
118 msg-result "Enabling IPv6"
119 define JIM_IPV6
121 if {[opt-bool lineedit] && [cc-check-includes termios.h]} {
122 msg-result "Enabling line editing"
123 define USE_LINENOISE
124 lappend extra_objs linenoise.o
126 if {[opt-bool references]} {
127 msg-result "Enabling references"
128 define JIM_REFERENCES
130 if {[opt-bool shared with-jim-shared]} {
131 msg-result "Building shared library"
132 define JIM_LIBTYPE shared
133 } else {
134 msg-result "Building static library"
135 define JIM_LIBTYPE static
138 # Note: Extension handling is mapped directly from the configure.ac
139 # implementation
141 set without [join [opt-val {without-ext with-out-jim-ext}]]
142 set withext [join [opt-val {with-ext with-jim-ext}]]
143 set withmod [join [opt-val {with-mod with-jim-extmod}]]
145 # Tcl extensions
146 set ext_tcl "stdlib glob tclcompat tree rlprompt oo binary"
147 # C extensions
148 set ext_c "load package readdir array clock exec file posix regexp signal aio eventloop pack syslog nvp readline sqlite sqlite3 win32"
150 # Tcl extensions which can be modules
151 set ext_tcl_mod "glob tree rlprompt oo binary"
152 # C extensions which can be modules
153 set ext_c_mod "readdir array clock file posix regexp syslog readline pack sqlite sqlite3 win32"
155 # All extensions
156 set ext_all [concat $ext_c $ext_tcl]
158 # Default static extensions
159 set ext_default "stdlib load package readdir glob array clock exec file posix regexp signal tclcompat aio eventloop syslog"
161 if {$without eq "default"} {
162 set ext_default stdlib
163 set without {}
166 # Check valid extension names
167 foreach i [concat $withext $without $withmod] {
168 if {$i ni $ext_all} {
169 user-error "Unknown extension: $i"
173 # needs_xxx="expression" means that the expr must eval to 1 to select the extension
174 # dep_xxx="yyy zzz" means that if xxx is selected, so is yyy and zzz
175 set dep(glob) readdir
176 set dep(rlprompt) readline
177 set dep(tree) oo
178 set dep(binary) pack
180 set needs(aio) {expr {[cc-check-function-in-lib socket socket] || 1}}
181 set needs(exec) {expr {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]}}
182 set needs(load) {expr {[cc-check-function-in-lib dlopen dl] || [have-feature dlopen-compat]}}
183 set needs(posix) {have-feature waitpid}
184 set needs(readdir) {have-feature opendir}
185 set needs(readline) {cc-check-function-in-lib readline readline}
186 set needs(signal) {expr {[have-feature sigaction] && [have-feature vfork]}}
187 set needs(sqlite) {cc-check-function-in-lib sqlite_open sqlite}
188 set needs(sqlite3) {cc-check-function-in-lib sqlite3_open sqlite3}
189 set needs(syslog) {have-feature syslog}
190 set needs(eventloop) {expr {[have-feature select] || [have-feature usleep]}}
191 set needs(win32) {have-feature windows}
193 # First handle dependencies. If an extension is enabled, also enable its dependency
194 foreach i [concat $ext_default $withext] {
195 if {$i in $without} {
196 continue
198 if {[info exists dep($i)]} {
199 lappend withext {*}$dep($i)
203 foreach i $withmod {
204 if {[info exists dep($i)]} {
205 # Theoretically, a mod could depend upon something which must be static
206 # If already configured static, don't make it a module
207 foreach d $dep($i) {
208 if {$d ni $withext} {
209 lappend withmod $d
215 # Now that we know what the platform supports:
217 # For all known extensions:
218 # - If it is disabled, remove it
219 # - Otherwise, check to see if it's pre-requisites are met
220 # - If yes, add it if it is enabled or is a default
221 # - If no, error if it is enabled, or do nothing otherwise
222 # - Modules may be either C or Tcl
224 set extmodtcl {}
225 set extmod {}
226 set ext {}
228 foreach i [lsort $ext_all] {
229 # First discard the extension if disabled or not enabled
230 if {$i in $without} {
231 msg-result "Extension $i...disabled"
232 continue
234 if {$i ni [concat $withext $withmod $ext_default]} {
235 msg-result "Extension $i...not enabled"
236 continue
239 # Check dependencies
240 set met 1
241 if {[info exists needs($i)]} {
242 set met [eval $needs($i)]
245 msg-checking "Extension $i..."
247 # Selected as a module?
248 if {$i in $withmod} {
249 if {$i in $ext_tcl_mod} {
250 # Easy, a Tcl module
251 msg-result "tcl"
252 lappend extmodtcl $i
253 continue
255 if {$i ni $ext_c_mod} {
256 user-error "not a module"
258 if {!$met} {
259 user-error "dependencies not met"
261 msg-result "module"
262 lappend extmod $i
263 continue
266 # Selected as a static extension?
267 if {$i in $withext} {
268 if {!$met} {
269 user-error "dependencies not met"
271 msg-result "enabled"
272 lappend ext $i
273 continue
276 # Enabled by default?
277 if {$i in $ext_default} {
278 if {!$met} {
279 msg-result "disabled (dependencies)"
280 continue
282 msg-result "enabled (default)"
283 lappend ext $i
284 continue
288 if {[have-feature windows]} {
289 lappend extra_objs jim-win32compat.o
291 if {$extmod ne "" && [get-define JIM_LIBTYPE] eq "static"} {
292 user-error "cygwin/mingw require --shared for dynamic modules"
296 if {"regexp" in "$ext $extmod"} {
297 # No regcomp means we need to use the built-in version
298 if {![have-feature regcomp]} {
299 incr jimregexp
303 if {$jimregexp || [opt-bool jim-regexp]} {
304 msg-result "Using built-in regexp"
305 define JIM_REGEXP
307 # If the built-in regexp overrides the system regcomp, etc.
308 # jim must be built shared so that the correct symbols are found
309 if {"regexp" in $extmod && [get-define JIM_LIBTYPE] eq "static" && [have-feature regcomp]} {
310 user-error "Must use --shared with regexp module and built-in regexp"
313 if {"load" ni $ext} {
314 # If we don't have load, no need to support shared objects
315 define SH_LINKFLAGS ""
318 msg-result "Jim static extensions: [lsort $ext]"
319 if {$extmodtcl ne ""} {
320 msg-result "Jim Tcl extensions: [lsort $extmodtcl]"
322 if {$extmod ne ""} {
323 msg-result "Jim dynamic extensions: [lsort $extmod]"
326 define JIM_EXTENSIONS $ext
327 define JIM_TCL_EXTENSIONS $extmodtcl
328 define JIM_MOD_EXTENSIONS $extmod
329 define EXTRA_OBJS $extra_objs
331 foreach e $ext {
332 define jim_ext_$e
333 if {$e in $ext_tcl} {
334 define-append GENERATED_SRCS jim-$e.c
338 define TCL_LIBRARY [get-define prefix]/lib/jim
339 define TCL_PLATFORM_OS [exec uname -s]
340 define TCL_PLATFORM_PLATFORM unix
342 make-autoconf-h jim-config.h {HAVE_LONG_LONG* JIM_UTF8}
343 make-autoconf-h jimautoconf.h {HAVE_* jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_*}
344 make-template Makefile.in