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