Fossil SCM

Merge trunk

jan.nijtmans 2020-01-28 20:39 UTC multi-thread merge
Commit 9dbea18c7128a442823bccc2d3b24a98b67237d667533078ac0c361b2f6c7764
322 files changed +10 +5 -7 +17 +5 -4 +4 -2 +15 +1 -1 +110 -12 +11 -1 +709 -235 +5 -27 +28 +4 -44 +35 +7 -5 +12 +20 +2 -2 +77 -79 +9 -13 +80 -52 -50 -75 -10 +3701 -3421 +19 -18 +207 -83 -20 +12 -23 +3 -3 +1 -1 +35 -28 +57 +3 +3 +4 -1 +3 +3 +1 -1 +11 -3 +78 -8 +3 +17 -12 +228 +36 -1 +5 -2 +6 -3 +3 +3 +1 -1 +3 +3 +14 +5 -2 +7 -5 +102 -2 +102 +3 -8 +487 -34 +6 +72 -9 +49 -12 +196 -100 +16 -16 +1 -1 +94 +1 -1 +240 -61 +134 -93 +51 -5 +9 -4 +1 +162 -29 +2 +19 -10 +11 -4 +1 +520 -85 +520 -85 +135 -8 +449 +64 -6 +2 -2 +12 -21 +80 -108 +304 -73 -2 +14 -7 +15 -1 +886 -40 +36 +593 -13 +13 -7 +2 -1 +1094 -318 +17 +1 -1 +66 +193 -47 +449 -74 +1 -1 +2 -2 +141 -33 +6 -3 +11 -1 +9 -8 +9 -6 +341 -109 +9 +2 -1 +2 -2 +1 -2 +57 -7 +1 -1 +437 -196 +6 -4 +421 -285 +421 -285 +100 -27 +29 -2 +8 -8 +96 -122 +344 -109 +104 -106 +44 -9 +95 -25 +38 -14 +1 -1 +56 -4 +4 +64 -4 +163 -34 +10 +13 -3 +39 -6 +187 -14 +140 -89 +5 +7 +78 -20 +89 -19 +235 -52 +190 -885 +24 -19 +3308 -430 +3 -3 +120 -39 +49 -28 +214 -100 +33 -11 +33 -11 +25 +26640 -14453 +759 -233 +140 -34 +29 -10 +10 -2 +388 -122 +29 -22 +99 -25 +1 +20 -12 +166 -5 +11 -11 +611 -179 +61 -34 +27 -13 +25 -10 +18 -7 +189 -158 +6 -8 +44 -10 +1 -1 +5 -3 +54 -6 +1 -1 +173 -43 +82 -19 +605 -185 +287 -112 +18 -9 +64 -42 +153 -27 +1 +136 -136 +23 +1 -1 +80 -16 +8 +49 -47 +10 -10 +1 -1 +3 -3 +58 +7 -7 +48 -12 +97 -19 +147 -7 +199 -167 +12 -5 +13 -1 +21 -15 +808 +37 -40 +49 +32 +95 +228 +95 +247 +126 +303 +252 +569 +320 +730 +458 +239 +387 -58 +111 -5 +9 +64 +39 +6 +36 +81 +234 -3 +19 -6 +38 +139 +15 -12 +1 -1 +1 -1 +139 -63 +336 +67 -29 -221 +48 -3 +1 -1 +56 -52 +2 -2 +241 -107 -7 +407 +864 -260 +2 -1 +1 -1 +3 +3 +28 -20 +11 +1 +1 +12 -13 +9 +225 +2 +3 -3 +53 +34 +112 +22 -1 +2 -2 +74 -3 +7 -7 +7 -6 +148 +71 +137 +69 +200 +92 +242 +108 +231 +101 +14 +7 -2 -38 +19 +7 +16 +41 +3 +34 +26 +127 +14 +196 -35 +199 +122 +18 +115 +52 +8 +69 +5 +146 +16 +81 -17 +281 -36 +1 -1 +62 -9 +2 -2 +102 -14 +7 -7 +395 +3 -3 +3 -2 +21 -2
~ .editorconfig ~ Dockerfile ~ Makefile.classic ~ Makefile.in ~ Makefile.osx-jaguar ~ README.md ~ VERSION ~ auto.def ~ autosetup/README.autosetup ~ autosetup/autosetup ~ autosetup/autosetup-config.guess + autosetup/autosetup-config.guess ~ autosetup/autosetup-config.sub + autosetup/autosetup-config.sub ~ autosetup/autosetup-find-tclsh + autosetup/autosetup-find-tclsh ~ autosetup/autosetup-test-tclsh + autosetup/autosetup-test-tclsh ~ autosetup/cc-db.tcl ~ autosetup/cc-lib.tcl ~ autosetup/cc-shared.tcl ~ autosetup/cc.tcl - autosetup/config.guess - autosetup/config.sub - autosetup/find-tclsh ~ autosetup/jimsh0.c ~ autosetup/pkg-config.tcl ~ autosetup/system.tcl - autosetup/test-tclsh ~ autosetup/tmake.auto ~ autosetup/tmake.tcl ~ configure ~ fossil.1 ~ skins/ardoise/css.txt ~ skins/ardoise/header.txt ~ skins/black_and_white/header.txt ~ skins/blitz/css.txt ~ skins/blitz/header.txt ~ skins/blitz_no_logo/header.txt ~ skins/bootstrap/footer.txt ~ skins/bootstrap/header.txt ~ skins/default/css.txt ~ skins/default/footer.txt ~ skins/default/header.txt ~ skins/default/js.txt ~ skins/eagle/css.txt ~ skins/eagle/header.txt ~ skins/enhanced1/header.txt ~ skins/khaki/header.txt ~ skins/original/header.txt ~ skins/plain_gray/details.txt ~ skins/plain_gray/header.txt ~ skins/rounded1/header.txt ~ skins/xekri/css.txt ~ skins/xekri/header.txt ~ src/add.c ~ src/alerts.c + src/alerts.c ~ src/attach.c ~ src/backoffice.c ~ src/bag.c ~ src/bisect.c ~ src/blob.c ~ src/branch.c ~ src/browse.c ~ src/cache.c ~ src/capabilities.c ~ src/captcha.c ~ src/cgi.c ~ src/checkin.c ~ src/checkout.c ~ src/clone.c ~ src/codecheck1.c ~ src/comformat.c ~ src/config.h ~ src/configure.c ~ src/content.c ~ src/copybtn.js ~ src/db.c ~ src/db.c ~ src/default_css.txt ~ src/deltafunc.c ~ src/descendants.c ~ src/diff.c ~ src/diffcmd.c ~ src/dispatch.c ~ src/doc.c - src/email.c ~ src/encode.c ~ src/event.c ~ src/export.c ~ src/extcgi.c ~ src/file.c ~ src/finfo.c ~ src/foci.c ~ src/forum.c ~ src/forum.js ~ src/fshell.c ~ src/fuzz.c ~ src/graph.c ~ src/graph.js ~ src/hname.c ~ src/href.js ~ src/http.c ~ src/http_socket.c ~ src/http_ssl.c ~ src/http_transport.c ~ src/import.c ~ src/info.c ~ src/json.c ~ src/json_branch.c ~ src/json_login.c ~ src/json_status.c ~ src/json_timeline.c ~ src/json_user.c ~ src/loadctrl.c ~ src/login.c ~ src/lookslike.c ~ src/main.c ~ src/main.c ~ src/main.mk ~ src/makeheaders.c ~ src/makeheaders.html ~ src/makemake.tcl ~ src/manifest.c ~ src/markdown.c ~ src/markdown.md ~ src/markdown_html.c ~ src/merge.c ~ src/miniz.c ~ src/mkbuiltin.c ~ src/mkindex.c ~ src/moderate.c ~ src/name.c ~ src/path.c ~ src/popen.c ~ src/printf.c ~ src/rebuild.c ~ src/regexp.c ~ src/repolist.c ~ src/report.c ~ src/schema.c ~ src/search.c ~ src/security_audit.c ~ src/setup.c ~ src/setupuser.c ~ src/sha1.c ~ src/shell.c ~ src/shun.c ~ src/sitemap.c ~ src/skins.c ~ src/smtp.c ~ src/sqlcmd.c ~ src/sqlcmd.c ~ src/sqlcompattest.c ~ src/sqlite3.c ~ src/sqlite3.h ~ src/stash.c ~ src/stat.c ~ src/statrep.c ~ src/style.c ~ src/sync.c ~ src/tag.c ~ src/tar.c ~ src/th.c ~ src/th_main.c ~ src/th_tcl.c ~ src/timeline.c ~ src/tkt.c ~ src/tktsetup.c ~ src/translate.c ~ src/undo.c ~ src/unicode.c ~ src/unversioned.c ~ src/update.c ~ src/url.c ~ src/user.c ~ src/util.c ~ src/verify.c ~ src/vfile.c ~ src/webmail.c ~ src/wiki.c ~ src/wikiformat.c ~ src/winhttp.c ~ src/wysiwyg.c ~ src/xfer.c ~ src/zip.c ~ test/commit-warning.test ~ test/graph-test-1.wiki ~ test/settings.test ~ test/tester.tcl ~ test/th1-docs.test ~ test/th1.test ~ test/wiki.test ~ tools/email-sender.tcl ~ tools/fossil-autocomplete.bash ~ tools/fslsrv ~ win/Makefile.PellesCGMake ~ win/Makefile.dmc ~ win/Makefile.mingw ~ win/Makefile.mingw.mistachkin ~ win/Makefile.msc ~ win/buildmsvc.bat ~ www/aboutcgi.wiki ~ www/aboutdownload.wiki ~ www/alerts.md ~ www/antibot.wiki ~ www/backoffice.md ~ www/blockchain.md - www/branch01.gif ~ www/branch01.graphml ~ www/branch01.svg - www/branch02.gif ~ www/branch02.graphml ~ www/branch02.svg - www/branch03.gif ~ www/branch03.graphml ~ www/branch03.svg - www/branch04.gif ~ www/branch04.graphml ~ www/branch04.svg - www/branch05.gif ~ www/branch05.graphml ~ www/branch05.svg ~ www/branch06.graphml ~ www/branch06.svg ~ www/branching.wiki ~ www/build.wiki ~ www/caps/admin-v-setup.md ~ www/caps/impl.md ~ www/caps/index.md ~ www/caps/login-groups.md ~ www/caps/ref.html ~ www/cgi.wiki ~ www/changes.wiki ~ www/checkin_names.wiki ~ www/chroot.md ~ www/collisions.ipynb ~ www/concepts.wiki ~ www/contribute.wiki ~ www/custom_ticket.wiki ~ www/customskin.md ~ www/defcsp.md ~ www/delta_format.wiki - www/emaildesign.md ~ www/embeddeddoc.wiki ~ www/encryptedrepos.wiki ~ www/env-opts.md ~ www/event.wiki ~ www/fileformat.wiki ~ www/fiveminutes.wiki ~ www/forum.wiki ~ www/fossil-v-git.wiki ~ www/fossil_prompt.sh ~ www/fossil_prompt.wiki ~ www/grep.md ~ www/hacker-howto.wiki ~ www/hashpolicy.wiki ~ www/image-format-vs-repo-size.ipynb ~ www/image-format-vs-repo-size.md ~ www/image-format-vs-repo-size.svg ~ www/index.wiki ~ www/inout.wiki ~ www/javascript.md ~ www/loadmgmt.md ~ www/makefile.wiki ~ www/mdtest/test1.md ~ www/mirrorlimitations.md ~ www/mirrortogithub.md ~ www/mkindex.tcl ~ www/password.wiki ~ www/permutedindex.html ~ www/private.wiki ~ www/quickstart.wiki ~ www/rebase01.graphml ~ www/rebase01.svg ~ www/rebase02.graphml ~ www/rebase02.svg ~ www/rebase03.graphml ~ www/rebase03.svg ~ www/rebase04.graphml ~ www/rebase04.svg ~ www/rebase05.graphml ~ www/rebase05.svg ~ www/rebaseharm.md ~ www/selfhost.wiki - www/server.wiki ~ www/server/any/althttpd.md ~ www/server/any/cgi.md ~ www/server/any/inetd.md ~ www/server/any/none.md ~ www/server/any/scgi.md ~ www/server/any/stunnel.md ~ www/server/any/xinetd.md ~ www/server/debian/nginx.md ~ www/server/debian/service.md ~ www/server/index.html + www/server/index.html ~ www/server/macos/service.md ~ www/server/whyuseaserver.wiki ~ www/server/windows/cgi-bin-perm.png ~ www/server/windows/cgi-exec-perm.png ~ www/server/windows/cgi-install-iis.png ~ www/server/windows/cgi-script-map.png ~ www/server/windows/cgi.md ~ www/server/windows/iis.md ~ www/server/windows/index.md ~ www/server/windows/none.md ~ www/server/windows/service.md ~ www/server/windows/stunnel.md ~ www/serverext.wiki ~ www/shunning.wiki ~ www/ssl.wiki ~ www/stats.wiki ~ www/sync.wiki ~ www/tech_overview.wiki ~ www/th1.md ~ www/tickets.wiki ~ www/tls-nginx.md ~ www/unvers.wiki ~ www/webui.wiki ~ www/wikitheory.wiki
--- a/.editorconfig
+++ b/.editorconfig
@@ -0,0 +1,10 @@
1
+# EditorConfig (https://editorconfig.com) Configuration for Fossil
2
+#
3
+# Following https://fossil-scm.org/fossil/doc/trunk/www/style.wiki
4
+#
5
+
6
+# Defaults for all files
7
+[*]
8
+end_of_line = lf
9
+insert_final_newline = true
10
+indent_styl[{Makefile,Makefile.*
--- a/.editorconfig
+++ b/.editorconfig
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
--- a/.editorconfig
+++ b/.editorconfig
@@ -0,0 +1,10 @@
1 # EditorConfig (https://editorconfig.com) Configuration for Fossil
2 #
3 # Following https://fossil-scm.org/fossil/doc/trunk/www/style.wiki
4 #
5
6 # Defaults for all files
7 [*]
8 end_of_line = lf
9 insert_final_newline = true
10 indent_styl[{Makefile,Makefile.*
+5 -7
--- Dockerfile
+++ Dockerfile
@@ -1,25 +1,23 @@
11
###
22
# Dockerfile for Fossil
33
###
4
-FROM fedora:24
4
+FROM fedora:29
55
66
### Now install some additional parts we will need for the build
7
-RUN dnf update -y && dnf install -y gcc make zlib-devel openssl-devel tar && dnf clean all && groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
7
+RUN dnf update -y && dnf install -y gcc make tcl tcl-devel zlib-devel openssl-devel tar && dnf clean all && groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
88
99
### If you want to build "trunk", change the next line accordingly.
1010
ENV FOSSIL_INSTALL_VERSION release
1111
12
-RUN curl "http://core.tcl.tk/tcl/tarball/tcl-src.tar.gz?name=tcl-src&uuid=release" | tar zx
13
-RUN cd tcl-src/unix && ./configure --prefix=/usr --disable-load && make && make install
14
-RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
15
-RUN cd fossil-src && ./configure --disable-fusefs --json --with-th1-docs --with-th1-hooks --with-tcl --with-tcl-stubs --with-tcl-private-stubs
12
+RUN curl "https://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
13
+RUN cd fossil-src && ./configure --disable-fusefs --json --with-th1-docs --with-th1-hooks --with-tcl=1 --with-tcl-stubs --with-tcl-private-stubs
1614
RUN cd fossil-src/src && mv main.c main.c.orig && sed s/\"now\"/0/ <main.c.orig >main.c
1715
RUN cd fossil-src && make && strip fossil && cp fossil /usr/bin && cd .. && rm -rf fossil-src && chmod a+rx /usr/bin/fossil && mkdir -p /opt/fossil && chown fossil:fossil /opt/fossil
1816
1917
### Build is done, remove modules no longer needed
20
-RUN dnf remove -y gcc make zlib-devel openssl-devel tar && dnf clean all
18
+RUN dnf remove -y gcc make zlib-devel tcl-devel openssl-devel tar && dnf clean all
2119
2220
USER fossil
2321
2422
ENV HOME /opt/fossil
2523
2624
--- Dockerfile
+++ Dockerfile
@@ -1,25 +1,23 @@
1 ###
2 # Dockerfile for Fossil
3 ###
4 FROM fedora:24
5
6 ### Now install some additional parts we will need for the build
7 RUN dnf update -y && dnf install -y gcc make zlib-devel openssl-devel tar && dnf clean all && groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
8
9 ### If you want to build "trunk", change the next line accordingly.
10 ENV FOSSIL_INSTALL_VERSION release
11
12 RUN curl "http://core.tcl.tk/tcl/tarball/tcl-src.tar.gz?name=tcl-src&uuid=release" | tar zx
13 RUN cd tcl-src/unix && ./configure --prefix=/usr --disable-load && make && make install
14 RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
15 RUN cd fossil-src && ./configure --disable-fusefs --json --with-th1-docs --with-th1-hooks --with-tcl --with-tcl-stubs --with-tcl-private-stubs
16 RUN cd fossil-src/src && mv main.c main.c.orig && sed s/\"now\"/0/ <main.c.orig >main.c
17 RUN cd fossil-src && make && strip fossil && cp fossil /usr/bin && cd .. && rm -rf fossil-src && chmod a+rx /usr/bin/fossil && mkdir -p /opt/fossil && chown fossil:fossil /opt/fossil
18
19 ### Build is done, remove modules no longer needed
20 RUN dnf remove -y gcc make zlib-devel openssl-devel tar && dnf clean all
21
22 USER fossil
23
24 ENV HOME /opt/fossil
25
26
--- Dockerfile
+++ Dockerfile
@@ -1,25 +1,23 @@
1 ###
2 # Dockerfile for Fossil
3 ###
4 FROM fedora:29
5
6 ### Now install some additional parts we will need for the build
7 RUN dnf update -y && dnf install -y gcc make tcl tcl-devel zlib-devel openssl-devel tar && dnf clean all && groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
8
9 ### If you want to build "trunk", change the next line accordingly.
10 ENV FOSSIL_INSTALL_VERSION release
11
12 RUN curl "https://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
13 RUN cd fossil-src && ./configure --disable-fusefs --json --with-th1-docs --with-th1-hooks --with-tcl=1 --with-tcl-stubs --with-tcl-private-stubs
 
 
14 RUN cd fossil-src/src && mv main.c main.c.orig && sed s/\"now\"/0/ <main.c.orig >main.c
15 RUN cd fossil-src && make && strip fossil && cp fossil /usr/bin && cd .. && rm -rf fossil-src && chmod a+rx /usr/bin/fossil && mkdir -p /opt/fossil && chown fossil:fossil /opt/fossil
16
17 ### Build is done, remove modules no longer needed
18 RUN dnf remove -y gcc make zlib-devel tcl-devel openssl-devel tar && dnf clean all
19
20 USER fossil
21
22 ENV HOME /opt/fossil
23
24
--- Makefile.classic
+++ Makefile.classic
@@ -19,10 +19,11 @@
1919
# will run on the platform that is doing the build. This is used
2020
# to compile code-generator programs as part of the build process.
2121
# See TCC below for the C compiler for building the finished binary.
2222
#
2323
BCC = gcc
24
+BCCFLAGS = $(CFLAGS)
2425
2526
#### The suffix to add to final executable file. When cross-compiling
2627
# to windows, make this ".exe". Otherwise leave it blank.
2728
#
2829
E =
@@ -49,10 +50,19 @@
4950
5051
#### We sometimes add the -static option here so that we can build a
5152
# static executable that will run in a chroot jail.
5253
#LIB = -static
5354
TCC += -DFOSSIL_DYNAMIC_BUILD=1
55
+
56
+TCCFLAGS = $(CFLAGS)
57
+
58
+# We don't attempt to use libedit or libreadline in this simplified
59
+# build system (contrast auto.def and Makefile.in) so use the included
60
+# copy of linenoise. MinGW can't make use of this, but linenoise is
61
+# ifdef'd out elsewhere for that platform. Note that this is a make
62
+# flag handled in src/main.mk, not a C preprocessor flag.
63
+USE_LINENOISE := 1
5464
5565
#### Extra arguments for linking the finished binary. Fossil needs
5666
# to link against the Z-Lib compression library unless the miniz
5767
# library in the source tree is being used. There are no other
5868
# required dependencies.
@@ -63,10 +73,15 @@
6373
# If using zlib:
6474
LIB += $(ZLIB_LIB.$(FOSSIL_ENABLE_MINIZ)) $(LDFLAGS)
6575
6676
# If using HTTPS:
6777
LIB += -lcrypto -lssl
78
+
79
+# Many platforms put cos() needed by src/piechart.c in libm, rather than
80
+# in libc. We cannot enable this by default because libm doesn't exist
81
+# everywhere.
82
+#LIB += -lm
6883
6984
#### Tcl shell for use in running the fossil testsuite. If you do not
7085
# care about testing the end result, this can be blank.
7186
#
7287
TCLSH = tclsh
@@ -84,7 +99,9 @@
8499
TCC.DragonFly += -DUSE_PREAD
85100
TCC.FreeBSD += -DUSE_PREAD
86101
TCC.NetBSD += -DUSE_PREAD
87102
TCC.OpenBSD += -DUSE_PREAD
88103
TCC += $(TCC.$(HOST_OS))
104
+
105
+APPNAME = fossil$(E)
89106
90107
include $(SRCDIR)/main.mk
91108
--- Makefile.classic
+++ Makefile.classic
@@ -19,10 +19,11 @@
19 # will run on the platform that is doing the build. This is used
20 # to compile code-generator programs as part of the build process.
21 # See TCC below for the C compiler for building the finished binary.
22 #
23 BCC = gcc
 
24
25 #### The suffix to add to final executable file. When cross-compiling
26 # to windows, make this ".exe". Otherwise leave it blank.
27 #
28 E =
@@ -49,10 +50,19 @@
49
50 #### We sometimes add the -static option here so that we can build a
51 # static executable that will run in a chroot jail.
52 #LIB = -static
53 TCC += -DFOSSIL_DYNAMIC_BUILD=1
 
 
 
 
 
 
 
 
 
54
55 #### Extra arguments for linking the finished binary. Fossil needs
56 # to link against the Z-Lib compression library unless the miniz
57 # library in the source tree is being used. There are no other
58 # required dependencies.
@@ -63,10 +73,15 @@
63 # If using zlib:
64 LIB += $(ZLIB_LIB.$(FOSSIL_ENABLE_MINIZ)) $(LDFLAGS)
65
66 # If using HTTPS:
67 LIB += -lcrypto -lssl
 
 
 
 
 
68
69 #### Tcl shell for use in running the fossil testsuite. If you do not
70 # care about testing the end result, this can be blank.
71 #
72 TCLSH = tclsh
@@ -84,7 +99,9 @@
84 TCC.DragonFly += -DUSE_PREAD
85 TCC.FreeBSD += -DUSE_PREAD
86 TCC.NetBSD += -DUSE_PREAD
87 TCC.OpenBSD += -DUSE_PREAD
88 TCC += $(TCC.$(HOST_OS))
 
 
89
90 include $(SRCDIR)/main.mk
91
--- Makefile.classic
+++ Makefile.classic
@@ -19,10 +19,11 @@
19 # will run on the platform that is doing the build. This is used
20 # to compile code-generator programs as part of the build process.
21 # See TCC below for the C compiler for building the finished binary.
22 #
23 BCC = gcc
24 BCCFLAGS = $(CFLAGS)
25
26 #### The suffix to add to final executable file. When cross-compiling
27 # to windows, make this ".exe". Otherwise leave it blank.
28 #
29 E =
@@ -49,10 +50,19 @@
50
51 #### We sometimes add the -static option here so that we can build a
52 # static executable that will run in a chroot jail.
53 #LIB = -static
54 TCC += -DFOSSIL_DYNAMIC_BUILD=1
55
56 TCCFLAGS = $(CFLAGS)
57
58 # We don't attempt to use libedit or libreadline in this simplified
59 # build system (contrast auto.def and Makefile.in) so use the included
60 # copy of linenoise. MinGW can't make use of this, but linenoise is
61 # ifdef'd out elsewhere for that platform. Note that this is a make
62 # flag handled in src/main.mk, not a C preprocessor flag.
63 USE_LINENOISE := 1
64
65 #### Extra arguments for linking the finished binary. Fossil needs
66 # to link against the Z-Lib compression library unless the miniz
67 # library in the source tree is being used. There are no other
68 # required dependencies.
@@ -63,10 +73,15 @@
73 # If using zlib:
74 LIB += $(ZLIB_LIB.$(FOSSIL_ENABLE_MINIZ)) $(LDFLAGS)
75
76 # If using HTTPS:
77 LIB += -lcrypto -lssl
78
79 # Many platforms put cos() needed by src/piechart.c in libm, rather than
80 # in libc. We cannot enable this by default because libm doesn't exist
81 # everywhere.
82 #LIB += -lm
83
84 #### Tcl shell for use in running the fossil testsuite. If you do not
85 # care about testing the end result, this can be blank.
86 #
87 TCLSH = tclsh
@@ -84,7 +99,9 @@
99 TCC.DragonFly += -DUSE_PREAD
100 TCC.FreeBSD += -DUSE_PREAD
101 TCC.NetBSD += -DUSE_PREAD
102 TCC.OpenBSD += -DUSE_PREAD
103 TCC += $(TCC.$(HOST_OS))
104
105 APPNAME = fossil$(E)
106
107 include $(SRCDIR)/main.mk
108
+5 -4
--- Makefile.in
+++ Makefile.in
@@ -34,27 +34,28 @@
3434
TCC = @CC@
3535
3636
#### Tcl shell for use in running the fossil testsuite. If you do not
3737
# care about testing the end result, this can be blank.
3838
#
39
-TCLSH = tclsh
39
+TCLSH = @TCLSH@
4040
4141
CFLAGS = @CFLAGS@
4242
LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
43
-BCCFLAGS = @CPPFLAGS@ @CFLAGS@
44
-TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H -DFOSSIL_ENABLE_LEGACY_MV_RM=1
43
+BCCFLAGS = @CPPFLAGS@ $(CFLAGS)
44
+TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
4545
INSTALLDIR = $(DESTDIR)@prefix@/bin
4646
USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
4747
USE_LINENOISE = @USE_LINENOISE@
4848
USE_MMAN_H = @USE_MMAN_H@
4949
USE_SEE = @USE_SEE@
5050
FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
51
+APPNAME = fossil
5152
5253
include $(SRCDIR)/main.mk
5354
5455
distclean: clean
55
- rm -f autoconfig.h config.log Makefile
56
+ -rm -f autoconfig.h config.log Makefile
5657
5758
reconfig:
5859
@AUTOREMAKE@
5960
6061
# Automatically reconfigure whenever an autosetup file or one of the
6162
--- Makefile.in
+++ Makefile.in
@@ -34,27 +34,28 @@
34 TCC = @CC@
35
36 #### Tcl shell for use in running the fossil testsuite. If you do not
37 # care about testing the end result, this can be blank.
38 #
39 TCLSH = tclsh
40
41 CFLAGS = @CFLAGS@
42 LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
43 BCCFLAGS = @CPPFLAGS@ @CFLAGS@
44 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H -DFOSSIL_ENABLE_LEGACY_MV_RM=1
45 INSTALLDIR = $(DESTDIR)@prefix@/bin
46 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
47 USE_LINENOISE = @USE_LINENOISE@
48 USE_MMAN_H = @USE_MMAN_H@
49 USE_SEE = @USE_SEE@
50 FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
 
51
52 include $(SRCDIR)/main.mk
53
54 distclean: clean
55 rm -f autoconfig.h config.log Makefile
56
57 reconfig:
58 @AUTOREMAKE@
59
60 # Automatically reconfigure whenever an autosetup file or one of the
61
--- Makefile.in
+++ Makefile.in
@@ -34,27 +34,28 @@
34 TCC = @CC@
35
36 #### Tcl shell for use in running the fossil testsuite. If you do not
37 # care about testing the end result, this can be blank.
38 #
39 TCLSH = @TCLSH@
40
41 CFLAGS = @CFLAGS@
42 LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
43 BCCFLAGS = @CPPFLAGS@ $(CFLAGS)
44 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
45 INSTALLDIR = $(DESTDIR)@prefix@/bin
46 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
47 USE_LINENOISE = @USE_LINENOISE@
48 USE_MMAN_H = @USE_MMAN_H@
49 USE_SEE = @USE_SEE@
50 FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
51 APPNAME = fossil
52
53 include $(SRCDIR)/main.mk
54
55 distclean: clean
56 -rm -f autoconfig.h config.log Makefile
57
58 reconfig:
59 @AUTOREMAKE@
60
61 # Automatically reconfigure whenever an autosetup file or one of the
62
--- Makefile.osx-jaguar
+++ Makefile.osx-jaguar
@@ -33,17 +33,19 @@
3333
# will run on the platform that is doing the build. This is used
3434
# to compile code-generator programs as part of the build process.
3535
# See TCC below for the C compiler for building the finished binary.
3636
#
3737
BCC = cc
38
+BCCFLAGS = $(CFLAGS)
3839
3940
#### The suffix to add to final executable file. When cross-compiling
4041
# to windows, make this ".exe". Otherwise leave it blank.
4142
#
42
-E =
43
+E =
4344
4445
TCC = cc
46
+TCCFLAGS = $(CFLAGS)
4547
4648
#### Tcl shell for use in running the fossil testsuite. If you do not
4749
# care about testing the end result, this can be blank.
4850
#
4951
TCLSH = tclsh
@@ -57,15 +59,15 @@
5759
TCC += -DWITHOUT_ICONV
5860
TCC += -Dsocklen_t=int
5961
TCC += -DSQLITE_MAX_MMAP_SIZE=0
6062
TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
6163
INSTALLDIR = $(DESTDIR)/usr/local/bin
62
-USE_SYSTEM_SQLITE =
64
+USE_SYSTEM_SQLITE =
6365
USE_LINENOISE = 1
6466
# FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
6567
FOSSIL_ENABLE_TCL = 0
6668
FOSSIL_ENABLE_MINIZ = 0
6769
6870
include $(SRCDIR)/main.mk
6971
7072
distclean: clean
7173
rm -f autoconfig.h config.log Makefile
7274
7375
ADDED README.md
--- Makefile.osx-jaguar
+++ Makefile.osx-jaguar
@@ -33,17 +33,19 @@
33 # will run on the platform that is doing the build. This is used
34 # to compile code-generator programs as part of the build process.
35 # See TCC below for the C compiler for building the finished binary.
36 #
37 BCC = cc
 
38
39 #### The suffix to add to final executable file. When cross-compiling
40 # to windows, make this ".exe". Otherwise leave it blank.
41 #
42 E =
43
44 TCC = cc
 
45
46 #### Tcl shell for use in running the fossil testsuite. If you do not
47 # care about testing the end result, this can be blank.
48 #
49 TCLSH = tclsh
@@ -57,15 +59,15 @@
57 TCC += -DWITHOUT_ICONV
58 TCC += -Dsocklen_t=int
59 TCC += -DSQLITE_MAX_MMAP_SIZE=0
60 TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
61 INSTALLDIR = $(DESTDIR)/usr/local/bin
62 USE_SYSTEM_SQLITE =
63 USE_LINENOISE = 1
64 # FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
65 FOSSIL_ENABLE_TCL = 0
66 FOSSIL_ENABLE_MINIZ = 0
67
68 include $(SRCDIR)/main.mk
69
70 distclean: clean
71 rm -f autoconfig.h config.log Makefile
72
73 DDED README.md
--- Makefile.osx-jaguar
+++ Makefile.osx-jaguar
@@ -33,17 +33,19 @@
33 # will run on the platform that is doing the build. This is used
34 # to compile code-generator programs as part of the build process.
35 # See TCC below for the C compiler for building the finished binary.
36 #
37 BCC = cc
38 BCCFLAGS = $(CFLAGS)
39
40 #### The suffix to add to final executable file. When cross-compiling
41 # to windows, make this ".exe". Otherwise leave it blank.
42 #
43 E =
44
45 TCC = cc
46 TCCFLAGS = $(CFLAGS)
47
48 #### Tcl shell for use in running the fossil testsuite. If you do not
49 # care about testing the end result, this can be blank.
50 #
51 TCLSH = tclsh
@@ -57,15 +59,15 @@
59 TCC += -DWITHOUT_ICONV
60 TCC += -Dsocklen_t=int
61 TCC += -DSQLITE_MAX_MMAP_SIZE=0
62 TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
63 INSTALLDIR = $(DESTDIR)/usr/local/bin
64 USE_SYSTEM_SQLITE =
65 USE_LINENOISE = 1
66 # FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
67 FOSSIL_ENABLE_TCL = 0
68 FOSSIL_ENABLE_MINIZ = 0
69
70 include $(SRCDIR)/main.mk
71
72 distclean: clean
73 rm -f autoconfig.h config.log Makefile
74
75 DDED README.md
+15
--- a/README.md
+++ b/README.md
@@ -0,0 +1,15 @@
1
+# About Fossil
2
+
3
+Fossil is a distributed version control system that has been widely
4
+used since 2007. Fossil was originally designed to support the
5
+[SQLite](https://sqlite.org) project but has been adopted by many other
6
+projects as well.
7
+
8
+Fossil is self-hosting at <https://fossil-scm.org>.
9
+
10
+If you are reading this on GitHub, then you are looking at a Git mirror
11
+of the self-hosting Fossil repository. The purpose of that mirror is to
12
+test and exercise Fossil's ability to export a Git mirror. Nobody much
13
+uses the GitHub mirror, except to verify that the mirror logic works. If
14
+you want to know more about Fossil, visit the official self-hosting site
15
+linked above.
--- a/README.md
+++ b/README.md
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/README.md
+++ b/README.md
@@ -0,0 +1,15 @@
1 # About Fossil
2
3 Fossil is a distributed version control system that has been widely
4 used since 2007. Fossil was originally designed to support the
5 [SQLite](https://sqlite.org) project but has been adopted by many other
6 projects as well.
7
8 Fossil is self-hosting at <https://fossil-scm.org>.
9
10 If you are reading this on GitHub, then you are looking at a Git mirror
11 of the self-hosting Fossil repository. The purpose of that mirror is to
12 test and exercise Fossil's ability to export a Git mirror. Nobody much
13 uses the GitHub mirror, except to verify that the mirror logic works. If
14 you want to know more about Fossil, visit the official self-hosting site
15 linked above.
+1 -1
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1
-2.6
1
+2.11
22
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 2.6
2
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 2.11
2
+110 -12
--- auto.def
+++ auto.def
@@ -9,10 +9,11 @@
99
with-zlib:path|auto|tree
1010
=> {Look for zlib in the given path, automatically, or in the source tree}
1111
with-exec-rel-paths=0
1212
=> {Enable relative paths for external diff/gdiff}
1313
with-legacy-mv-rm=1 => {Enable legacy behavior for mv/rm (skip checkout files)}
14
+ with-sanitizer: => {Build with C compiler's -fsanitize=LIST; e.g. address,enum,null,undefined}
1415
with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
1516
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
1617
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
1718
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
1819
with-tcl-private-stubs=0
@@ -33,12 +34,47 @@
3334
}
3435
3536
# Use pread/pwrite system calls in place of seek + read/write if possible
3637
define USE_PREAD [cc-check-functions pread]
3738
38
-# Find tclsh for the test suite. Can't yet use jimsh for this.
39
+# Find tclsh for the test suite.
40
+#
41
+# We can't use jimsh for this: the test suite uses features of Tcl that
42
+# Jim doesn't support, either statically or due to the way it's built by
43
+# autosetup. For example, Jim supports `file normalize`, but only if
44
+# you build it with HAVE_REALPATH, which won't ever be defined in this
45
+# context because autosetup doesn't try to discover platform-specific
46
+# details like that before it decides to build jimsh0. Besides which,
47
+# autosetup won't build jimsh0 at all if it can find tclsh itself.
48
+# Ironically, this means we may right now be running under either jimsh0
49
+# or a version of tclsh that we find unsuitable below!
3950
cc-check-progs tclsh
51
+set hbtd /usr/local/Cellar/tcl-tk
52
+if {[string equal false [get-define TCLSH]]} {
53
+ msg-result "WARNING: 'make test' will not run here."
54
+} else {
55
+ set v [exec /bin/sh -c "echo 'puts \$tcl_version' | tclsh"]
56
+ if {[expr {$v >= 8.6}]} {
57
+ msg-result "Found Tclsh version $v in the PATH."
58
+ define TCLSH tclsh
59
+ } elseif {[file isdirectory $hbtd]} {
60
+ # This is a macOS system with the Homebrew version of Tcl/Tk
61
+ # installed. Select the newest version. It won't normally be
62
+ # in the PATH to avoid shadowing /usr/bin/tclsh, and even if it
63
+ # were in the PATH, it's bad practice to put /usr/local/bin (the
64
+ # Homebrew default) ahead of /usr/bin, especially given that
65
+ # it's user-writeable by default with Homebrew. Thus, we can be
66
+ # pretty sure the only way to call it is with an absolute path.
67
+ set v [exec ls -tr $hbtd | tail -1]
68
+ set path "$hbtd/$v/bin/tclsh"
69
+ define TCLSH $path
70
+ msg-result "Using Homebrew Tcl/Tk version $path."
71
+ } else {
72
+ msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
73
+ define TCLSH false ;# force "make test" failure via /usr/bin/false
74
+ }
75
+}
4076
4177
define EXTRA_CFLAGS "-Wall"
4278
define EXTRA_LDFLAGS ""
4379
define USE_SYSTEM_SQLITE 0
4480
define USE_LINENOISE 0
@@ -81,29 +117,25 @@
81117
}
82118
return $found
83119
}
84120
85121
if {![opt-bool internal-sqlite]} {
86
- proc find_internal_sqlite {} {
122
+ proc find_system_sqlite {} {
87123
88124
# On some systems (slackware), libsqlite3 requires -ldl to link. So
89125
# search for the system SQLite once with -ldl, and once without. If
90126
# the library can only be found with $extralibs set to -ldl, then
91127
# the code below will append -ldl to LIBS.
92128
#
93129
foreach extralibs {{} {-ldl}} {
94130
95131
# Locate the system SQLite by searching for sqlite3_open(). Then check
96
- # if sqlite3_keyword_check() can be found as well. If we can find open() but
97
- # not keyword_check(), then the system SQLite is too old to link against
132
+ # if sqlite3_stmt_isexplain can be found as well. If we can find open() but
133
+ # not stmt_isexplain(), then the system SQLite is too old to link against
98134
# fossil.
99135
#
100136
if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
101
- if {![check-function-in-lib sqlite3_keyword_check sqlite3 $extralibs]} {
102
- user-error "system sqlite3 too old (require >= 3.24.0)"
103
- }
104
-
105137
# Success. Update symbols and return.
106138
#
107139
define USE_SYSTEM_SQLITE 1
108140
define-append LIBS -lsqlite3
109141
define-append LIBS $extralibs
@@ -111,11 +143,44 @@
111143
}
112144
}
113145
user-error "system sqlite3 not found"
114146
}
115147
116
- find_internal_sqlite
148
+ find_system_sqlite
149
+
150
+ proc test_system_sqlite {} {
151
+ # Check compatibility of the system SQLite library by running the sqlcompttest.c
152
+ # program in the source tree
153
+ #
154
+ set cmdline {}
155
+ lappend cmdline {*}[get-define CCACHE]
156
+ lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
157
+ lappend cmdline $::autosetup(dir)/../src/sqlcompattest.c -o conftest__
158
+ lappend cmdline {*}[get-define LDFLAGS]
159
+ lappend cmdline {*}[get-define LIBS]
160
+ set ok 1
161
+ set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
162
+ if {$err} {
163
+ configlog "Failed: [join $cmdline]"
164
+ if {[string length $result]>0} {configlog $result}
165
+ configlog "============"
166
+ set ok 0
167
+ } elseif {$::autosetup(debug)} {
168
+ configlog "Compiled OK: [join $cmdline]"
169
+ configlog "============"
170
+ }
171
+ if {!$ok} {
172
+ user-error "unable to compile SQLite compatibility test program"
173
+ }
174
+ set err [catch {exec-with-stderr ./conftest__} result errinfo]
175
+ if {$err} {
176
+ user-error $result
177
+ }
178
+ file delete ./conftest__
179
+ }
180
+ test_system_sqlite
181
+
117182
}
118183
119184
proc is_mingw {} {
120185
return [string match *mingw* [get-define host]]
121186
}
@@ -134,12 +199,12 @@
134199
if {[string match *-solaris* [get-define host]]} {
135200
define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__}
136201
}
137202
138203
if {[opt-bool fossil-debug]} {
139
- define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
140204
define CFLAGS {-g -O0 -Wall}
205
+ define-append CFLAGS -DFOSSIL_DEBUG
141206
msg-result "Debugging support enabled"
142207
}
143208
144209
if {[opt-bool no-opt]} {
145210
define CFLAGS {-g -O0 -Wall}
@@ -167,11 +232,11 @@
167232
define FOSSIL_ENABLE_JSON
168233
msg-result "JSON support enabled"
169234
}
170235
171236
if {[opt-bool with-legacy-mv-rm]} {
172
- define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM
237
+ define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM=1
173238
define FOSSIL_ENABLE_LEGACY_MV_RM
174239
msg-result "Legacy mv/rm support enabled"
175240
}
176241
177242
if {[opt-bool with-exec-rel-paths]} {
@@ -478,15 +543,34 @@
478543
# Last resort, may be Windows
479544
if {[is_mingw]} {
480545
define-append LIBS -lwsock32
481546
}
482547
}
483
-cc-check-function-in-lib ns_name_uncompress resolv
548
+
549
+# The SMTP module requires special libraries and headers for MX DNS
550
+# record lookups and such.
551
+cc-check-includes arpa/nameser.h
552
+cc-include-needs bind/resolv.h netinet/in.h
553
+cc-check-includes bind/resolv.h
554
+cc-check-includes resolv.h
555
+if { !(([cc-check-function-in-lib dn_expand resolv] ||
556
+ [cc-check-function-in-lib ns_name_uncompress {bind resolv}] ||
557
+ [cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) &&
558
+ ([cc-check-function-in-lib ns_parserr {bind resolv}] ||
559
+ [cc-check-function-in-lib __ns_parserr {bind resolv}]) &&
560
+ ([cc-check-function-in-lib res_query {bind resolv}] ||
561
+ [cc-check-function-in-lib __res_query {bind resolv}]))} {
562
+ msg-result "WARNING: SMTP feature will not be able to look up local MX."
563
+}
564
+cc-check-function-in-lib res_9_ns_initparse resolv
565
+
566
+# Other nonstandard function checks
484567
cc-check-functions utime
485568
cc-check-functions usleep
486569
cc-check-functions strchrnul
487570
cc-check-functions pledge
571
+cc-check-functions backtrace
488572
489573
# Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE
490574
if {![cc-check-functions getloadavg]} {
491575
define FOSSIL_OMIT_LOAD_AVERAGE 1
492576
msg-result "Load average support unavailable"
@@ -506,10 +590,24 @@
506590
define FOSSIL_HAVE_FUSEFS 1
507591
define-append LIBS -lfuse
508592
msg-result "FuseFS support enabled"
509593
}
510594
}
595
+
596
+# Add -fsanitize compile and link options late: we don't want the C
597
+# checks above to run with those sanitizers enabled. It can not only
598
+# be pointless, it can actually break correct tests.
599
+set fsan [opt-val with-sanitizer]
600
+if {[string length $fsan]} {
601
+ define-append EXTRA_CFLAGS -fsanitize=$fsan
602
+ define-append EXTRA_LDFLAGS -fsanitize=$fsan
603
+ if {[string first "undefined" $fsan] != -1} {
604
+ # We need to link with libubsan if we're compiling under
605
+ # GCC with -fsanitize=undefined.
606
+ cc-check-function-in-lib __ubsan_handle_add_overflow ubsan
607
+ }
608
+}
511609
512610
# Finally, append -ldl to make sure it's the last in the list.
513611
# The library order matters in case of static linking.
514612
if {[check-function-in-lib dlopen dl]} {
515613
# Some platforms (*BSD) have the dl functions already in libc and no libdl.
516614
--- auto.def
+++ auto.def
@@ -9,10 +9,11 @@
9 with-zlib:path|auto|tree
10 => {Look for zlib in the given path, automatically, or in the source tree}
11 with-exec-rel-paths=0
12 => {Enable relative paths for external diff/gdiff}
13 with-legacy-mv-rm=1 => {Enable legacy behavior for mv/rm (skip checkout files)}
 
14 with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
15 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
16 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
17 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
18 with-tcl-private-stubs=0
@@ -33,12 +34,47 @@
33 }
34
35 # Use pread/pwrite system calls in place of seek + read/write if possible
36 define USE_PREAD [cc-check-functions pread]
37
38 # Find tclsh for the test suite. Can't yet use jimsh for this.
 
 
 
 
 
 
 
 
 
 
39 cc-check-progs tclsh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41 define EXTRA_CFLAGS "-Wall"
42 define EXTRA_LDFLAGS ""
43 define USE_SYSTEM_SQLITE 0
44 define USE_LINENOISE 0
@@ -81,29 +117,25 @@
81 }
82 return $found
83 }
84
85 if {![opt-bool internal-sqlite]} {
86 proc find_internal_sqlite {} {
87
88 # On some systems (slackware), libsqlite3 requires -ldl to link. So
89 # search for the system SQLite once with -ldl, and once without. If
90 # the library can only be found with $extralibs set to -ldl, then
91 # the code below will append -ldl to LIBS.
92 #
93 foreach extralibs {{} {-ldl}} {
94
95 # Locate the system SQLite by searching for sqlite3_open(). Then check
96 # if sqlite3_keyword_check() can be found as well. If we can find open() but
97 # not keyword_check(), then the system SQLite is too old to link against
98 # fossil.
99 #
100 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
101 if {![check-function-in-lib sqlite3_keyword_check sqlite3 $extralibs]} {
102 user-error "system sqlite3 too old (require >= 3.24.0)"
103 }
104
105 # Success. Update symbols and return.
106 #
107 define USE_SYSTEM_SQLITE 1
108 define-append LIBS -lsqlite3
109 define-append LIBS $extralibs
@@ -111,11 +143,44 @@
111 }
112 }
113 user-error "system sqlite3 not found"
114 }
115
116 find_internal_sqlite
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117 }
118
119 proc is_mingw {} {
120 return [string match *mingw* [get-define host]]
121 }
@@ -134,12 +199,12 @@
134 if {[string match *-solaris* [get-define host]]} {
135 define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__}
136 }
137
138 if {[opt-bool fossil-debug]} {
139 define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
140 define CFLAGS {-g -O0 -Wall}
 
141 msg-result "Debugging support enabled"
142 }
143
144 if {[opt-bool no-opt]} {
145 define CFLAGS {-g -O0 -Wall}
@@ -167,11 +232,11 @@
167 define FOSSIL_ENABLE_JSON
168 msg-result "JSON support enabled"
169 }
170
171 if {[opt-bool with-legacy-mv-rm]} {
172 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM
173 define FOSSIL_ENABLE_LEGACY_MV_RM
174 msg-result "Legacy mv/rm support enabled"
175 }
176
177 if {[opt-bool with-exec-rel-paths]} {
@@ -478,15 +543,34 @@
478 # Last resort, may be Windows
479 if {[is_mingw]} {
480 define-append LIBS -lwsock32
481 }
482 }
483 cc-check-function-in-lib ns_name_uncompress resolv
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484 cc-check-functions utime
485 cc-check-functions usleep
486 cc-check-functions strchrnul
487 cc-check-functions pledge
 
488
489 # Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE
490 if {![cc-check-functions getloadavg]} {
491 define FOSSIL_OMIT_LOAD_AVERAGE 1
492 msg-result "Load average support unavailable"
@@ -506,10 +590,24 @@
506 define FOSSIL_HAVE_FUSEFS 1
507 define-append LIBS -lfuse
508 msg-result "FuseFS support enabled"
509 }
510 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
512 # Finally, append -ldl to make sure it's the last in the list.
513 # The library order matters in case of static linking.
514 if {[check-function-in-lib dlopen dl]} {
515 # Some platforms (*BSD) have the dl functions already in libc and no libdl.
516
--- auto.def
+++ auto.def
@@ -9,10 +9,11 @@
9 with-zlib:path|auto|tree
10 => {Look for zlib in the given path, automatically, or in the source tree}
11 with-exec-rel-paths=0
12 => {Enable relative paths for external diff/gdiff}
13 with-legacy-mv-rm=1 => {Enable legacy behavior for mv/rm (skip checkout files)}
14 with-sanitizer: => {Build with C compiler's -fsanitize=LIST; e.g. address,enum,null,undefined}
15 with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
16 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
17 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
18 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
19 with-tcl-private-stubs=0
@@ -33,12 +34,47 @@
34 }
35
36 # Use pread/pwrite system calls in place of seek + read/write if possible
37 define USE_PREAD [cc-check-functions pread]
38
39 # Find tclsh for the test suite.
40 #
41 # We can't use jimsh for this: the test suite uses features of Tcl that
42 # Jim doesn't support, either statically or due to the way it's built by
43 # autosetup. For example, Jim supports `file normalize`, but only if
44 # you build it with HAVE_REALPATH, which won't ever be defined in this
45 # context because autosetup doesn't try to discover platform-specific
46 # details like that before it decides to build jimsh0. Besides which,
47 # autosetup won't build jimsh0 at all if it can find tclsh itself.
48 # Ironically, this means we may right now be running under either jimsh0
49 # or a version of tclsh that we find unsuitable below!
50 cc-check-progs tclsh
51 set hbtd /usr/local/Cellar/tcl-tk
52 if {[string equal false [get-define TCLSH]]} {
53 msg-result "WARNING: 'make test' will not run here."
54 } else {
55 set v [exec /bin/sh -c "echo 'puts \$tcl_version' | tclsh"]
56 if {[expr {$v >= 8.6}]} {
57 msg-result "Found Tclsh version $v in the PATH."
58 define TCLSH tclsh
59 } elseif {[file isdirectory $hbtd]} {
60 # This is a macOS system with the Homebrew version of Tcl/Tk
61 # installed. Select the newest version. It won't normally be
62 # in the PATH to avoid shadowing /usr/bin/tclsh, and even if it
63 # were in the PATH, it's bad practice to put /usr/local/bin (the
64 # Homebrew default) ahead of /usr/bin, especially given that
65 # it's user-writeable by default with Homebrew. Thus, we can be
66 # pretty sure the only way to call it is with an absolute path.
67 set v [exec ls -tr $hbtd | tail -1]
68 set path "$hbtd/$v/bin/tclsh"
69 define TCLSH $path
70 msg-result "Using Homebrew Tcl/Tk version $path."
71 } else {
72 msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
73 define TCLSH false ;# force "make test" failure via /usr/bin/false
74 }
75 }
76
77 define EXTRA_CFLAGS "-Wall"
78 define EXTRA_LDFLAGS ""
79 define USE_SYSTEM_SQLITE 0
80 define USE_LINENOISE 0
@@ -81,29 +117,25 @@
117 }
118 return $found
119 }
120
121 if {![opt-bool internal-sqlite]} {
122 proc find_system_sqlite {} {
123
124 # On some systems (slackware), libsqlite3 requires -ldl to link. So
125 # search for the system SQLite once with -ldl, and once without. If
126 # the library can only be found with $extralibs set to -ldl, then
127 # the code below will append -ldl to LIBS.
128 #
129 foreach extralibs {{} {-ldl}} {
130
131 # Locate the system SQLite by searching for sqlite3_open(). Then check
132 # if sqlite3_stmt_isexplain can be found as well. If we can find open() but
133 # not stmt_isexplain(), then the system SQLite is too old to link against
134 # fossil.
135 #
136 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
 
 
 
 
137 # Success. Update symbols and return.
138 #
139 define USE_SYSTEM_SQLITE 1
140 define-append LIBS -lsqlite3
141 define-append LIBS $extralibs
@@ -111,11 +143,44 @@
143 }
144 }
145 user-error "system sqlite3 not found"
146 }
147
148 find_system_sqlite
149
150 proc test_system_sqlite {} {
151 # Check compatibility of the system SQLite library by running the sqlcompttest.c
152 # program in the source tree
153 #
154 set cmdline {}
155 lappend cmdline {*}[get-define CCACHE]
156 lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
157 lappend cmdline $::autosetup(dir)/../src/sqlcompattest.c -o conftest__
158 lappend cmdline {*}[get-define LDFLAGS]
159 lappend cmdline {*}[get-define LIBS]
160 set ok 1
161 set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
162 if {$err} {
163 configlog "Failed: [join $cmdline]"
164 if {[string length $result]>0} {configlog $result}
165 configlog "============"
166 set ok 0
167 } elseif {$::autosetup(debug)} {
168 configlog "Compiled OK: [join $cmdline]"
169 configlog "============"
170 }
171 if {!$ok} {
172 user-error "unable to compile SQLite compatibility test program"
173 }
174 set err [catch {exec-with-stderr ./conftest__} result errinfo]
175 if {$err} {
176 user-error $result
177 }
178 file delete ./conftest__
179 }
180 test_system_sqlite
181
182 }
183
184 proc is_mingw {} {
185 return [string match *mingw* [get-define host]]
186 }
@@ -134,12 +199,12 @@
199 if {[string match *-solaris* [get-define host]]} {
200 define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__}
201 }
202
203 if {[opt-bool fossil-debug]} {
 
204 define CFLAGS {-g -O0 -Wall}
205 define-append CFLAGS -DFOSSIL_DEBUG
206 msg-result "Debugging support enabled"
207 }
208
209 if {[opt-bool no-opt]} {
210 define CFLAGS {-g -O0 -Wall}
@@ -167,11 +232,11 @@
232 define FOSSIL_ENABLE_JSON
233 msg-result "JSON support enabled"
234 }
235
236 if {[opt-bool with-legacy-mv-rm]} {
237 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM=1
238 define FOSSIL_ENABLE_LEGACY_MV_RM
239 msg-result "Legacy mv/rm support enabled"
240 }
241
242 if {[opt-bool with-exec-rel-paths]} {
@@ -478,15 +543,34 @@
543 # Last resort, may be Windows
544 if {[is_mingw]} {
545 define-append LIBS -lwsock32
546 }
547 }
548
549 # The SMTP module requires special libraries and headers for MX DNS
550 # record lookups and such.
551 cc-check-includes arpa/nameser.h
552 cc-include-needs bind/resolv.h netinet/in.h
553 cc-check-includes bind/resolv.h
554 cc-check-includes resolv.h
555 if { !(([cc-check-function-in-lib dn_expand resolv] ||
556 [cc-check-function-in-lib ns_name_uncompress {bind resolv}] ||
557 [cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) &&
558 ([cc-check-function-in-lib ns_parserr {bind resolv}] ||
559 [cc-check-function-in-lib __ns_parserr {bind resolv}]) &&
560 ([cc-check-function-in-lib res_query {bind resolv}] ||
561 [cc-check-function-in-lib __res_query {bind resolv}]))} {
562 msg-result "WARNING: SMTP feature will not be able to look up local MX."
563 }
564 cc-check-function-in-lib res_9_ns_initparse resolv
565
566 # Other nonstandard function checks
567 cc-check-functions utime
568 cc-check-functions usleep
569 cc-check-functions strchrnul
570 cc-check-functions pledge
571 cc-check-functions backtrace
572
573 # Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE
574 if {![cc-check-functions getloadavg]} {
575 define FOSSIL_OMIT_LOAD_AVERAGE 1
576 msg-result "Load average support unavailable"
@@ -506,10 +590,24 @@
590 define FOSSIL_HAVE_FUSEFS 1
591 define-append LIBS -lfuse
592 msg-result "FuseFS support enabled"
593 }
594 }
595
596 # Add -fsanitize compile and link options late: we don't want the C
597 # checks above to run with those sanitizers enabled. It can not only
598 # be pointless, it can actually break correct tests.
599 set fsan [opt-val with-sanitizer]
600 if {[string length $fsan]} {
601 define-append EXTRA_CFLAGS -fsanitize=$fsan
602 define-append EXTRA_LDFLAGS -fsanitize=$fsan
603 if {[string first "undefined" $fsan] != -1} {
604 # We need to link with libubsan if we're compiling under
605 # GCC with -fsanitize=undefined.
606 cc-check-function-in-lib __ubsan_handle_add_overflow ubsan
607 }
608 }
609
610 # Finally, append -ldl to make sure it's the last in the list.
611 # The library order matters in case of static linking.
612 if {[check-function-in-lib dlopen dl]} {
613 # Some platforms (*BSD) have the dl functions already in libc and no libdl.
614
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1
-This is autosetup v0.6.6. See http://msteveb.github.com/autosetup/
1
+README.autosetup created by autosetup v0.6.9
2
+
3
+This is the autosetup directory for a local install of autosetup.
4
+It contains autosetup, support files and loadable modules.
5
+
6
+*.tcl files in this directory are optional modules which
7
+can be loaded with the 'use' directive.
8
+
9
+*.auto files in this directory are auto-loaded.
10
+
11
+For more information, see http://msteveb.github.com/autosetup/
212
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1 This is autosetup v0.6.6. See http://msteveb.github.com/autosetup/
 
 
 
 
 
 
 
 
 
 
2
--- autosetup/README.autosetup
+++ autosetup/README.autosetup
@@ -1,1 +1,11 @@
1 README.autosetup created by autosetup v0.6.9
2
3 This is the autosetup directory for a local install of autosetup.
4 It contains autosetup, support files and loadable modules.
5
6 *.tcl files in this directory are optional modules which
7 can be loaded with the 'use' directive.
8
9 *.auto files in this directory are auto-loaded.
10
11 For more information, see http://msteveb.github.com/autosetup/
12
+709 -235
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,17 @@
11
#!/bin/sh
22
# Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
33
# All rights reserved
44
# vim:se syntax=tcl:
55
# \
6
-dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@"
6
+dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
77
8
-set autosetup(version) 0.6.6
8
+# Note that the version has a trailing + on unreleased versions
9
+set autosetup(version) 0.6.9
910
1011
# Can be set to 1 to debug early-init problems
11
-set autosetup(debug) 0
12
+set autosetup(debug) [expr {"--debug" in $argv}]
1213
1314
##################################################################
1415
#
1516
# Main flow of control, option handling
1617
#
@@ -72,14 +73,18 @@
7273
set autosetup(cmdline) {}
7374
# options is a list of known options
7475
set autosetup(options) {}
7576
# optset is a dictionary of option values set by the user based on getopt
7677
set autosetup(optset) {}
77
- # optdefault is a dictionary of default values for options
78
+ # optdefault is a dictionary of default values
7879
set autosetup(optdefault) {}
80
+ # options-defaults is a dictionary of overrides for default values for options
81
+ set autosetup(options-defaults) {}
7982
set autosetup(optionhelp) {}
8083
set autosetup(showhelp) 0
84
+
85
+ use util
8186
8287
# Parse options
8388
use getopt
8489
8590
# At the is point we don't know what is a valid option
@@ -87,15 +92,28 @@
8792
set autosetup(getopt) [getopt argv]
8893
8994
#"=Core Options:"
9095
options-add {
9196
help:=local => "display help and options. Optionally specify a module name, such as --help=system"
97
+ licence license => "display the autosetup license"
9298
version => "display the version of autosetup"
9399
ref:=text manual:=text
94100
reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
95101
debug => "display debugging output as autosetup runs"
96
- install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
102
+ install:=. => "install autosetup to the current or given directory"
103
+ }
104
+ if {$autosetup(installed)} {
105
+ # hidden options so we can produce a nice error
106
+ options-add {
107
+ sysinstall:path
108
+ }
109
+ } else {
110
+ options-add {
111
+ sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
112
+ }
113
+ }
114
+ options-add {
97115
force init:=help => "create initial auto.def, etc. Use --init=help for known types"
98116
# Undocumented options
99117
option-checking=1
100118
nopager
101119
quiet
@@ -107,12 +125,12 @@
107125
puts $autosetup(version)
108126
exit 0
109127
}
110128
111129
# autosetup --conf=alternate-auto.def
112
- if {[opt-val conf] ne ""} {
113
- set autosetup(autodef) [opt-val conf]
130
+ if {[opt-str conf o]} {
131
+ set autosetup(autodef) $o
114132
}
115133
116134
# Debugging output (set this early)
117135
incr autosetup(debug) [opt-bool debug]
118136
incr autosetup(force) [opt-bool force]
@@ -124,41 +142,50 @@
124142
if {[file exists $autosetup(libdir)/local.tcl]} {
125143
use local
126144
}
127145
128146
# Now any auto-load modules
129
- foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
130
- automf_load source $file
131
- }
147
+ autosetup_load_auto_modules
132148
133
- if {[opt-val help] ne ""} {
149
+ if {[opt-str help o]} {
134150
incr autosetup(showhelp)
135151
use help
136
- autosetup_help [opt-val help]
152
+ autosetup_help $o
137153
}
138154
139
- if {[opt-val {manual ref reference}] ne ""} {
155
+ if {[opt-bool licence license]} {
156
+ use help
157
+ autosetup_show_license
158
+ exit 0
159
+ }
160
+
161
+ if {[opt-str {manual ref reference} o]} {
140162
use help
141
- autosetup_reference [opt-val {manual ref reference}]
163
+ autosetup_reference $o
142164
}
143165
144166
# Allow combining --install and --init
145167
set earlyexit 0
146
- if {[opt-val install] ne ""} {
168
+ if {[opt-str install o]} {
147169
use install
148
- autosetup_install [opt-val install]
170
+ autosetup_install $o
149171
incr earlyexit
150172
}
151173
152
- if {[opt-val init] ne ""} {
174
+ if {[opt-str init o]} {
153175
use init
154
- autosetup_init [opt-val init]
176
+ autosetup_init $o
155177
incr earlyexit
156178
}
157179
158180
if {$earlyexit} {
159181
exit 0
182
+ }
183
+ if {[opt-str sysinstall o]} {
184
+ use install
185
+ autosetup_install $o 1
186
+ exit 0
160187
}
161188
162189
if {![file exists $autosetup(autodef)]} {
163190
# Check for invalid option first
164191
options {}
@@ -185,10 +212,11 @@
185212
define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
186213
187214
188215
# Log how we were invoked
189216
configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
217
+ configlog "Tclsh: [info nameofexecutable]"
190218
191219
# Note that auto.def is *not* loaded in the global scope
192220
source $autosetup(autodef)
193221
194222
# Could warn here if options {} was not specified
@@ -210,14 +238,14 @@
210238
#
211239
# Check each of the named, boolean options and if any have been explicitly enabled
212240
# or disabled by the user, return 1 or 0 accordingly.
213241
#
214242
# If the option was specified more than once, the last value wins.
215
-# e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
243
+# e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
216244
#
217245
# If no value was specified by the user, returns the default value for the
218
-# first option. If -nodefault is given, this behaviour changes and
246
+# first option. If '-nodefault' is given, this behaviour changes and
219247
# -1 is returned instead.
220248
#
221249
proc opt-bool {args} {
222250
set nodefault 0
223251
if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +265,19 @@
237265
}
238266
# Default value is the default for the first option
239267
return [dict get $::autosetup(optdefault) [lindex $args 0]]
240268
}
241269
242
-# @opt-val option-list ?default=""?
270
+# @opt-val optionlist ?default=""?
243271
#
244
-# Returns a list containing all the values given for the non-boolean options in 'option-list'.
272
+# Returns a list containing all the values given for the non-boolean options in '$optionlist'.
245273
# There will be one entry in the list for each option given by the user, including if the
246274
# same option was used multiple times.
247
-# If only a single value is required, use something like:
248275
#
249
-## lindex [opt-val $names] end
276
+# If no options were set, '$default' is returned (exactly, not as a list).
250277
#
251
-# If no options were set, $default is returned (exactly, not as a list).
278
+# Note: For most use cases, 'opt-str' should be preferred.
252279
#
253280
proc opt-val {names {default ""}} {
254281
option-check-names {*}$names
255282
256283
foreach opt $names {
@@ -261,10 +288,83 @@
261288
if {[info exists result]} {
262289
return $result
263290
}
264291
return $default
265292
}
293
+
294
+# @opt-str optionlist varname ?default?
295
+#
296
+# Sets '$varname' in the callers scope to the value for one of the given options.
297
+#
298
+# For the list of options given in '$optionlist', if any value is set for any option,
299
+# the option value is taken to be the *last* value of the last option (in the order given).
300
+#
301
+# If no option was given, and a default was specified with 'options-defaults',
302
+# that value is used.
303
+#
304
+# If no 'options-defaults' value was given and '$default' was given, it is used.
305
+#
306
+# If none of the above provided a value, no value is set.
307
+#
308
+# The return value depends on whether '$default' was specified.
309
+# If it was, the option value is returned.
310
+# If it was not, 1 is returns if a value was set, or 0 if not.
311
+#
312
+# Typical usage is as follows:
313
+#
314
+## if {[opt-str {myopt altname} o]} {
315
+## do something with $o
316
+## }
317
+#
318
+# Or:
319
+## define myname [opt-str {myopt altname} o "/usr/local"]
320
+#
321
+proc opt-str {names varname args} {
322
+ global autosetup
323
+
324
+ option-check-names {*}$names
325
+ upvar $varname value
326
+
327
+ if {[llength $args]} {
328
+ # A default was given, so always return the string value of the option
329
+ set default [lindex $args 0]
330
+ set retopt 1
331
+ } else {
332
+ # No default, so return 0 or 1 to indicate if a value was found
333
+ set retopt 0
334
+ }
335
+
336
+ foreach opt $names {
337
+ if {[dict exists $::autosetup(optset) $opt]} {
338
+ set result [lindex [dict get $::autosetup(optset) $opt] end]
339
+ }
340
+ }
341
+
342
+ if {![info exists result]} {
343
+ # No user-specified value. Has options-defaults been set?
344
+ foreach opt $names {
345
+ if {[dict exists $::autosetup(options-defaults) $opt]} {
346
+ set result [dict get $autosetup(options-defaults) $opt]
347
+ }
348
+ }
349
+ }
350
+
351
+ if {[info exists result]} {
352
+ set value $result
353
+ if {$retopt} {
354
+ return $value
355
+ }
356
+ return 1
357
+ }
358
+
359
+ if {$retopt} {
360
+ set value $default
361
+ return $value
362
+ }
363
+
364
+ return 0
365
+}
266366
267367
proc option-check-names {args} {
268368
foreach o $args {
269369
if {$o ni $::autosetup(options)} {
270370
autosetup-error "Request for undeclared option --$o"
@@ -293,10 +393,11 @@
293393
# This is a special heading
294394
lappend autosetup(optionhelp) $opt ""
295395
set header {}
296396
continue
297397
}
398
+ unset -nocomplain defaultvalue equal value
298399
299400
#puts "i=$i, opt=$opt"
300401
regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
301402
if {$name in $autosetup(options)} {
302403
autosetup-error "Option $name already specified"
@@ -310,10 +411,16 @@
310411
# This is a documentation-only option, like "-C <dir>"
311412
set opthelp $opt
312413
} elseif {$colon eq ""} {
313414
# Boolean option
314415
lappend autosetup(options) $name
416
+
417
+ # Check for override
418
+ if {[dict exists $autosetup(options-defaults) $name]} {
419
+ # A default was specified with options-defaults, so use it
420
+ set value [dict get $autosetup(options-defaults) $name]
421
+ }
315422
316423
if {$value eq "1"} {
317424
set opthelp "--disable-$name"
318425
} else {
319426
set opthelp "--$name"
@@ -321,11 +428,12 @@
321428
322429
# Set the default
323430
if {$value eq ""} {
324431
set value 0
325432
}
326
- dict set autosetup(optdefault) $name $value
433
+ set defaultvalue $value
434
+ dict set autosetup(optdefault) $name $defaultvalue
327435
328436
if {[dict exists $autosetup(getopt) $name]} {
329437
# The option was specified by the user. Look at the last value.
330438
lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
331439
if {$type eq "str"} {
@@ -342,19 +450,39 @@
342450
#puts "Found boolean option --$name=$setvalue"
343451
}
344452
} else {
345453
# String option.
346454
lappend autosetup(options) $name
455
+
456
+ if {$colon eq ":"} {
457
+ # Was ":name=default" given?
458
+ # If so, set $value to the display name and $defaultvalue to the default
459
+ # (This is the preferred way to set a default value for a string option)
460
+ if {[regexp {^([^=]+)=(.*)$} $value -> value defaultvalue]} {
461
+ dict set autosetup(optdefault) $name $defaultvalue
462
+ }
463
+ }
464
+
465
+ # Maybe override the default value
466
+ if {[dict exists $autosetup(options-defaults) $name]} {
467
+ # A default was specified with options-defaults, so use it
468
+ set defaultvalue [dict get $autosetup(options-defaults) $name]
469
+ dict set autosetup(optdefault) $name $defaultvalue
470
+ } elseif {![info exists defaultvalue]} {
471
+ # For backward compatibility, if ":name" was given, use name as both
472
+ # the display text and the default value, but only if the user
473
+ # specified the option without the value
474
+ set defaultvalue $value
475
+ }
347476
348477
if {$equal eq "="} {
349478
# String option with optional value
350479
set opthelp "--$name?=$value?"
351480
} else {
352481
# String option with required value
353482
set opthelp "--$name=$value"
354483
}
355
- dict set autosetup(optdefault) $name $value
356484
357485
# Get the values specified by the user
358486
if {[dict exists $autosetup(getopt) $name]} {
359487
set listvalue {}
360488
@@ -363,11 +491,11 @@
363491
if {$type eq "bool" && $setvalue} {
364492
if {$equal ne "="} {
365493
user-error "Option --$name requires a value"
366494
}
367495
# If given as a boolean, use the default value
368
- set setvalue $value
496
+ set setvalue $defaultvalue
369497
}
370498
lappend listvalue $setvalue
371499
}
372500
373501
#puts "Found string option --$name=$listvalue"
@@ -376,10 +504,13 @@
376504
}
377505
378506
# Now create the help for this option if appropriate
379507
if {[lindex $opts $i+1] eq "=>"} {
380508
set desc [lindex $opts $i+2]
509
+ if {[info exists defaultvalue]} {
510
+ set desc [string map [list @default@ $defaultvalue] $desc]
511
+ }
381512
#string match \n* $desc
382513
if {$header ne ""} {
383514
lappend autosetup(optionhelp) $header ""
384515
set header ""
385516
}
@@ -463,35 +594,39 @@
463594
options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
464595
}
465596
}
466597
}
467598
468
-# @options options-spec
599
+# @options optionspec
469600
#
470601
# Specifies configuration-time options which may be selected by the user
471
-# and checked with opt-val and opt-bool. The format of options-spec follows.
602
+# and checked with 'opt-str' and 'opt-bool'. '$optionspec' contains a series
603
+# of options specifications separated by newlines, as follows:
472604
#
473605
# A boolean option is of the form:
474606
#
475607
## name[=0|1] => "Description of this boolean option"
476608
#
477
-# The default is name=0, meaning that the option is disabled by default.
478
-# If name=1 is used to make the option enabled by default, the description should reflect
609
+# The default is 'name=0', meaning that the option is disabled by default.
610
+# If 'name=1' is used to make the option enabled by default, the description should reflect
479611
# that with text like "Disable support for ...".
480612
#
481613
# An argument option (one which takes a parameter) is of the form:
482614
#
483615
## name:[=]value => "Description of this option"
484616
#
485
-# If the name:value form is used, the value must be provided with the option (as --name=myvalue).
486
-# If the name:=value form is used, the value is optional and the given value is used as the default
617
+# If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
618
+# If the 'name:=value' form is used, the value is optional and the given value is used as the default
487619
# if it is not provided.
488620
#
489
-# Undocumented options are also supported by omitting the "=> description.
490
-# These options are not displayed with --help and can be useful for internal options or as aliases.
621
+# The description may contain '@default@', in which case it will be replaced with the default
622
+# value for the option (taking into account defaults specified with 'options-defaults'.
491623
#
492
-# For example, --disable-lfs is an alias for --disable=largefile:
624
+# Undocumented options are also supported by omitting the '=> description'.
625
+# These options are not displayed with '--help' and can be useful for internal options or as aliases.
626
+#
627
+# For example, '--disable-lfs' is an alias for '--disable=largefile':
493628
#
494629
## lfs=1 largefile=1 => "Disable large file support"
495630
#
496631
proc options {optlist} {
497632
# Allow options as a list or args
@@ -509,27 +644,37 @@
509644
user-error "Unknown option --$o"
510645
}
511646
}
512647
}
513648
}
649
+
650
+# @options-defaults dictionary
651
+#
652
+# Specifies a dictionary of options and a new default value for each of those options.
653
+# Use before any 'use' statements in 'auto.def' to change the defaults for
654
+# subsequently included modules.
655
+proc options-defaults {dict} {
656
+ foreach {n v} $dict {
657
+ dict set ::autosetup(options-defaults) $n $v
658
+ }
659
+}
514660
515661
proc config_guess {} {
516
- if {[file-isexec $::autosetup(dir)/config.guess]} {
517
- exec-with-stderr sh $::autosetup(dir)/config.guess
518
- if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
662
+ if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
663
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
519664
user-error $alias
520665
}
521666
return $alias
522667
} else {
523
- configlog "No config.guess, so using uname"
668
+ configlog "No autosetup-config.guess, so using uname"
524669
string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
525670
}
526671
}
527672
528673
proc config_sub {alias} {
529
- if {[file-isexec $::autosetup(dir)/config.sub]} {
530
- if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
674
+ if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
675
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
531676
user-error $alias
532677
}
533678
}
534679
return $alias
535680
}
@@ -536,39 +681,48 @@
536681
537682
# @define name ?value=1?
538683
#
539684
# Defines the named variable to the given value.
540685
# These (name, value) pairs represent the results of the configuration check
541
-# and are available to be checked, modified and substituted.
686
+# and are available to be subsequently checked, modified and substituted.
542687
#
543688
proc define {name {value 1}} {
544689
set ::define($name) $value
545690
#dputs "$name <= $value"
546691
}
547692
548693
# @undefine name
549694
#
550
-# Undefine the named variable
695
+# Undefine the named variable.
551696
#
552697
proc undefine {name} {
553698
unset -nocomplain ::define($name)
554699
#dputs "$name <= <undef>"
555700
}
556701
557702
# @define-append name value ...
558703
#
559
-# Appends the given value(s) to the given 'defined' variable.
560
-# If the variable is not defined or empty, it is set to $value.
704
+# Appends the given value(s) to the given "defined" variable.
705
+# If the variable is not defined or empty, it is set to '$value'.
561706
# Otherwise the value is appended, separated by a space.
562707
# Any extra values are similarly appended.
563708
# If any value is already contained in the variable (as a substring) it is omitted.
564709
#
565710
proc define-append {name args} {
566711
if {[get-define $name ""] ne ""} {
567
- # Make a token attempt to avoid duplicates
712
+ # Avoid duplicates
568713
foreach arg $args {
569
- if {[string first $arg $::define($name)] == -1} {
714
+ if {$arg eq ""} {
715
+ continue
716
+ }
717
+ set found 0
718
+ foreach str [split $::define($name) " "] {
719
+ if {$str eq $arg} {
720
+ incr found
721
+ }
722
+ }
723
+ if {!$found} {
570724
append ::define($name) " " $arg
571725
}
572726
}
573727
} else {
574728
set ::define($name) [join $args]
@@ -576,11 +730,11 @@
576730
#dputs "$name += [join $args] => $::define($name)"
577731
}
578732
579733
# @get-define name ?default=0?
580734
#
581
-# Returns the current value of the 'defined' variable, or $default
735
+# Returns the current value of the "defined" variable, or '$default'
582736
# if not set.
583737
#
584738
proc get-define {name {default 0}} {
585739
if {[info exists ::define($name)]} {
586740
#dputs "$name => $::define($name)"
@@ -595,14 +749,26 @@
595749
# Returns 1 if the given variable is defined.
596750
#
597751
proc is-defined {name} {
598752
info exists ::define($name)
599753
}
754
+
755
+# @is-define-set name
756
+#
757
+# Returns 1 if the given variable is defined and is set
758
+# to a value other than "" or 0
759
+#
760
+proc is-define-set {name} {
761
+ if {[get-define $name] in {0 ""}} {
762
+ return 0
763
+ }
764
+ return 1
765
+}
600766
601767
# @all-defines
602768
#
603
-# Returns a dictionary (name value list) of all defined variables.
769
+# Returns a dictionary (name, value list) of all defined variables.
604770
#
605771
# This is suitable for use with 'dict', 'array set' or 'foreach'
606772
# and allows for arbitrary processing of the defined variables.
607773
#
608774
proc all-defines {} {
@@ -610,13 +776,13 @@
610776
}
611777
612778
613779
# @get-env name default
614780
#
615
-# If $name was specified on the command line, return it.
616
-# If $name was set in the environment, return it.
617
-# Otherwise return $default.
781
+# If '$name' was specified on the command line, return it.
782
+# Otherwise if '$name' was set in the environment, return it.
783
+# Otherwise return '$default'.
618784
#
619785
proc get-env {name default} {
620786
if {[dict exists $::autosetup(cmdline) $name]} {
621787
return [dict get $::autosetup(cmdline) $name]
622788
}
@@ -623,11 +789,11 @@
623789
getenv $name $default
624790
}
625791
626792
# @env-is-set name
627793
#
628
-# Returns 1 if the $name was specified on the command line or in the environment.
794
+# Returns 1 if '$name' was specified on the command line or in the environment.
629795
# Note that an empty environment variable is not considered to be set.
630796
#
631797
proc env-is-set {name} {
632798
if {[dict exists $::autosetup(cmdline) $name]} {
633799
return 1
@@ -639,11 +805,11 @@
639805
}
640806
641807
# @readfile filename ?default=""?
642808
#
643809
# Return the contents of the file, without the trailing newline.
644
-# If the file doesn't exist or can't be read, returns $default.
810
+# If the file doesn't exist or can't be read, returns '$default'.
645811
#
646812
proc readfile {filename {default_value ""}} {
647813
set result $default_value
648814
catch {
649815
set f [open $filename]
@@ -653,11 +819,11 @@
653819
return $result
654820
}
655821
656822
# @writefile filename value
657823
#
658
-# Creates the given file containing $value.
824
+# Creates the given file containing '$value'.
659825
# Does not add an extra newline.
660826
#
661827
proc writefile {filename value} {
662828
set f [open $filename w]
663829
puts -nonewline $f $value
@@ -677,63 +843,60 @@
677843
lappend args [quote-if-needed $arg]
678844
}
679845
join $args
680846
}
681847
682
-# @suffix suf list
683
-#
684
-# Takes a list and returns a new list with $suf appended
685
-# to each element
686
-#
687
-## suffix .c {a b c} => {a.c b.c c.c}
688
-#
689
-proc suffix {suf list} {
848
+# @list-non-empty list
849
+#
850
+# Returns a copy of the given list with empty elements removed
851
+proc list-non-empty {list} {
690852
set result {}
691853
foreach p $list {
692
- lappend result $p$suf
854
+ if {$p ne ""} {
855
+ lappend result $p
856
+ }
693857
}
694858
return $result
695859
}
696860
697
-# @prefix pre list
698
-#
699
-# Takes a list and returns a new list with $pre prepended
700
-# to each element
701
-#
702
-## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
703
-#
704
-proc prefix {pre list} {
705
- set result {}
706
- foreach p $list {
707
- lappend result $pre$p
708
- }
709
- return $result
861
+# @find-executable-path name
862
+#
863
+# Searches the path for an executable with the given name.
864
+# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
865
+# in which case the parameters are ignored.
866
+# The full path to the executable if found, or "" if not found.
867
+# Returns 1 if found, or 0 if not.
868
+#
869
+proc find-executable-path {name} {
870
+ # Ignore any parameters
871
+ set name [lindex $name 0]
872
+ # The empty string is never a valid executable
873
+ if {$name ne ""} {
874
+ foreach p [split-path] {
875
+ dputs "Looking for $name in $p"
876
+ set exec [file join $p $name]
877
+ if {[file-isexec $exec]} {
878
+ dputs "Found $name -> $exec"
879
+ return $exec
880
+ }
881
+ }
882
+ }
883
+ return {}
710884
}
711885
712886
# @find-executable name
713887
#
714888
# Searches the path for an executable with the given name.
715
-# Note that the name may include some parameters, e.g. "cc -mbig-endian",
889
+# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
716890
# in which case the parameters are ignored.
717891
# Returns 1 if found, or 0 if not.
718892
#
719893
proc find-executable {name} {
720
- # Ignore any parameters
721
- set name [lindex $name 0]
722
- if {$name eq ""} {
723
- # The empty string is never a valid executable
724
- return 0
725
- }
726
- foreach p [split-path] {
727
- dputs "Looking for $name in $p"
728
- set exec [file join $p $name]
729
- if {[file-isexec $exec]} {
730
- dputs "Found $name -> $exec"
731
- return 1
732
- }
733
- }
734
- return 0
894
+ if {[find-executable-path $name] eq {}} {
895
+ return 0
896
+ }
897
+ return 1
735898
}
736899
737900
# @find-an-executable ?-required? name ...
738901
#
739902
# Given a list of possible executable names,
@@ -764,11 +927,11 @@
764927
return ""
765928
}
766929
767930
# @configlog msg
768931
#
769
-# Writes the given message to the configuration log, config.log
932
+# Writes the given message to the configuration log, 'config.log'.
770933
#
771934
proc configlog {msg} {
772935
if {![info exists ::autosetup(logfh)]} {
773936
set ::autosetup(logfh) [open config.log w]
774937
}
@@ -800,12 +963,12 @@
800963
}
801964
}
802965
803966
# @msg-quiet command ...
804967
#
805
-# msg-quiet evaluates it's arguments as a command with output
806
-# from msg-checking and msg-result suppressed.
968
+# 'msg-quiet' evaluates it's arguments as a command with output
969
+# from 'msg-checking' and 'msg-result' suppressed.
807970
#
808971
# This is useful if a check needs to run a subcheck which isn't
809972
# of interest to the user.
810973
proc msg-quiet {args} {
811974
incr ::autosetup(msg-quiet)
@@ -841,11 +1004,11 @@
8411004
8421005
# @user-error msg
8431006
#
8441007
# Indicate incorrect usage to the user, including if required components
8451008
# or features are not found.
846
-# autosetup exits with a non-zero return code.
1009
+# 'autosetup' exits with a non-zero return code.
8471010
#
8481011
proc user-error {msg} {
8491012
show-notices
8501013
puts stderr "Error: $msg"
8511014
puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +1050,21 @@
8871050
proc maybe-show-timestamp {} {
8881051
if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
8891052
puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
8901053
}
8911054
}
1055
+
1056
+# @autosetup-require-version required
1057
+#
1058
+# Checks the current version of 'autosetup' against '$required'.
1059
+# A fatal error is generated if the current version is less than that required.
1060
+#
1061
+proc autosetup-require-version {required} {
1062
+ if {[compare-versions $::autosetup(version) $required] < 0} {
1063
+ user-error "autosetup version $required is required, but this is $::autosetup(version)"
1064
+ }
1065
+}
8921066
8931067
proc autosetup_version {} {
8941068
return "autosetup v$::autosetup(version)"
8951069
}
8961070
@@ -986,23 +1160,35 @@
9861160
# The latter form is useful for a complex module which requires additional
9871161
# support file. In this form, '$::usedir' is set to the module directory
9881162
# when it is loaded.
9891163
#
9901164
proc use {args} {
1165
+ global autosetup libmodule modsource
1166
+
1167
+ set dirs [list $autosetup(libdir)]
1168
+ if {[info exists autosetup(srcdir)]} {
1169
+ lappend dirs $autosetup(srcdir)/autosetup
1170
+ }
9911171
foreach m $args {
992
- if {[info exists ::libmodule($m)]} {
1172
+ if {[info exists libmodule($m)]} {
9931173
continue
9941174
}
995
- set ::libmodule($m) 1
996
- if {[info exists ::modsource($m)]} {
997
- automf_load eval $::modsource($m)
1175
+ set libmodule($m) 1
1176
+ if {[info exists modsource(${m}.tcl)]} {
1177
+ automf_load eval $modsource(${m}.tcl)
9981178
} else {
999
- set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
1179
+ set locs [list ${m}.tcl ${m}/init.tcl]
10001180
set found 0
1001
- foreach source $sources {
1002
- if {[file exists $source]} {
1003
- incr found
1181
+ foreach dir $dirs {
1182
+ foreach loc $locs {
1183
+ set source $dir/$loc
1184
+ if {[file exists $source]} {
1185
+ incr found
1186
+ break
1187
+ }
1188
+ }
1189
+ if {$found} {
10041190
break
10051191
}
10061192
}
10071193
if {$found} {
10081194
# For the convenience of the "use" source, point to the directory
@@ -1014,10 +1200,22 @@
10141200
autosetup-error "use: No such module: $m"
10151201
}
10161202
}
10171203
}
10181204
}
1205
+
1206
+proc autosetup_load_auto_modules {} {
1207
+ global autosetup modsource
1208
+ # First load any embedded auto modules
1209
+ foreach mod [array names modsource *.auto] {
1210
+ automf_load eval $modsource($mod)
1211
+ }
1212
+ # Now any external auto modules
1213
+ foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1214
+ automf_load source $file
1215
+ }
1216
+}
10191217
10201218
# Load module source in the global scope by executing the given command
10211219
proc automf_load {args} {
10221220
if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
10231221
autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1225,21 @@
10271225
# Initial settings
10281226
set autosetup(exe) $::argv0
10291227
set autosetup(istcl) 1
10301228
set autosetup(start) [clock millis]
10311229
set autosetup(installed) 0
1230
+set autosetup(sysinstall) 0
10321231
set autosetup(msg-checking) 0
10331232
set autosetup(msg-quiet) 0
1233
+set autosetup(inittypes) {}
10341234
10351235
# Embedded modules are inserted below here
10361236
set autosetup(installed) 1
1037
-# ----- module asciidoc-formatting -----
1237
+set autosetup(sysinstall) 0
1238
+# ----- @module asciidoc-formatting.tcl -----
10381239
1039
-set modsource(asciidoc-formatting) {
1240
+set modsource(asciidoc-formatting.tcl) {
10401241
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
10411242
# All rights reserved
10421243
10431244
# Module which provides text formatting
10441245
# asciidoc format
@@ -1102,19 +1303,19 @@
11021303
regsub -all "\n\n" $defn "\n ::\n" defn
11031304
puts $defn
11041305
}
11051306
}
11061307
1107
-# ----- module formatting -----
1308
+# ----- @module formatting.tcl -----
11081309
1109
-set modsource(formatting) {
1310
+set modsource(formatting.tcl) {
11101311
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
11111312
# All rights reserved
11121313
11131314
# Module which provides common text formatting
11141315
1115
-# This is designed for documenation which looks like:
1316
+# This is designed for documentation which looks like:
11161317
# code {...}
11171318
# or
11181319
# code {
11191320
# ...
11201321
# ...
@@ -1159,13 +1360,13 @@
11591360
# Return the result
11601361
return $lines
11611362
}
11621363
}
11631364
1164
-# ----- module getopt -----
1365
+# ----- @module getopt.tcl -----
11651366
1166
-set modsource(getopt) {
1367
+set modsource(getopt.tcl) {
11671368
# Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
11681369
# All rights reserved
11691370
11701371
# Simple getopt module
11711372
@@ -1197,11 +1398,11 @@
11971398
11981399
if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
11991400
# --name=value
12001401
dict lappend opts $name [list str $value]
12011402
} elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1202
- if {$prefix in {enable- with- ""}} {
1403
+ if {$prefix in {enable- ""}} {
12031404
set value 1
12041405
} else {
12051406
set value 0
12061407
}
12071408
dict lappend opts $name [list bool $value]
@@ -1218,13 +1419,13 @@
12181419
12191420
return $opts
12201421
}
12211422
}
12221423
1223
-# ----- module help -----
1424
+# ----- @module help.tcl -----
12241425
1225
-set modsource(help) {
1426
+set modsource(help.tcl) {
12261427
# Copyright (c) 2010 WorkWare Systems http://workware.net.au/
12271428
# All rights reserved
12281429
12291430
# Module which provides usage, help and the command reference
12301431
@@ -1251,10 +1452,28 @@
12511452
options-show
12521453
}
12531454
}
12541455
exit 0
12551456
}
1457
+
1458
+proc autosetup_show_license {} {
1459
+ global modsource autosetup
1460
+ use_pager
1461
+
1462
+ if {[info exists modsource(LICENSE)]} {
1463
+ puts $modsource(LICENSE)
1464
+ return
1465
+ }
1466
+ foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1467
+ set path [file join $dir LICENSE]
1468
+ if {[file exists $path]} {
1469
+ puts [readfile $path]
1470
+ return
1471
+ }
1472
+ }
1473
+ puts "LICENSE not found"
1474
+}
12561475
12571476
# If not already paged and stdout is a tty, pipe the output through the pager
12581477
# This is done by reinvoking autosetup with --nopager added
12591478
proc use_pager {} {
12601479
if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1523,16 @@
13041523
}
13051524
13061525
proc autosetup_output_block {type lines} {
13071526
if {[llength $lines]} {
13081527
switch $type {
1528
+ section {
1529
+ section $lines
1530
+ }
1531
+ subsection {
1532
+ subsection $lines
1533
+ }
13091534
code {
13101535
codelines $lines
13111536
}
13121537
p {
13131538
p [join $lines]
@@ -1325,30 +1550,45 @@
13251550
# Generate a command reference from inline documentation
13261551
proc automf_command_reference {} {
13271552
lappend files $::autosetup(prog)
13281553
lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
13291554
1330
- section "Core Commands"
1331
- set type p
1332
- set lines {}
1333
- set cmd {}
1555
+ # We want to process all non-module files before module files
1556
+ # and then modules in alphabetical order.
1557
+ # So examine all files and extract docs into doc($modulename) and doc(_core_)
1558
+ #
1559
+ # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1560
+ # and $data is a string for section, subsection or a list of text lines for other types.
1561
+
1562
+ # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1563
+
1564
+ set doc(_core_) {}
1565
+ lappend doc(_core_) [list section "Core Commands"]
13341566
13351567
foreach file $files {
1568
+ set modulename [file rootname [file tail $file]]
1569
+ set current _core_
13361570
set f [open $file]
13371571
while {![eof $f]} {
13381572
set line [gets $f]
1573
+
1574
+ # Find embedded module names
1575
+ if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1576
+ continue
1577
+ }
13391578
13401579
# Find lines starting with "# @*" and continuing through the remaining comment lines
13411580
if {![regexp {^# @(.*)} $line -> cmd]} {
13421581
continue
13431582
}
13441583
13451584
# Synopsis or command?
13461585
if {$cmd eq "synopsis:"} {
1347
- section "Module: [file rootname [file tail $file]]"
1586
+ set current $modulename
1587
+ lappend doc($current) [list section "Module: $modulename"]
13481588
} else {
1349
- subsection $cmd
1589
+ lappend doc($current) [list subsection $cmd]
13501590
}
13511591
13521592
set lines {}
13531593
set type p
13541594
@@ -1369,29 +1609,38 @@
13691609
13701610
#puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
13711611
13721612
if {$t ne $type || $cmd eq ""} {
13731613
# Finish the current block
1374
- autosetup_output_block $type $lines
1614
+ lappend doc($current) [list $type $lines]
13751615
set lines {}
13761616
set type $t
13771617
}
13781618
if {$cmd ne ""} {
13791619
lappend lines $cmd
13801620
}
13811621
}
13821622
1383
- autosetup_output_block $type $lines
1623
+ lappend doc($current) [list $type $lines]
13841624
}
13851625
close $f
13861626
}
1627
+
1628
+ # Now format and output the results
1629
+
1630
+ # _core_ will sort first
1631
+ foreach module [lsort [array names doc]] {
1632
+ foreach item $doc($module) {
1633
+ autosetup_output_block {*}$item
1634
+ }
1635
+ }
13871636
}
13881637
}
13891638
1390
-# ----- module init -----
1639
+# ----- @module init.tcl -----
13911640
1392
-set modsource(init) {
1641
+set modsource(init.tcl) {
13931642
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
13941643
# All rights reserved
13951644
13961645
# Module to help create auto.def and configure
13971646
@@ -1444,79 +1693,157 @@
14441693
}
14451694
writefile $filename $contents
14461695
}
14471696
}
14481697
1449
-# ----- module install -----
1698
+# ----- @module install.tcl -----
14501699
1451
-set modsource(install) {
1700
+set modsource(install.tcl) {
14521701
# Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
14531702
# All rights reserved
14541703
14551704
# Module which can install autosetup
14561705
1457
-proc autosetup_install {dir} {
1458
- if {[catch {
1706
+# autosetup(installed)=1 means that autosetup is not running from source
1707
+# autosetup(sysinstall)=1 means that autosetup is running from a sysinstall version
1708
+# shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1709
+
1710
+proc autosetup_install {dir {shared 0}} {
1711
+ global autosetup
1712
+ if {$shared} {
1713
+ if {$autosetup(installed) || $autosetup(sysinstall)} {
1714
+ user-error "Can only --sysinstall from development sources"
1715
+ }
1716
+ } elseif {$autosetup(installed) && !$autosetup(sysinstall)} {
1717
+ user-error "Can't --install from project install"
1718
+ }
1719
+
1720
+ if {$autosetup(sysinstall)} {
1721
+ # This is the sysinstall version, so install just uses references
14591722
cd $dir
1723
+
1724
+ puts "[autosetup_version] creating configure to use system-installed autosetup"
1725
+ autosetup_create_configure 1
1726
+ puts "Creating autosetup/README.autosetup"
14601727
file mkdir autosetup
1728
+ autosetup_install_readme autosetup/README.autosetup 1
1729
+ return
1730
+ }
1731
+
1732
+ if {[catch {
1733
+ if {$shared} {
1734
+ set target $dir/bin/autosetup
1735
+ set installedas $target
1736
+ } else {
1737
+ if {$dir eq "."} {
1738
+ set installedas autosetup
1739
+ } else {
1740
+ set installedas $dir/autosetup
1741
+ }
1742
+ cd $dir
1743
+ file mkdir autosetup
1744
+ set target autosetup/autosetup
1745
+ }
1746
+ set targetdir [file dirname $target]
1747
+ file mkdir $targetdir
14611748
1462
- set f [open autosetup/autosetup w]
1749
+ set f [open $target w]
14631750
1464
- set publicmodules [glob $::autosetup(libdir)/*.auto]
1751
+ set publicmodules {}
14651752
14661753
# First the main script, but only up until "CUT HERE"
1467
- set in [open $::autosetup(dir)/autosetup]
1754
+ set in [open $autosetup(dir)/autosetup]
14681755
while {[gets $in buf] >= 0} {
14691756
if {$buf ne "##-- CUT HERE --##"} {
14701757
puts $f $buf
14711758
continue
14721759
}
14731760
14741761
# Insert the static modules here
14751762
# i.e. those which don't contain @synopsis:
1763
+ # All modules are inserted if $shared is set
14761764
puts $f "set autosetup(installed) 1"
1477
- foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
1765
+ puts $f "set autosetup(sysinstall) $shared"
1766
+ foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1767
+ set modname [file tail $file]
1768
+ set ext [file ext $modname]
14781769
set buf [readfile $file]
1479
- if {[string match "*\n# @synopsis:*" $buf]} {
1480
- lappend publicmodules $file
1481
- continue
1770
+ if {!$shared} {
1771
+ if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1772
+ lappend publicmodules $file
1773
+ continue
1774
+ }
14821775
}
1483
- set modname [file rootname [file tail $file]]
1484
- puts $f "# ----- module $modname -----"
1776
+ dputs "install: importing lib/[file tail $file]"
1777
+ puts $f "# ----- @module $modname -----"
14851778
puts $f "\nset modsource($modname) \{"
14861779
puts $f $buf
14871780
puts $f "\}\n"
14881781
}
1782
+ if {$shared} {
1783
+ foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1784
+ $autosetup(srcdir)/LICENSE LICENSE] {
1785
+ dputs "install: importing $srcname as $destname"
1786
+ puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1787
+ }
1788
+ }
14891789
}
14901790
close $in
14911791
close $f
1492
- exec chmod 755 autosetup/autosetup
1792
+ catch {exec chmod 755 $target}
1793
+
1794
+ set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1795
+ set removefiles {}
1796
+
1797
+ if {!$shared} {
1798
+ autosetup_install_readme $targetdir/README.autosetup 0
14931799
1494
- # Install public modules
1495
- foreach file $publicmodules {
1496
- autosetup_install_file $file autosetup
1800
+ # Install public modules
1801
+ foreach file $publicmodules {
1802
+ set tail [file tail $file]
1803
+ autosetup_install_file $file $targetdir/$tail
1804
+ }
1805
+ lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1806
+ lappend removefiles config.guess config.sub test-tclsh find-tclsh
1807
+ } else {
1808
+ lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
14971809
}
14981810
14991811
# Install support files
1500
- foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
1501
- autosetup_install_file $::autosetup(dir)/$file autosetup
1502
- }
1503
- exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
1504
-
1505
- writefile autosetup/README.autosetup \
1506
- "This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
1507
-
1812
+ foreach fileinfo $installfiles {
1813
+ if {[llength $fileinfo] == 2} {
1814
+ lassign $fileinfo source dest
1815
+ } else {
1816
+ lassign $fileinfo source
1817
+ set dest $source
1818
+ }
1819
+ autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1820
+ }
1821
+
1822
+ # Remove obsolete files
1823
+ foreach file $removefiles {
1824
+ if {[file exists $targetdir/$file]} {
1825
+ file delete $targetdir/$file
1826
+ }
1827
+ }
15081828
} error]} {
15091829
user-error "Failed to install autosetup: $error"
15101830
}
1511
- puts "Installed [autosetup_version] to autosetup/"
1831
+ if {$shared} {
1832
+ set type "system"
1833
+ } else {
1834
+ set type "local"
1835
+ }
1836
+ puts "Installed $type [autosetup_version] to $installedas"
15121837
1513
- # Now create 'configure' if necessary
1514
- autosetup_create_configure
1838
+ if {!$shared} {
1839
+ # Now create 'configure' if necessary
1840
+ autosetup_create_configure 0
1841
+ }
15151842
}
15161843
1517
-proc autosetup_create_configure {} {
1844
+proc autosetup_create_configure {shared} {
15181845
if {[file exists configure]} {
15191846
if {!$::autosetup(force)} {
15201847
# Could this be an autosetup configure?
15211848
if {![string match "*\nWRAPPER=*" [readfile configure]]} {
15221849
puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1854,75 @@
15271854
puts "I will overwrite the existing configure because you used --force."
15281855
}
15291856
} else {
15301857
puts "I don't see configure, so I will create it."
15311858
}
1532
- writefile configure \
1859
+ if {$shared} {
1860
+ writefile configure \
1861
+{#!/bin/sh
1862
+WRAPPER="$0"; export WRAPPER; "autosetup" "$@"
1863
+}
1864
+ } else {
1865
+ writefile configure \
15331866
{#!/bin/sh
15341867
dir="`dirname "$0"`/autosetup"
1535
-WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
1868
+WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
15361869
}
1870
+ }
15371871
catch {exec chmod 755 configure}
15381872
}
15391873
15401874
# Append the contents of $file to filehandle $f
15411875
proc autosetup_install_append {f file} {
1876
+ dputs "install: include $file"
15421877
set in [open $file]
15431878
puts $f [read $in]
15441879
close $in
15451880
}
15461881
1547
-proc autosetup_install_file {file dir} {
1548
- if {![file exists $file]} {
1549
- error "Missing installation file '$file'"
1550
- }
1551
- writefile [file join $dir [file tail $file]] [readfile $file]\n
1552
-}
1553
-
1554
-if {$::autosetup(installed)} {
1555
- user-error "autosetup can only be installed from development source, not from installed copy"
1882
+proc autosetup_install_file {source target} {
1883
+ dputs "install: $source => $target"
1884
+ if {![file exists $source]} {
1885
+ error "Missing installation file '$source'"
1886
+ }
1887
+ writefile $target [readfile $source]\n
1888
+ # If possible, copy the file mode
1889
+ file stat $source stat
1890
+ set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1891
+ catch {exec chmod $mode $target}
1892
+}
1893
+
1894
+proc autosetup_install_readme {target sysinstall} {
1895
+ set readme "README.autosetup created by [autosetup_version]\n\n"
1896
+ if {$sysinstall} {
1897
+ append readme \
1898
+{This is the autosetup directory for a system install of autosetup.
1899
+Loadable modules can be added here.
1900
+}
1901
+ } else {
1902
+ append readme \
1903
+{This is the autosetup directory for a local install of autosetup.
1904
+It contains autosetup, support files and loadable modules.
1905
+}
1906
+}
1907
+
1908
+ append readme {
1909
+*.tcl files in this directory are optional modules which
1910
+can be loaded with the 'use' directive.
1911
+
1912
+*.auto files in this directory are auto-loaded.
1913
+
1914
+For more information, see http://msteveb.github.com/autosetup/
1915
+}
1916
+ dputs "install: autosetup/README.autosetup"
1917
+ writefile $target $readme
15561918
}
15571919
}
15581920
1559
-# ----- module markdown-formatting -----
1921
+# ----- @module markdown-formatting.tcl -----
15601922
1561
-set modsource(markdown-formatting) {
1923
+set modsource(markdown-formatting.tcl) {
15621924
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
15631925
# All rights reserved
15641926
15651927
# Module which provides text formatting
15661928
# markdown format (kramdown syntax)
@@ -1627,13 +1989,13 @@
16271989
}
16281990
puts "$defn"
16291991
}
16301992
}
16311993
1632
-# ----- module misc -----
1994
+# ----- @module misc.tcl -----
16331995
1634
-set modsource(misc) {
1996
+set modsource(misc.tcl) {
16351997
# Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
16361998
# All rights reserved
16371999
16382000
# Module containing misc procs useful to modules
16392001
# Largely for platform compatibility
@@ -1805,106 +2167,218 @@
18052167
string trim $result
18062168
}
18072169
}
18082170
}
18092171
1810
-# ----- module text-formatting -----
2172
+# ----- @module text-formatting.tcl -----
18112173
1812
-set modsource(text-formatting) {
2174
+set modsource(text-formatting.tcl) {
18132175
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
18142176
# All rights reserved
18152177
18162178
# Module which provides text formatting
18172179
18182180
use formatting
18192181
18202182
proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
1821
- set len 0
1822
- set space $firstprefix
1823
- foreach word [split $text] {
1824
- set word [string trim $word]
1825
- if {$word == ""} {
1826
- continue
1827
- }
1828
- if {$len && [string length $space$word] + $len >= $length} {
1829
- puts ""
1830
- set len 0
1831
- set space $nextprefix
1832
- }
1833
- incr len [string length $space$word]
1834
-
1835
- # Use man-page conventions for highlighting 'quoted' and *quoted*
1836
- # single words.
1837
- # Use x^Hx for *bold* and _^Hx for 'underline'.
1838
- #
1839
- # less and more will both understand this.
1840
- # Pipe through 'col -b' to remove them.
1841
- if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1842
- regsub -all . $bareword "_\b&" word
1843
- append word $dot
1844
- } elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1845
- regsub -all . $bareword "&\b&" word
1846
- append word $dot
1847
- }
1848
- puts -nonewline $space$word
1849
- set space " "
1850
- }
1851
- if {$len} {
1852
- puts ""
1853
- }
2183
+ set len 0
2184
+ set space $firstprefix
2185
+
2186
+ foreach word [split $text] {
2187
+ set word [string trim $word]
2188
+ if {$word eq ""} {
2189
+ continue
2190
+ }
2191
+ if {[info exists partial]} {
2192
+ append partial " " $word
2193
+ if {[string first $quote $word] < 0} {
2194
+ # Haven't found end of quoted word
2195
+ continue
2196
+ }
2197
+ # Finished quoted word
2198
+ set word $partial
2199
+ unset partial
2200
+ unset quote
2201
+ } else {
2202
+ set quote [string index $word 0]
2203
+ if {$quote in {' *}} {
2204
+ if {[string first $quote $word 1] < 0} {
2205
+ # Haven't found end of quoted word
2206
+ # Not a whole word.
2207
+ set first [string index $word 0]
2208
+ # Start of quoted word
2209
+ set partial $word
2210
+ continue
2211
+ }
2212
+ }
2213
+ }
2214
+
2215
+ if {$len && [string length $space$word] + $len >= $length} {
2216
+ puts ""
2217
+ set len 0
2218
+ set space $nextprefix
2219
+ }
2220
+ incr len [string length $space$word]
2221
+
2222
+ # Use man-page conventions for highlighting 'quoted' and *quoted*
2223
+ # single words.
2224
+ # Use x^Hx for *bold* and _^Hx for 'underline'.
2225
+ #
2226
+ # less and more will both understand this.
2227
+ # Pipe through 'col -b' to remove them.
2228
+ if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2229
+ set quoted [string map {~ " "} $quoted]
2230
+ regsub -all . $quoted "&\b&" quoted
2231
+ set word $quoted$after
2232
+ } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2233
+ set quoted [string map {~ " "} $quoted]
2234
+ regsub -all . $quoted "_\b&" quoted
2235
+ set word $quoted$after
2236
+ }
2237
+ puts -nonewline $space$word
2238
+ set space " "
2239
+ }
2240
+ if {[info exists partial]} {
2241
+ # Missing end of quote
2242
+ puts -nonewline $space$partial
2243
+ }
2244
+ if {$len} {
2245
+ puts ""
2246
+ }
18542247
}
18552248
proc title {text} {
1856
- underline [string trim $text] =
1857
- nl
2249
+ underline [string trim $text] =
2250
+ nl
18582251
}
18592252
proc p {text} {
1860
- wordwrap $text 80
1861
- nl
2253
+ wordwrap $text 80
2254
+ nl
18622255
}
18632256
proc codelines {lines} {
1864
- foreach line $lines {
1865
- puts " $line"
1866
- }
1867
- nl
2257
+ foreach line $lines {
2258
+ puts " $line"
2259
+ }
2260
+ nl
18682261
}
18692262
proc nl {} {
1870
- puts ""
2263
+ puts ""
18712264
}
18722265
proc underline {text char} {
1873
- regexp "^(\[ \t\]*)(.*)" $text -> indent words
1874
- puts $text
1875
- puts $indent[string repeat $char [string length $words]]
2266
+ regexp "^(\[ \t\]*)(.*)" $text -> indent words
2267
+ puts $text
2268
+ puts $indent[string repeat $char [string length $words]]
18762269
}
18772270
proc section {text} {
1878
- underline "[string trim $text]" -
1879
- nl
2271
+ underline "[string trim $text]" -
2272
+ nl
18802273
}
18812274
proc subsection {text} {
1882
- underline "$text" ~
1883
- nl
2275
+ underline "$text" ~
2276
+ nl
18842277
}
18852278
proc bullet {text} {
1886
- wordwrap $text 76 " * " " "
2279
+ wordwrap $text 76 " * " " "
18872280
}
18882281
proc indent {text} {
1889
- wordwrap $text 76 " " " "
2282
+ wordwrap $text 76 " " " "
18902283
}
18912284
proc defn {first args} {
1892
- if {$first ne ""} {
1893
- underline " $first" ~
1894
- }
1895
- foreach p $args {
1896
- if {$p ne ""} {
1897
- indent $p
1898
- }
1899
- }
2285
+ if {$first ne ""} {
2286
+ underline " $first" ~
2287
+ }
2288
+ foreach p $args {
2289
+ if {$p ne ""} {
2290
+ indent $p
2291
+ }
2292
+ }
2293
+}
2294
+}
2295
+
2296
+# ----- @module util.tcl -----
2297
+
2298
+set modsource(util.tcl) {
2299
+# Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2300
+# All rights reserved
2301
+
2302
+# Module which contains miscellaneous utility functions
2303
+
2304
+# @compare-versions version1 version2
2305
+#
2306
+# Versions are of the form 'a.b.c' (may be any number of numeric components)
2307
+#
2308
+# Compares the two versions and returns:
2309
+## -1 if v1 < v2
2310
+## 0 if v1 == v2
2311
+## 1 if v1 > v2
2312
+#
2313
+# If one version has fewer components than the other, 0 is substituted to the right. e.g.
2314
+## 0.2 < 0.3
2315
+## 0.2.5 > 0.2
2316
+## 1.1 == 1.1.0
2317
+#
2318
+proc compare-versions {v1 v2} {
2319
+ foreach c1 [split $v1 .] c2 [split $v2 .] {
2320
+ if {$c1 eq ""} {
2321
+ set c1 0
2322
+ }
2323
+ if {$c2 eq ""} {
2324
+ set c2 0
2325
+ }
2326
+ if {$c1 < $c2} {
2327
+ return -1
2328
+ }
2329
+ if {$c1 > $c2} {
2330
+ return 1
2331
+ }
2332
+ }
2333
+ return 0
2334
+}
2335
+
2336
+# @suffix suf list
2337
+#
2338
+# Takes a list and returns a new list with '$suf' appended
2339
+# to each element
2340
+#
2341
+## suffix .c {a b c} => {a.c b.c c.c}
2342
+#
2343
+proc suffix {suf list} {
2344
+ set result {}
2345
+ foreach p $list {
2346
+ lappend result $p$suf
2347
+ }
2348
+ return $result
2349
+}
2350
+
2351
+# @prefix pre list
2352
+#
2353
+# Takes a list and returns a new list with '$pre' prepended
2354
+# to each element
2355
+#
2356
+## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2357
+#
2358
+proc prefix {pre list} {
2359
+ set result {}
2360
+ foreach p $list {
2361
+ lappend result $pre$p
2362
+ }
2363
+ return $result
2364
+}
2365
+
2366
+# @lpop list
2367
+#
2368
+# Removes the last entry from the given list and returns it.
2369
+proc lpop {listname} {
2370
+ upvar $listname list
2371
+ set val [lindex $list end]
2372
+ set list [lrange $list 0 end-1]
2373
+ return $val
19002374
}
19012375
}
19022376
1903
-# ----- module wiki-formatting -----
2377
+# ----- @module wiki-formatting.tcl -----
19042378
1905
-set modsource(wiki-formatting) {
2379
+set modsource(wiki-formatting.tcl) {
19062380
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
19072381
# All rights reserved
19082382
19092383
# Module which provides text formatting
19102384
# wiki.tcl.tk format output
@@ -1975,11 +2449,11 @@
19752449
if {$autosetup(debug)} {
19762450
main $argv
19772451
}
19782452
if {[catch {main $argv} msg opts] == 1} {
19792453
show-notices
1980
- autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
2454
+ autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
19812455
if {!$autosetup(debug)} {
19822456
puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
19832457
}
19842458
exit 1
19852459
}
19862460
19872461
ADDED autosetup/autosetup-config.guess
19882462
ADDED autosetup/autosetup-config.sub
19892463
ADDED autosetup/autosetup-find-tclsh
19902464
ADDED autosetup/autosetup-test-tclsh
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,17 @@
1 #!/bin/sh
2 # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3 # All rights reserved
4 # vim:se syntax=tcl:
5 # \
6 dir=`dirname "$0"`; exec "`$dir/find-tclsh`" "$0" "$@"
7
8 set autosetup(version) 0.6.6
 
9
10 # Can be set to 1 to debug early-init problems
11 set autosetup(debug) 0
12
13 ##################################################################
14 #
15 # Main flow of control, option handling
16 #
@@ -72,14 +73,18 @@
72 set autosetup(cmdline) {}
73 # options is a list of known options
74 set autosetup(options) {}
75 # optset is a dictionary of option values set by the user based on getopt
76 set autosetup(optset) {}
77 # optdefault is a dictionary of default values for options
78 set autosetup(optdefault) {}
 
 
79 set autosetup(optionhelp) {}
80 set autosetup(showhelp) 0
 
 
81
82 # Parse options
83 use getopt
84
85 # At the is point we don't know what is a valid option
@@ -87,15 +92,28 @@
87 set autosetup(getopt) [getopt argv]
88
89 #"=Core Options:"
90 options-add {
91 help:=local => "display help and options. Optionally specify a module name, such as --help=system"
 
92 version => "display the version of autosetup"
93 ref:=text manual:=text
94 reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
95 debug => "display debugging output as autosetup runs"
96 install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
 
 
 
 
 
 
 
 
 
 
 
 
97 force init:=help => "create initial auto.def, etc. Use --init=help for known types"
98 # Undocumented options
99 option-checking=1
100 nopager
101 quiet
@@ -107,12 +125,12 @@
107 puts $autosetup(version)
108 exit 0
109 }
110
111 # autosetup --conf=alternate-auto.def
112 if {[opt-val conf] ne ""} {
113 set autosetup(autodef) [opt-val conf]
114 }
115
116 # Debugging output (set this early)
117 incr autosetup(debug) [opt-bool debug]
118 incr autosetup(force) [opt-bool force]
@@ -124,41 +142,50 @@
124 if {[file exists $autosetup(libdir)/local.tcl]} {
125 use local
126 }
127
128 # Now any auto-load modules
129 foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
130 automf_load source $file
131 }
132
133 if {[opt-val help] ne ""} {
134 incr autosetup(showhelp)
135 use help
136 autosetup_help [opt-val help]
137 }
138
139 if {[opt-val {manual ref reference}] ne ""} {
 
 
 
 
 
 
140 use help
141 autosetup_reference [opt-val {manual ref reference}]
142 }
143
144 # Allow combining --install and --init
145 set earlyexit 0
146 if {[opt-val install] ne ""} {
147 use install
148 autosetup_install [opt-val install]
149 incr earlyexit
150 }
151
152 if {[opt-val init] ne ""} {
153 use init
154 autosetup_init [opt-val init]
155 incr earlyexit
156 }
157
158 if {$earlyexit} {
159 exit 0
 
 
 
 
 
160 }
161
162 if {![file exists $autosetup(autodef)]} {
163 # Check for invalid option first
164 options {}
@@ -185,10 +212,11 @@
185 define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
186
187
188 # Log how we were invoked
189 configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
 
190
191 # Note that auto.def is *not* loaded in the global scope
192 source $autosetup(autodef)
193
194 # Could warn here if options {} was not specified
@@ -210,14 +238,14 @@
210 #
211 # Check each of the named, boolean options and if any have been explicitly enabled
212 # or disabled by the user, return 1 or 0 accordingly.
213 #
214 # If the option was specified more than once, the last value wins.
215 # e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
216 #
217 # If no value was specified by the user, returns the default value for the
218 # first option. If -nodefault is given, this behaviour changes and
219 # -1 is returned instead.
220 #
221 proc opt-bool {args} {
222 set nodefault 0
223 if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +265,19 @@
237 }
238 # Default value is the default for the first option
239 return [dict get $::autosetup(optdefault) [lindex $args 0]]
240 }
241
242 # @opt-val option-list ?default=""?
243 #
244 # Returns a list containing all the values given for the non-boolean options in 'option-list'.
245 # There will be one entry in the list for each option given by the user, including if the
246 # same option was used multiple times.
247 # If only a single value is required, use something like:
248 #
249 ## lindex [opt-val $names] end
250 #
251 # If no options were set, $default is returned (exactly, not as a list).
252 #
253 proc opt-val {names {default ""}} {
254 option-check-names {*}$names
255
256 foreach opt $names {
@@ -261,10 +288,83 @@
261 if {[info exists result]} {
262 return $result
263 }
264 return $default
265 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
267 proc option-check-names {args} {
268 foreach o $args {
269 if {$o ni $::autosetup(options)} {
270 autosetup-error "Request for undeclared option --$o"
@@ -293,10 +393,11 @@
293 # This is a special heading
294 lappend autosetup(optionhelp) $opt ""
295 set header {}
296 continue
297 }
 
298
299 #puts "i=$i, opt=$opt"
300 regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
301 if {$name in $autosetup(options)} {
302 autosetup-error "Option $name already specified"
@@ -310,10 +411,16 @@
310 # This is a documentation-only option, like "-C <dir>"
311 set opthelp $opt
312 } elseif {$colon eq ""} {
313 # Boolean option
314 lappend autosetup(options) $name
 
 
 
 
 
 
315
316 if {$value eq "1"} {
317 set opthelp "--disable-$name"
318 } else {
319 set opthelp "--$name"
@@ -321,11 +428,12 @@
321
322 # Set the default
323 if {$value eq ""} {
324 set value 0
325 }
326 dict set autosetup(optdefault) $name $value
 
327
328 if {[dict exists $autosetup(getopt) $name]} {
329 # The option was specified by the user. Look at the last value.
330 lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
331 if {$type eq "str"} {
@@ -342,19 +450,39 @@
342 #puts "Found boolean option --$name=$setvalue"
343 }
344 } else {
345 # String option.
346 lappend autosetup(options) $name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
348 if {$equal eq "="} {
349 # String option with optional value
350 set opthelp "--$name?=$value?"
351 } else {
352 # String option with required value
353 set opthelp "--$name=$value"
354 }
355 dict set autosetup(optdefault) $name $value
356
357 # Get the values specified by the user
358 if {[dict exists $autosetup(getopt) $name]} {
359 set listvalue {}
360
@@ -363,11 +491,11 @@
363 if {$type eq "bool" && $setvalue} {
364 if {$equal ne "="} {
365 user-error "Option --$name requires a value"
366 }
367 # If given as a boolean, use the default value
368 set setvalue $value
369 }
370 lappend listvalue $setvalue
371 }
372
373 #puts "Found string option --$name=$listvalue"
@@ -376,10 +504,13 @@
376 }
377
378 # Now create the help for this option if appropriate
379 if {[lindex $opts $i+1] eq "=>"} {
380 set desc [lindex $opts $i+2]
 
 
 
381 #string match \n* $desc
382 if {$header ne ""} {
383 lappend autosetup(optionhelp) $header ""
384 set header ""
385 }
@@ -463,35 +594,39 @@
463 options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
464 }
465 }
466 }
467
468 # @options options-spec
469 #
470 # Specifies configuration-time options which may be selected by the user
471 # and checked with opt-val and opt-bool. The format of options-spec follows.
 
472 #
473 # A boolean option is of the form:
474 #
475 ## name[=0|1] => "Description of this boolean option"
476 #
477 # The default is name=0, meaning that the option is disabled by default.
478 # If name=1 is used to make the option enabled by default, the description should reflect
479 # that with text like "Disable support for ...".
480 #
481 # An argument option (one which takes a parameter) is of the form:
482 #
483 ## name:[=]value => "Description of this option"
484 #
485 # If the name:value form is used, the value must be provided with the option (as --name=myvalue).
486 # If the name:=value form is used, the value is optional and the given value is used as the default
487 # if it is not provided.
488 #
489 # Undocumented options are also supported by omitting the "=> description.
490 # These options are not displayed with --help and can be useful for internal options or as aliases.
491 #
492 # For example, --disable-lfs is an alias for --disable=largefile:
 
 
 
493 #
494 ## lfs=1 largefile=1 => "Disable large file support"
495 #
496 proc options {optlist} {
497 # Allow options as a list or args
@@ -509,27 +644,37 @@
509 user-error "Unknown option --$o"
510 }
511 }
512 }
513 }
 
 
 
 
 
 
 
 
 
 
 
514
515 proc config_guess {} {
516 if {[file-isexec $::autosetup(dir)/config.guess]} {
517 exec-with-stderr sh $::autosetup(dir)/config.guess
518 if {[catch {exec-with-stderr sh $::autosetup(dir)/config.guess} alias]} {
519 user-error $alias
520 }
521 return $alias
522 } else {
523 configlog "No config.guess, so using uname"
524 string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
525 }
526 }
527
528 proc config_sub {alias} {
529 if {[file-isexec $::autosetup(dir)/config.sub]} {
530 if {[catch {exec-with-stderr sh $::autosetup(dir)/config.sub $alias} alias]} {
531 user-error $alias
532 }
533 }
534 return $alias
535 }
@@ -536,39 +681,48 @@
536
537 # @define name ?value=1?
538 #
539 # Defines the named variable to the given value.
540 # These (name, value) pairs represent the results of the configuration check
541 # and are available to be checked, modified and substituted.
542 #
543 proc define {name {value 1}} {
544 set ::define($name) $value
545 #dputs "$name <= $value"
546 }
547
548 # @undefine name
549 #
550 # Undefine the named variable
551 #
552 proc undefine {name} {
553 unset -nocomplain ::define($name)
554 #dputs "$name <= <undef>"
555 }
556
557 # @define-append name value ...
558 #
559 # Appends the given value(s) to the given 'defined' variable.
560 # If the variable is not defined or empty, it is set to $value.
561 # Otherwise the value is appended, separated by a space.
562 # Any extra values are similarly appended.
563 # If any value is already contained in the variable (as a substring) it is omitted.
564 #
565 proc define-append {name args} {
566 if {[get-define $name ""] ne ""} {
567 # Make a token attempt to avoid duplicates
568 foreach arg $args {
569 if {[string first $arg $::define($name)] == -1} {
 
 
 
 
 
 
 
 
 
570 append ::define($name) " " $arg
571 }
572 }
573 } else {
574 set ::define($name) [join $args]
@@ -576,11 +730,11 @@
576 #dputs "$name += [join $args] => $::define($name)"
577 }
578
579 # @get-define name ?default=0?
580 #
581 # Returns the current value of the 'defined' variable, or $default
582 # if not set.
583 #
584 proc get-define {name {default 0}} {
585 if {[info exists ::define($name)]} {
586 #dputs "$name => $::define($name)"
@@ -595,14 +749,26 @@
595 # Returns 1 if the given variable is defined.
596 #
597 proc is-defined {name} {
598 info exists ::define($name)
599 }
 
 
 
 
 
 
 
 
 
 
 
 
600
601 # @all-defines
602 #
603 # Returns a dictionary (name value list) of all defined variables.
604 #
605 # This is suitable for use with 'dict', 'array set' or 'foreach'
606 # and allows for arbitrary processing of the defined variables.
607 #
608 proc all-defines {} {
@@ -610,13 +776,13 @@
610 }
611
612
613 # @get-env name default
614 #
615 # If $name was specified on the command line, return it.
616 # If $name was set in the environment, return it.
617 # Otherwise return $default.
618 #
619 proc get-env {name default} {
620 if {[dict exists $::autosetup(cmdline) $name]} {
621 return [dict get $::autosetup(cmdline) $name]
622 }
@@ -623,11 +789,11 @@
623 getenv $name $default
624 }
625
626 # @env-is-set name
627 #
628 # Returns 1 if the $name was specified on the command line or in the environment.
629 # Note that an empty environment variable is not considered to be set.
630 #
631 proc env-is-set {name} {
632 if {[dict exists $::autosetup(cmdline) $name]} {
633 return 1
@@ -639,11 +805,11 @@
639 }
640
641 # @readfile filename ?default=""?
642 #
643 # Return the contents of the file, without the trailing newline.
644 # If the file doesn't exist or can't be read, returns $default.
645 #
646 proc readfile {filename {default_value ""}} {
647 set result $default_value
648 catch {
649 set f [open $filename]
@@ -653,11 +819,11 @@
653 return $result
654 }
655
656 # @writefile filename value
657 #
658 # Creates the given file containing $value.
659 # Does not add an extra newline.
660 #
661 proc writefile {filename value} {
662 set f [open $filename w]
663 puts -nonewline $f $value
@@ -677,63 +843,60 @@
677 lappend args [quote-if-needed $arg]
678 }
679 join $args
680 }
681
682 # @suffix suf list
683 #
684 # Takes a list and returns a new list with $suf appended
685 # to each element
686 #
687 ## suffix .c {a b c} => {a.c b.c c.c}
688 #
689 proc suffix {suf list} {
690 set result {}
691 foreach p $list {
692 lappend result $p$suf
 
 
693 }
694 return $result
695 }
696
697 # @prefix pre list
698 #
699 # Takes a list and returns a new list with $pre prepended
700 # to each element
701 #
702 ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
703 #
704 proc prefix {pre list} {
705 set result {}
706 foreach p $list {
707 lappend result $pre$p
708 }
709 return $result
 
 
 
 
 
 
 
 
 
 
710 }
711
712 # @find-executable name
713 #
714 # Searches the path for an executable with the given name.
715 # Note that the name may include some parameters, e.g. "cc -mbig-endian",
716 # in which case the parameters are ignored.
717 # Returns 1 if found, or 0 if not.
718 #
719 proc find-executable {name} {
720 # Ignore any parameters
721 set name [lindex $name 0]
722 if {$name eq ""} {
723 # The empty string is never a valid executable
724 return 0
725 }
726 foreach p [split-path] {
727 dputs "Looking for $name in $p"
728 set exec [file join $p $name]
729 if {[file-isexec $exec]} {
730 dputs "Found $name -> $exec"
731 return 1
732 }
733 }
734 return 0
735 }
736
737 # @find-an-executable ?-required? name ...
738 #
739 # Given a list of possible executable names,
@@ -764,11 +927,11 @@
764 return ""
765 }
766
767 # @configlog msg
768 #
769 # Writes the given message to the configuration log, config.log
770 #
771 proc configlog {msg} {
772 if {![info exists ::autosetup(logfh)]} {
773 set ::autosetup(logfh) [open config.log w]
774 }
@@ -800,12 +963,12 @@
800 }
801 }
802
803 # @msg-quiet command ...
804 #
805 # msg-quiet evaluates it's arguments as a command with output
806 # from msg-checking and msg-result suppressed.
807 #
808 # This is useful if a check needs to run a subcheck which isn't
809 # of interest to the user.
810 proc msg-quiet {args} {
811 incr ::autosetup(msg-quiet)
@@ -841,11 +1004,11 @@
841
842 # @user-error msg
843 #
844 # Indicate incorrect usage to the user, including if required components
845 # or features are not found.
846 # autosetup exits with a non-zero return code.
847 #
848 proc user-error {msg} {
849 show-notices
850 puts stderr "Error: $msg"
851 puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +1050,21 @@
887 proc maybe-show-timestamp {} {
888 if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
889 puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
890 }
891 }
 
 
 
 
 
 
 
 
 
 
 
892
893 proc autosetup_version {} {
894 return "autosetup v$::autosetup(version)"
895 }
896
@@ -986,23 +1160,35 @@
986 # The latter form is useful for a complex module which requires additional
987 # support file. In this form, '$::usedir' is set to the module directory
988 # when it is loaded.
989 #
990 proc use {args} {
 
 
 
 
 
 
991 foreach m $args {
992 if {[info exists ::libmodule($m)]} {
993 continue
994 }
995 set ::libmodule($m) 1
996 if {[info exists ::modsource($m)]} {
997 automf_load eval $::modsource($m)
998 } else {
999 set sources [list $::autosetup(libdir)/${m}.tcl $::autosetup(libdir)/${m}/init.tcl]
1000 set found 0
1001 foreach source $sources {
1002 if {[file exists $source]} {
1003 incr found
 
 
 
 
 
 
1004 break
1005 }
1006 }
1007 if {$found} {
1008 # For the convenience of the "use" source, point to the directory
@@ -1014,10 +1200,22 @@
1014 autosetup-error "use: No such module: $m"
1015 }
1016 }
1017 }
1018 }
 
 
 
 
 
 
 
 
 
 
 
 
1019
1020 # Load module source in the global scope by executing the given command
1021 proc automf_load {args} {
1022 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1023 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1225,21 @@
1027 # Initial settings
1028 set autosetup(exe) $::argv0
1029 set autosetup(istcl) 1
1030 set autosetup(start) [clock millis]
1031 set autosetup(installed) 0
 
1032 set autosetup(msg-checking) 0
1033 set autosetup(msg-quiet) 0
 
1034
1035 # Embedded modules are inserted below here
1036 set autosetup(installed) 1
1037 # ----- module asciidoc-formatting -----
 
1038
1039 set modsource(asciidoc-formatting) {
1040 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1041 # All rights reserved
1042
1043 # Module which provides text formatting
1044 # asciidoc format
@@ -1102,19 +1303,19 @@
1102 regsub -all "\n\n" $defn "\n ::\n" defn
1103 puts $defn
1104 }
1105 }
1106
1107 # ----- module formatting -----
1108
1109 set modsource(formatting) {
1110 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1111 # All rights reserved
1112
1113 # Module which provides common text formatting
1114
1115 # This is designed for documenation which looks like:
1116 # code {...}
1117 # or
1118 # code {
1119 # ...
1120 # ...
@@ -1159,13 +1360,13 @@
1159 # Return the result
1160 return $lines
1161 }
1162 }
1163
1164 # ----- module getopt -----
1165
1166 set modsource(getopt) {
1167 # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1168 # All rights reserved
1169
1170 # Simple getopt module
1171
@@ -1197,11 +1398,11 @@
1197
1198 if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1199 # --name=value
1200 dict lappend opts $name [list str $value]
1201 } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1202 if {$prefix in {enable- with- ""}} {
1203 set value 1
1204 } else {
1205 set value 0
1206 }
1207 dict lappend opts $name [list bool $value]
@@ -1218,13 +1419,13 @@
1218
1219 return $opts
1220 }
1221 }
1222
1223 # ----- module help -----
1224
1225 set modsource(help) {
1226 # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1227 # All rights reserved
1228
1229 # Module which provides usage, help and the command reference
1230
@@ -1251,10 +1452,28 @@
1251 options-show
1252 }
1253 }
1254 exit 0
1255 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1256
1257 # If not already paged and stdout is a tty, pipe the output through the pager
1258 # This is done by reinvoking autosetup with --nopager added
1259 proc use_pager {} {
1260 if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1523,16 @@
1304 }
1305
1306 proc autosetup_output_block {type lines} {
1307 if {[llength $lines]} {
1308 switch $type {
 
 
 
 
 
 
1309 code {
1310 codelines $lines
1311 }
1312 p {
1313 p [join $lines]
@@ -1325,30 +1550,45 @@
1325 # Generate a command reference from inline documentation
1326 proc automf_command_reference {} {
1327 lappend files $::autosetup(prog)
1328 lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1329
1330 section "Core Commands"
1331 set type p
1332 set lines {}
1333 set cmd {}
 
 
 
 
 
 
 
1334
1335 foreach file $files {
 
 
1336 set f [open $file]
1337 while {![eof $f]} {
1338 set line [gets $f]
 
 
 
 
 
1339
1340 # Find lines starting with "# @*" and continuing through the remaining comment lines
1341 if {![regexp {^# @(.*)} $line -> cmd]} {
1342 continue
1343 }
1344
1345 # Synopsis or command?
1346 if {$cmd eq "synopsis:"} {
1347 section "Module: [file rootname [file tail $file]]"
 
1348 } else {
1349 subsection $cmd
1350 }
1351
1352 set lines {}
1353 set type p
1354
@@ -1369,29 +1609,38 @@
1369
1370 #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1371
1372 if {$t ne $type || $cmd eq ""} {
1373 # Finish the current block
1374 autosetup_output_block $type $lines
1375 set lines {}
1376 set type $t
1377 }
1378 if {$cmd ne ""} {
1379 lappend lines $cmd
1380 }
1381 }
1382
1383 autosetup_output_block $type $lines
1384 }
1385 close $f
1386 }
 
 
 
 
 
 
 
 
 
1387 }
1388 }
1389
1390 # ----- module init -----
1391
1392 set modsource(init) {
1393 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1394 # All rights reserved
1395
1396 # Module to help create auto.def and configure
1397
@@ -1444,79 +1693,157 @@
1444 }
1445 writefile $filename $contents
1446 }
1447 }
1448
1449 # ----- module install -----
1450
1451 set modsource(install) {
1452 # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1453 # All rights reserved
1454
1455 # Module which can install autosetup
1456
1457 proc autosetup_install {dir} {
1458 if {[catch {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1459 cd $dir
 
 
 
 
1460 file mkdir autosetup
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1461
1462 set f [open autosetup/autosetup w]
1463
1464 set publicmodules [glob $::autosetup(libdir)/*.auto]
1465
1466 # First the main script, but only up until "CUT HERE"
1467 set in [open $::autosetup(dir)/autosetup]
1468 while {[gets $in buf] >= 0} {
1469 if {$buf ne "##-- CUT HERE --##"} {
1470 puts $f $buf
1471 continue
1472 }
1473
1474 # Insert the static modules here
1475 # i.e. those which don't contain @synopsis:
 
1476 puts $f "set autosetup(installed) 1"
1477 foreach file [lsort [glob $::autosetup(libdir)/*.tcl]] {
 
 
 
1478 set buf [readfile $file]
1479 if {[string match "*\n# @synopsis:*" $buf]} {
1480 lappend publicmodules $file
1481 continue
 
 
1482 }
1483 set modname [file rootname [file tail $file]]
1484 puts $f "# ----- module $modname -----"
1485 puts $f "\nset modsource($modname) \{"
1486 puts $f $buf
1487 puts $f "\}\n"
1488 }
 
 
 
 
 
 
 
1489 }
1490 close $in
1491 close $f
1492 exec chmod 755 autosetup/autosetup
 
 
 
 
 
 
1493
1494 # Install public modules
1495 foreach file $publicmodules {
1496 autosetup_install_file $file autosetup
 
 
 
 
 
 
1497 }
1498
1499 # Install support files
1500 foreach file {config.guess config.sub jimsh0.c find-tclsh test-tclsh LICENSE} {
1501 autosetup_install_file $::autosetup(dir)/$file autosetup
1502 }
1503 exec chmod 755 autosetup/config.sub autosetup/config.guess autosetup/find-tclsh
1504
1505 writefile autosetup/README.autosetup \
1506 "This is [autosetup_version]. See http://msteveb.github.com/autosetup/\n"
1507
 
 
 
 
 
 
 
 
1508 } error]} {
1509 user-error "Failed to install autosetup: $error"
1510 }
1511 puts "Installed [autosetup_version] to autosetup/"
 
 
 
 
 
1512
1513 # Now create 'configure' if necessary
1514 autosetup_create_configure
 
 
1515 }
1516
1517 proc autosetup_create_configure {} {
1518 if {[file exists configure]} {
1519 if {!$::autosetup(force)} {
1520 # Could this be an autosetup configure?
1521 if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1522 puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1854,75 @@
1527 puts "I will overwrite the existing configure because you used --force."
1528 }
1529 } else {
1530 puts "I don't see configure, so I will create it."
1531 }
1532 writefile configure \
 
 
 
 
 
 
1533 {#!/bin/sh
1534 dir="`dirname "$0"`/autosetup"
1535 WRAPPER="$0"; export WRAPPER; exec "`$dir/find-tclsh`" "$dir/autosetup" "$@"
1536 }
 
1537 catch {exec chmod 755 configure}
1538 }
1539
1540 # Append the contents of $file to filehandle $f
1541 proc autosetup_install_append {f file} {
 
1542 set in [open $file]
1543 puts $f [read $in]
1544 close $in
1545 }
1546
1547 proc autosetup_install_file {file dir} {
1548 if {![file exists $file]} {
1549 error "Missing installation file '$file'"
1550 }
1551 writefile [file join $dir [file tail $file]] [readfile $file]\n
1552 }
1553
1554 if {$::autosetup(installed)} {
1555 user-error "autosetup can only be installed from development source, not from installed copy"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1556 }
1557 }
1558
1559 # ----- module markdown-formatting -----
1560
1561 set modsource(markdown-formatting) {
1562 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1563 # All rights reserved
1564
1565 # Module which provides text formatting
1566 # markdown format (kramdown syntax)
@@ -1627,13 +1989,13 @@
1627 }
1628 puts "$defn"
1629 }
1630 }
1631
1632 # ----- module misc -----
1633
1634 set modsource(misc) {
1635 # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
1636 # All rights reserved
1637
1638 # Module containing misc procs useful to modules
1639 # Largely for platform compatibility
@@ -1805,106 +2167,218 @@
1805 string trim $result
1806 }
1807 }
1808 }
1809
1810 # ----- module text-formatting -----
1811
1812 set modsource(text-formatting) {
1813 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1814 # All rights reserved
1815
1816 # Module which provides text formatting
1817
1818 use formatting
1819
1820 proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
1821 set len 0
1822 set space $firstprefix
1823 foreach word [split $text] {
1824 set word [string trim $word]
1825 if {$word == ""} {
1826 continue
1827 }
1828 if {$len && [string length $space$word] + $len >= $length} {
1829 puts ""
1830 set len 0
1831 set space $nextprefix
1832 }
1833 incr len [string length $space$word]
1834
1835 # Use man-page conventions for highlighting 'quoted' and *quoted*
1836 # single words.
1837 # Use x^Hx for *bold* and _^Hx for 'underline'.
1838 #
1839 # less and more will both understand this.
1840 # Pipe through 'col -b' to remove them.
1841 if {[regexp {^'(.*)'([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1842 regsub -all . $bareword "_\b&" word
1843 append word $dot
1844 } elseif {[regexp {^[*](.*)[*]([^a-zA-Z0-9_]*)$} $word -> bareword dot]} {
1845 regsub -all . $bareword "&\b&" word
1846 append word $dot
1847 }
1848 puts -nonewline $space$word
1849 set space " "
1850 }
1851 if {$len} {
1852 puts ""
1853 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1854 }
1855 proc title {text} {
1856 underline [string trim $text] =
1857 nl
1858 }
1859 proc p {text} {
1860 wordwrap $text 80
1861 nl
1862 }
1863 proc codelines {lines} {
1864 foreach line $lines {
1865 puts " $line"
1866 }
1867 nl
1868 }
1869 proc nl {} {
1870 puts ""
1871 }
1872 proc underline {text char} {
1873 regexp "^(\[ \t\]*)(.*)" $text -> indent words
1874 puts $text
1875 puts $indent[string repeat $char [string length $words]]
1876 }
1877 proc section {text} {
1878 underline "[string trim $text]" -
1879 nl
1880 }
1881 proc subsection {text} {
1882 underline "$text" ~
1883 nl
1884 }
1885 proc bullet {text} {
1886 wordwrap $text 76 " * " " "
1887 }
1888 proc indent {text} {
1889 wordwrap $text 76 " " " "
1890 }
1891 proc defn {first args} {
1892 if {$first ne ""} {
1893 underline " $first" ~
1894 }
1895 foreach p $args {
1896 if {$p ne ""} {
1897 indent $p
1898 }
1899 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1900 }
1901 }
1902
1903 # ----- module wiki-formatting -----
1904
1905 set modsource(wiki-formatting) {
1906 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1907 # All rights reserved
1908
1909 # Module which provides text formatting
1910 # wiki.tcl.tk format output
@@ -1975,11 +2449,11 @@
1975 if {$autosetup(debug)} {
1976 main $argv
1977 }
1978 if {[catch {main $argv} msg opts] == 1} {
1979 show-notices
1980 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
1981 if {!$autosetup(debug)} {
1982 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
1983 }
1984 exit 1
1985 }
1986
1987 DDED autosetup/autosetup-config.guess
1988 DDED autosetup/autosetup-config.sub
1989 DDED autosetup/autosetup-find-tclsh
1990 DDED autosetup/autosetup-test-tclsh
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -1,16 +1,17 @@
1 #!/bin/sh
2 # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3 # All rights reserved
4 # vim:se syntax=tcl:
5 # \
6 dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
7
8 # Note that the version has a trailing + on unreleased versions
9 set autosetup(version) 0.6.9
10
11 # Can be set to 1 to debug early-init problems
12 set autosetup(debug) [expr {"--debug" in $argv}]
13
14 ##################################################################
15 #
16 # Main flow of control, option handling
17 #
@@ -72,14 +73,18 @@
73 set autosetup(cmdline) {}
74 # options is a list of known options
75 set autosetup(options) {}
76 # optset is a dictionary of option values set by the user based on getopt
77 set autosetup(optset) {}
78 # optdefault is a dictionary of default values
79 set autosetup(optdefault) {}
80 # options-defaults is a dictionary of overrides for default values for options
81 set autosetup(options-defaults) {}
82 set autosetup(optionhelp) {}
83 set autosetup(showhelp) 0
84
85 use util
86
87 # Parse options
88 use getopt
89
90 # At the is point we don't know what is a valid option
@@ -87,15 +92,28 @@
92 set autosetup(getopt) [getopt argv]
93
94 #"=Core Options:"
95 options-add {
96 help:=local => "display help and options. Optionally specify a module name, such as --help=system"
97 licence license => "display the autosetup license"
98 version => "display the version of autosetup"
99 ref:=text manual:=text
100 reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
101 debug => "display debugging output as autosetup runs"
102 install:=. => "install autosetup to the current or given directory"
103 }
104 if {$autosetup(installed)} {
105 # hidden options so we can produce a nice error
106 options-add {
107 sysinstall:path
108 }
109 } else {
110 options-add {
111 sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
112 }
113 }
114 options-add {
115 force init:=help => "create initial auto.def, etc. Use --init=help for known types"
116 # Undocumented options
117 option-checking=1
118 nopager
119 quiet
@@ -107,12 +125,12 @@
125 puts $autosetup(version)
126 exit 0
127 }
128
129 # autosetup --conf=alternate-auto.def
130 if {[opt-str conf o]} {
131 set autosetup(autodef) $o
132 }
133
134 # Debugging output (set this early)
135 incr autosetup(debug) [opt-bool debug]
136 incr autosetup(force) [opt-bool force]
@@ -124,41 +142,50 @@
142 if {[file exists $autosetup(libdir)/local.tcl]} {
143 use local
144 }
145
146 # Now any auto-load modules
147 autosetup_load_auto_modules
 
 
148
149 if {[opt-str help o]} {
150 incr autosetup(showhelp)
151 use help
152 autosetup_help $o
153 }
154
155 if {[opt-bool licence license]} {
156 use help
157 autosetup_show_license
158 exit 0
159 }
160
161 if {[opt-str {manual ref reference} o]} {
162 use help
163 autosetup_reference $o
164 }
165
166 # Allow combining --install and --init
167 set earlyexit 0
168 if {[opt-str install o]} {
169 use install
170 autosetup_install $o
171 incr earlyexit
172 }
173
174 if {[opt-str init o]} {
175 use init
176 autosetup_init $o
177 incr earlyexit
178 }
179
180 if {$earlyexit} {
181 exit 0
182 }
183 if {[opt-str sysinstall o]} {
184 use install
185 autosetup_install $o 1
186 exit 0
187 }
188
189 if {![file exists $autosetup(autodef)]} {
190 # Check for invalid option first
191 options {}
@@ -185,10 +212,11 @@
212 define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
213
214
215 # Log how we were invoked
216 configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
217 configlog "Tclsh: [info nameofexecutable]"
218
219 # Note that auto.def is *not* loaded in the global scope
220 source $autosetup(autodef)
221
222 # Could warn here if options {} was not specified
@@ -210,14 +238,14 @@
238 #
239 # Check each of the named, boolean options and if any have been explicitly enabled
240 # or disabled by the user, return 1 or 0 accordingly.
241 #
242 # If the option was specified more than once, the last value wins.
243 # e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
244 #
245 # If no value was specified by the user, returns the default value for the
246 # first option. If '-nodefault' is given, this behaviour changes and
247 # -1 is returned instead.
248 #
249 proc opt-bool {args} {
250 set nodefault 0
251 if {[lindex $args 0] eq "-nodefault"} {
@@ -237,20 +265,19 @@
265 }
266 # Default value is the default for the first option
267 return [dict get $::autosetup(optdefault) [lindex $args 0]]
268 }
269
270 # @opt-val optionlist ?default=""?
271 #
272 # Returns a list containing all the values given for the non-boolean options in '$optionlist'.
273 # There will be one entry in the list for each option given by the user, including if the
274 # same option was used multiple times.
 
275 #
276 # If no options were set, '$default' is returned (exactly, not as a list).
277 #
278 # Note: For most use cases, 'opt-str' should be preferred.
279 #
280 proc opt-val {names {default ""}} {
281 option-check-names {*}$names
282
283 foreach opt $names {
@@ -261,10 +288,83 @@
288 if {[info exists result]} {
289 return $result
290 }
291 return $default
292 }
293
294 # @opt-str optionlist varname ?default?
295 #
296 # Sets '$varname' in the callers scope to the value for one of the given options.
297 #
298 # For the list of options given in '$optionlist', if any value is set for any option,
299 # the option value is taken to be the *last* value of the last option (in the order given).
300 #
301 # If no option was given, and a default was specified with 'options-defaults',
302 # that value is used.
303 #
304 # If no 'options-defaults' value was given and '$default' was given, it is used.
305 #
306 # If none of the above provided a value, no value is set.
307 #
308 # The return value depends on whether '$default' was specified.
309 # If it was, the option value is returned.
310 # If it was not, 1 is returns if a value was set, or 0 if not.
311 #
312 # Typical usage is as follows:
313 #
314 ## if {[opt-str {myopt altname} o]} {
315 ## do something with $o
316 ## }
317 #
318 # Or:
319 ## define myname [opt-str {myopt altname} o "/usr/local"]
320 #
321 proc opt-str {names varname args} {
322 global autosetup
323
324 option-check-names {*}$names
325 upvar $varname value
326
327 if {[llength $args]} {
328 # A default was given, so always return the string value of the option
329 set default [lindex $args 0]
330 set retopt 1
331 } else {
332 # No default, so return 0 or 1 to indicate if a value was found
333 set retopt 0
334 }
335
336 foreach opt $names {
337 if {[dict exists $::autosetup(optset) $opt]} {
338 set result [lindex [dict get $::autosetup(optset) $opt] end]
339 }
340 }
341
342 if {![info exists result]} {
343 # No user-specified value. Has options-defaults been set?
344 foreach opt $names {
345 if {[dict exists $::autosetup(options-defaults) $opt]} {
346 set result [dict get $autosetup(options-defaults) $opt]
347 }
348 }
349 }
350
351 if {[info exists result]} {
352 set value $result
353 if {$retopt} {
354 return $value
355 }
356 return 1
357 }
358
359 if {$retopt} {
360 set value $default
361 return $value
362 }
363
364 return 0
365 }
366
367 proc option-check-names {args} {
368 foreach o $args {
369 if {$o ni $::autosetup(options)} {
370 autosetup-error "Request for undeclared option --$o"
@@ -293,10 +393,11 @@
393 # This is a special heading
394 lappend autosetup(optionhelp) $opt ""
395 set header {}
396 continue
397 }
398 unset -nocomplain defaultvalue equal value
399
400 #puts "i=$i, opt=$opt"
401 regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
402 if {$name in $autosetup(options)} {
403 autosetup-error "Option $name already specified"
@@ -310,10 +411,16 @@
411 # This is a documentation-only option, like "-C <dir>"
412 set opthelp $opt
413 } elseif {$colon eq ""} {
414 # Boolean option
415 lappend autosetup(options) $name
416
417 # Check for override
418 if {[dict exists $autosetup(options-defaults) $name]} {
419 # A default was specified with options-defaults, so use it
420 set value [dict get $autosetup(options-defaults) $name]
421 }
422
423 if {$value eq "1"} {
424 set opthelp "--disable-$name"
425 } else {
426 set opthelp "--$name"
@@ -321,11 +428,12 @@
428
429 # Set the default
430 if {$value eq ""} {
431 set value 0
432 }
433 set defaultvalue $value
434 dict set autosetup(optdefault) $name $defaultvalue
435
436 if {[dict exists $autosetup(getopt) $name]} {
437 # The option was specified by the user. Look at the last value.
438 lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
439 if {$type eq "str"} {
@@ -342,19 +450,39 @@
450 #puts "Found boolean option --$name=$setvalue"
451 }
452 } else {
453 # String option.
454 lappend autosetup(options) $name
455
456 if {$colon eq ":"} {
457 # Was ":name=default" given?
458 # If so, set $value to the display name and $defaultvalue to the default
459 # (This is the preferred way to set a default value for a string option)
460 if {[regexp {^([^=]+)=(.*)$} $value -> value defaultvalue]} {
461 dict set autosetup(optdefault) $name $defaultvalue
462 }
463 }
464
465 # Maybe override the default value
466 if {[dict exists $autosetup(options-defaults) $name]} {
467 # A default was specified with options-defaults, so use it
468 set defaultvalue [dict get $autosetup(options-defaults) $name]
469 dict set autosetup(optdefault) $name $defaultvalue
470 } elseif {![info exists defaultvalue]} {
471 # For backward compatibility, if ":name" was given, use name as both
472 # the display text and the default value, but only if the user
473 # specified the option without the value
474 set defaultvalue $value
475 }
476
477 if {$equal eq "="} {
478 # String option with optional value
479 set opthelp "--$name?=$value?"
480 } else {
481 # String option with required value
482 set opthelp "--$name=$value"
483 }
 
484
485 # Get the values specified by the user
486 if {[dict exists $autosetup(getopt) $name]} {
487 set listvalue {}
488
@@ -363,11 +491,11 @@
491 if {$type eq "bool" && $setvalue} {
492 if {$equal ne "="} {
493 user-error "Option --$name requires a value"
494 }
495 # If given as a boolean, use the default value
496 set setvalue $defaultvalue
497 }
498 lappend listvalue $setvalue
499 }
500
501 #puts "Found string option --$name=$listvalue"
@@ -376,10 +504,13 @@
504 }
505
506 # Now create the help for this option if appropriate
507 if {[lindex $opts $i+1] eq "=>"} {
508 set desc [lindex $opts $i+2]
509 if {[info exists defaultvalue]} {
510 set desc [string map [list @default@ $defaultvalue] $desc]
511 }
512 #string match \n* $desc
513 if {$header ne ""} {
514 lappend autosetup(optionhelp) $header ""
515 set header ""
516 }
@@ -463,35 +594,39 @@
594 options-wrap-desc [string trim $desc] $cols " " $indent [expr $max + 2]
595 }
596 }
597 }
598
599 # @options optionspec
600 #
601 # Specifies configuration-time options which may be selected by the user
602 # and checked with 'opt-str' and 'opt-bool'. '$optionspec' contains a series
603 # of options specifications separated by newlines, as follows:
604 #
605 # A boolean option is of the form:
606 #
607 ## name[=0|1] => "Description of this boolean option"
608 #
609 # The default is 'name=0', meaning that the option is disabled by default.
610 # If 'name=1' is used to make the option enabled by default, the description should reflect
611 # that with text like "Disable support for ...".
612 #
613 # An argument option (one which takes a parameter) is of the form:
614 #
615 ## name:[=]value => "Description of this option"
616 #
617 # If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
618 # If the 'name:=value' form is used, the value is optional and the given value is used as the default
619 # if it is not provided.
620 #
621 # The description may contain '@default@', in which case it will be replaced with the default
622 # value for the option (taking into account defaults specified with 'options-defaults'.
623 #
624 # Undocumented options are also supported by omitting the '=> description'.
625 # These options are not displayed with '--help' and can be useful for internal options or as aliases.
626 #
627 # For example, '--disable-lfs' is an alias for '--disable=largefile':
628 #
629 ## lfs=1 largefile=1 => "Disable large file support"
630 #
631 proc options {optlist} {
632 # Allow options as a list or args
@@ -509,27 +644,37 @@
644 user-error "Unknown option --$o"
645 }
646 }
647 }
648 }
649
650 # @options-defaults dictionary
651 #
652 # Specifies a dictionary of options and a new default value for each of those options.
653 # Use before any 'use' statements in 'auto.def' to change the defaults for
654 # subsequently included modules.
655 proc options-defaults {dict} {
656 foreach {n v} $dict {
657 dict set ::autosetup(options-defaults) $n $v
658 }
659 }
660
661 proc config_guess {} {
662 if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
663 if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
 
664 user-error $alias
665 }
666 return $alias
667 } else {
668 configlog "No autosetup-config.guess, so using uname"
669 string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
670 }
671 }
672
673 proc config_sub {alias} {
674 if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
675 if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
676 user-error $alias
677 }
678 }
679 return $alias
680 }
@@ -536,39 +681,48 @@
681
682 # @define name ?value=1?
683 #
684 # Defines the named variable to the given value.
685 # These (name, value) pairs represent the results of the configuration check
686 # and are available to be subsequently checked, modified and substituted.
687 #
688 proc define {name {value 1}} {
689 set ::define($name) $value
690 #dputs "$name <= $value"
691 }
692
693 # @undefine name
694 #
695 # Undefine the named variable.
696 #
697 proc undefine {name} {
698 unset -nocomplain ::define($name)
699 #dputs "$name <= <undef>"
700 }
701
702 # @define-append name value ...
703 #
704 # Appends the given value(s) to the given "defined" variable.
705 # If the variable is not defined or empty, it is set to '$value'.
706 # Otherwise the value is appended, separated by a space.
707 # Any extra values are similarly appended.
708 # If any value is already contained in the variable (as a substring) it is omitted.
709 #
710 proc define-append {name args} {
711 if {[get-define $name ""] ne ""} {
712 # Avoid duplicates
713 foreach arg $args {
714 if {$arg eq ""} {
715 continue
716 }
717 set found 0
718 foreach str [split $::define($name) " "] {
719 if {$str eq $arg} {
720 incr found
721 }
722 }
723 if {!$found} {
724 append ::define($name) " " $arg
725 }
726 }
727 } else {
728 set ::define($name) [join $args]
@@ -576,11 +730,11 @@
730 #dputs "$name += [join $args] => $::define($name)"
731 }
732
733 # @get-define name ?default=0?
734 #
735 # Returns the current value of the "defined" variable, or '$default'
736 # if not set.
737 #
738 proc get-define {name {default 0}} {
739 if {[info exists ::define($name)]} {
740 #dputs "$name => $::define($name)"
@@ -595,14 +749,26 @@
749 # Returns 1 if the given variable is defined.
750 #
751 proc is-defined {name} {
752 info exists ::define($name)
753 }
754
755 # @is-define-set name
756 #
757 # Returns 1 if the given variable is defined and is set
758 # to a value other than "" or 0
759 #
760 proc is-define-set {name} {
761 if {[get-define $name] in {0 ""}} {
762 return 0
763 }
764 return 1
765 }
766
767 # @all-defines
768 #
769 # Returns a dictionary (name, value list) of all defined variables.
770 #
771 # This is suitable for use with 'dict', 'array set' or 'foreach'
772 # and allows for arbitrary processing of the defined variables.
773 #
774 proc all-defines {} {
@@ -610,13 +776,13 @@
776 }
777
778
779 # @get-env name default
780 #
781 # If '$name' was specified on the command line, return it.
782 # Otherwise if '$name' was set in the environment, return it.
783 # Otherwise return '$default'.
784 #
785 proc get-env {name default} {
786 if {[dict exists $::autosetup(cmdline) $name]} {
787 return [dict get $::autosetup(cmdline) $name]
788 }
@@ -623,11 +789,11 @@
789 getenv $name $default
790 }
791
792 # @env-is-set name
793 #
794 # Returns 1 if '$name' was specified on the command line or in the environment.
795 # Note that an empty environment variable is not considered to be set.
796 #
797 proc env-is-set {name} {
798 if {[dict exists $::autosetup(cmdline) $name]} {
799 return 1
@@ -639,11 +805,11 @@
805 }
806
807 # @readfile filename ?default=""?
808 #
809 # Return the contents of the file, without the trailing newline.
810 # If the file doesn't exist or can't be read, returns '$default'.
811 #
812 proc readfile {filename {default_value ""}} {
813 set result $default_value
814 catch {
815 set f [open $filename]
@@ -653,11 +819,11 @@
819 return $result
820 }
821
822 # @writefile filename value
823 #
824 # Creates the given file containing '$value'.
825 # Does not add an extra newline.
826 #
827 proc writefile {filename value} {
828 set f [open $filename w]
829 puts -nonewline $f $value
@@ -677,63 +843,60 @@
843 lappend args [quote-if-needed $arg]
844 }
845 join $args
846 }
847
848 # @list-non-empty list
849 #
850 # Returns a copy of the given list with empty elements removed
851 proc list-non-empty {list} {
 
 
 
 
852 set result {}
853 foreach p $list {
854 if {$p ne ""} {
855 lappend result $p
856 }
857 }
858 return $result
859 }
860
861 # @find-executable-path name
862 #
863 # Searches the path for an executable with the given name.
864 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
865 # in which case the parameters are ignored.
866 # The full path to the executable if found, or "" if not found.
867 # Returns 1 if found, or 0 if not.
868 #
869 proc find-executable-path {name} {
870 # Ignore any parameters
871 set name [lindex $name 0]
872 # The empty string is never a valid executable
873 if {$name ne ""} {
874 foreach p [split-path] {
875 dputs "Looking for $name in $p"
876 set exec [file join $p $name]
877 if {[file-isexec $exec]} {
878 dputs "Found $name -> $exec"
879 return $exec
880 }
881 }
882 }
883 return {}
884 }
885
886 # @find-executable name
887 #
888 # Searches the path for an executable with the given name.
889 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
890 # in which case the parameters are ignored.
891 # Returns 1 if found, or 0 if not.
892 #
893 proc find-executable {name} {
894 if {[find-executable-path $name] eq {}} {
895 return 0
896 }
897 return 1
 
 
 
 
 
 
 
 
 
 
 
898 }
899
900 # @find-an-executable ?-required? name ...
901 #
902 # Given a list of possible executable names,
@@ -764,11 +927,11 @@
927 return ""
928 }
929
930 # @configlog msg
931 #
932 # Writes the given message to the configuration log, 'config.log'.
933 #
934 proc configlog {msg} {
935 if {![info exists ::autosetup(logfh)]} {
936 set ::autosetup(logfh) [open config.log w]
937 }
@@ -800,12 +963,12 @@
963 }
964 }
965
966 # @msg-quiet command ...
967 #
968 # 'msg-quiet' evaluates it's arguments as a command with output
969 # from 'msg-checking' and 'msg-result' suppressed.
970 #
971 # This is useful if a check needs to run a subcheck which isn't
972 # of interest to the user.
973 proc msg-quiet {args} {
974 incr ::autosetup(msg-quiet)
@@ -841,11 +1004,11 @@
1004
1005 # @user-error msg
1006 #
1007 # Indicate incorrect usage to the user, including if required components
1008 # or features are not found.
1009 # 'autosetup' exits with a non-zero return code.
1010 #
1011 proc user-error {msg} {
1012 show-notices
1013 puts stderr "Error: $msg"
1014 puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
@@ -887,10 +1050,21 @@
1050 proc maybe-show-timestamp {} {
1051 if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
1052 puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
1053 }
1054 }
1055
1056 # @autosetup-require-version required
1057 #
1058 # Checks the current version of 'autosetup' against '$required'.
1059 # A fatal error is generated if the current version is less than that required.
1060 #
1061 proc autosetup-require-version {required} {
1062 if {[compare-versions $::autosetup(version) $required] < 0} {
1063 user-error "autosetup version $required is required, but this is $::autosetup(version)"
1064 }
1065 }
1066
1067 proc autosetup_version {} {
1068 return "autosetup v$::autosetup(version)"
1069 }
1070
@@ -986,23 +1160,35 @@
1160 # The latter form is useful for a complex module which requires additional
1161 # support file. In this form, '$::usedir' is set to the module directory
1162 # when it is loaded.
1163 #
1164 proc use {args} {
1165 global autosetup libmodule modsource
1166
1167 set dirs [list $autosetup(libdir)]
1168 if {[info exists autosetup(srcdir)]} {
1169 lappend dirs $autosetup(srcdir)/autosetup
1170 }
1171 foreach m $args {
1172 if {[info exists libmodule($m)]} {
1173 continue
1174 }
1175 set libmodule($m) 1
1176 if {[info exists modsource(${m}.tcl)]} {
1177 automf_load eval $modsource(${m}.tcl)
1178 } else {
1179 set locs [list ${m}.tcl ${m}/init.tcl]
1180 set found 0
1181 foreach dir $dirs {
1182 foreach loc $locs {
1183 set source $dir/$loc
1184 if {[file exists $source]} {
1185 incr found
1186 break
1187 }
1188 }
1189 if {$found} {
1190 break
1191 }
1192 }
1193 if {$found} {
1194 # For the convenience of the "use" source, point to the directory
@@ -1014,10 +1200,22 @@
1200 autosetup-error "use: No such module: $m"
1201 }
1202 }
1203 }
1204 }
1205
1206 proc autosetup_load_auto_modules {} {
1207 global autosetup modsource
1208 # First load any embedded auto modules
1209 foreach mod [array names modsource *.auto] {
1210 automf_load eval $modsource($mod)
1211 }
1212 # Now any external auto modules
1213 foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1214 automf_load source $file
1215 }
1216 }
1217
1218 # Load module source in the global scope by executing the given command
1219 proc automf_load {args} {
1220 if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1221 autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
@@ -1027,18 +1225,21 @@
1225 # Initial settings
1226 set autosetup(exe) $::argv0
1227 set autosetup(istcl) 1
1228 set autosetup(start) [clock millis]
1229 set autosetup(installed) 0
1230 set autosetup(sysinstall) 0
1231 set autosetup(msg-checking) 0
1232 set autosetup(msg-quiet) 0
1233 set autosetup(inittypes) {}
1234
1235 # Embedded modules are inserted below here
1236 set autosetup(installed) 1
1237 set autosetup(sysinstall) 0
1238 # ----- @module asciidoc-formatting.tcl -----
1239
1240 set modsource(asciidoc-formatting.tcl) {
1241 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1242 # All rights reserved
1243
1244 # Module which provides text formatting
1245 # asciidoc format
@@ -1102,19 +1303,19 @@
1303 regsub -all "\n\n" $defn "\n ::\n" defn
1304 puts $defn
1305 }
1306 }
1307
1308 # ----- @module formatting.tcl -----
1309
1310 set modsource(formatting.tcl) {
1311 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1312 # All rights reserved
1313
1314 # Module which provides common text formatting
1315
1316 # This is designed for documentation which looks like:
1317 # code {...}
1318 # or
1319 # code {
1320 # ...
1321 # ...
@@ -1159,13 +1360,13 @@
1360 # Return the result
1361 return $lines
1362 }
1363 }
1364
1365 # ----- @module getopt.tcl -----
1366
1367 set modsource(getopt.tcl) {
1368 # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1369 # All rights reserved
1370
1371 # Simple getopt module
1372
@@ -1197,11 +1398,11 @@
1398
1399 if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1400 # --name=value
1401 dict lappend opts $name [list str $value]
1402 } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1403 if {$prefix in {enable- ""}} {
1404 set value 1
1405 } else {
1406 set value 0
1407 }
1408 dict lappend opts $name [list bool $value]
@@ -1218,13 +1419,13 @@
1419
1420 return $opts
1421 }
1422 }
1423
1424 # ----- @module help.tcl -----
1425
1426 set modsource(help.tcl) {
1427 # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1428 # All rights reserved
1429
1430 # Module which provides usage, help and the command reference
1431
@@ -1251,10 +1452,28 @@
1452 options-show
1453 }
1454 }
1455 exit 0
1456 }
1457
1458 proc autosetup_show_license {} {
1459 global modsource autosetup
1460 use_pager
1461
1462 if {[info exists modsource(LICENSE)]} {
1463 puts $modsource(LICENSE)
1464 return
1465 }
1466 foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1467 set path [file join $dir LICENSE]
1468 if {[file exists $path]} {
1469 puts [readfile $path]
1470 return
1471 }
1472 }
1473 puts "LICENSE not found"
1474 }
1475
1476 # If not already paged and stdout is a tty, pipe the output through the pager
1477 # This is done by reinvoking autosetup with --nopager added
1478 proc use_pager {} {
1479 if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
@@ -1304,10 +1523,16 @@
1523 }
1524
1525 proc autosetup_output_block {type lines} {
1526 if {[llength $lines]} {
1527 switch $type {
1528 section {
1529 section $lines
1530 }
1531 subsection {
1532 subsection $lines
1533 }
1534 code {
1535 codelines $lines
1536 }
1537 p {
1538 p [join $lines]
@@ -1325,30 +1550,45 @@
1550 # Generate a command reference from inline documentation
1551 proc automf_command_reference {} {
1552 lappend files $::autosetup(prog)
1553 lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1554
1555 # We want to process all non-module files before module files
1556 # and then modules in alphabetical order.
1557 # So examine all files and extract docs into doc($modulename) and doc(_core_)
1558 #
1559 # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1560 # and $data is a string for section, subsection or a list of text lines for other types.
1561
1562 # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1563
1564 set doc(_core_) {}
1565 lappend doc(_core_) [list section "Core Commands"]
1566
1567 foreach file $files {
1568 set modulename [file rootname [file tail $file]]
1569 set current _core_
1570 set f [open $file]
1571 while {![eof $f]} {
1572 set line [gets $f]
1573
1574 # Find embedded module names
1575 if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1576 continue
1577 }
1578
1579 # Find lines starting with "# @*" and continuing through the remaining comment lines
1580 if {![regexp {^# @(.*)} $line -> cmd]} {
1581 continue
1582 }
1583
1584 # Synopsis or command?
1585 if {$cmd eq "synopsis:"} {
1586 set current $modulename
1587 lappend doc($current) [list section "Module: $modulename"]
1588 } else {
1589 lappend doc($current) [list subsection $cmd]
1590 }
1591
1592 set lines {}
1593 set type p
1594
@@ -1369,29 +1609,38 @@
1609
1610 #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1611
1612 if {$t ne $type || $cmd eq ""} {
1613 # Finish the current block
1614 lappend doc($current) [list $type $lines]
1615 set lines {}
1616 set type $t
1617 }
1618 if {$cmd ne ""} {
1619 lappend lines $cmd
1620 }
1621 }
1622
1623 lappend doc($current) [list $type $lines]
1624 }
1625 close $f
1626 }
1627
1628 # Now format and output the results
1629
1630 # _core_ will sort first
1631 foreach module [lsort [array names doc]] {
1632 foreach item $doc($module) {
1633 autosetup_output_block {*}$item
1634 }
1635 }
1636 }
1637 }
1638
1639 # ----- @module init.tcl -----
1640
1641 set modsource(init.tcl) {
1642 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1643 # All rights reserved
1644
1645 # Module to help create auto.def and configure
1646
@@ -1444,79 +1693,157 @@
1693 }
1694 writefile $filename $contents
1695 }
1696 }
1697
1698 # ----- @module install.tcl -----
1699
1700 set modsource(install.tcl) {
1701 # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1702 # All rights reserved
1703
1704 # Module which can install autosetup
1705
1706 # autosetup(installed)=1 means that autosetup is not running from source
1707 # autosetup(sysinstall)=1 means that autosetup is running from a sysinstall version
1708 # shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1709
1710 proc autosetup_install {dir {shared 0}} {
1711 global autosetup
1712 if {$shared} {
1713 if {$autosetup(installed) || $autosetup(sysinstall)} {
1714 user-error "Can only --sysinstall from development sources"
1715 }
1716 } elseif {$autosetup(installed) && !$autosetup(sysinstall)} {
1717 user-error "Can't --install from project install"
1718 }
1719
1720 if {$autosetup(sysinstall)} {
1721 # This is the sysinstall version, so install just uses references
1722 cd $dir
1723
1724 puts "[autosetup_version] creating configure to use system-installed autosetup"
1725 autosetup_create_configure 1
1726 puts "Creating autosetup/README.autosetup"
1727 file mkdir autosetup
1728 autosetup_install_readme autosetup/README.autosetup 1
1729 return
1730 }
1731
1732 if {[catch {
1733 if {$shared} {
1734 set target $dir/bin/autosetup
1735 set installedas $target
1736 } else {
1737 if {$dir eq "."} {
1738 set installedas autosetup
1739 } else {
1740 set installedas $dir/autosetup
1741 }
1742 cd $dir
1743 file mkdir autosetup
1744 set target autosetup/autosetup
1745 }
1746 set targetdir [file dirname $target]
1747 file mkdir $targetdir
1748
1749 set f [open $target w]
1750
1751 set publicmodules {}
1752
1753 # First the main script, but only up until "CUT HERE"
1754 set in [open $autosetup(dir)/autosetup]
1755 while {[gets $in buf] >= 0} {
1756 if {$buf ne "##-- CUT HERE --##"} {
1757 puts $f $buf
1758 continue
1759 }
1760
1761 # Insert the static modules here
1762 # i.e. those which don't contain @synopsis:
1763 # All modules are inserted if $shared is set
1764 puts $f "set autosetup(installed) 1"
1765 puts $f "set autosetup(sysinstall) $shared"
1766 foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1767 set modname [file tail $file]
1768 set ext [file ext $modname]
1769 set buf [readfile $file]
1770 if {!$shared} {
1771 if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1772 lappend publicmodules $file
1773 continue
1774 }
1775 }
1776 dputs "install: importing lib/[file tail $file]"
1777 puts $f "# ----- @module $modname -----"
1778 puts $f "\nset modsource($modname) \{"
1779 puts $f $buf
1780 puts $f "\}\n"
1781 }
1782 if {$shared} {
1783 foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1784 $autosetup(srcdir)/LICENSE LICENSE] {
1785 dputs "install: importing $srcname as $destname"
1786 puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1787 }
1788 }
1789 }
1790 close $in
1791 close $f
1792 catch {exec chmod 755 $target}
1793
1794 set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1795 set removefiles {}
1796
1797 if {!$shared} {
1798 autosetup_install_readme $targetdir/README.autosetup 0
1799
1800 # Install public modules
1801 foreach file $publicmodules {
1802 set tail [file tail $file]
1803 autosetup_install_file $file $targetdir/$tail
1804 }
1805 lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1806 lappend removefiles config.guess config.sub test-tclsh find-tclsh
1807 } else {
1808 lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
1809 }
1810
1811 # Install support files
1812 foreach fileinfo $installfiles {
1813 if {[llength $fileinfo] == 2} {
1814 lassign $fileinfo source dest
1815 } else {
1816 lassign $fileinfo source
1817 set dest $source
1818 }
1819 autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1820 }
1821
1822 # Remove obsolete files
1823 foreach file $removefiles {
1824 if {[file exists $targetdir/$file]} {
1825 file delete $targetdir/$file
1826 }
1827 }
1828 } error]} {
1829 user-error "Failed to install autosetup: $error"
1830 }
1831 if {$shared} {
1832 set type "system"
1833 } else {
1834 set type "local"
1835 }
1836 puts "Installed $type [autosetup_version] to $installedas"
1837
1838 if {!$shared} {
1839 # Now create 'configure' if necessary
1840 autosetup_create_configure 0
1841 }
1842 }
1843
1844 proc autosetup_create_configure {shared} {
1845 if {[file exists configure]} {
1846 if {!$::autosetup(force)} {
1847 # Could this be an autosetup configure?
1848 if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1849 puts "I see configure, but not created by autosetup, so I won't overwrite it."
@@ -1527,40 +1854,75 @@
1854 puts "I will overwrite the existing configure because you used --force."
1855 }
1856 } else {
1857 puts "I don't see configure, so I will create it."
1858 }
1859 if {$shared} {
1860 writefile configure \
1861 {#!/bin/sh
1862 WRAPPER="$0"; export WRAPPER; "autosetup" "$@"
1863 }
1864 } else {
1865 writefile configure \
1866 {#!/bin/sh
1867 dir="`dirname "$0"`/autosetup"
1868 WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
1869 }
1870 }
1871 catch {exec chmod 755 configure}
1872 }
1873
1874 # Append the contents of $file to filehandle $f
1875 proc autosetup_install_append {f file} {
1876 dputs "install: include $file"
1877 set in [open $file]
1878 puts $f [read $in]
1879 close $in
1880 }
1881
1882 proc autosetup_install_file {source target} {
1883 dputs "install: $source => $target"
1884 if {![file exists $source]} {
1885 error "Missing installation file '$source'"
1886 }
1887 writefile $target [readfile $source]\n
1888 # If possible, copy the file mode
1889 file stat $source stat
1890 set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1891 catch {exec chmod $mode $target}
1892 }
1893
1894 proc autosetup_install_readme {target sysinstall} {
1895 set readme "README.autosetup created by [autosetup_version]\n\n"
1896 if {$sysinstall} {
1897 append readme \
1898 {This is the autosetup directory for a system install of autosetup.
1899 Loadable modules can be added here.
1900 }
1901 } else {
1902 append readme \
1903 {This is the autosetup directory for a local install of autosetup.
1904 It contains autosetup, support files and loadable modules.
1905 }
1906 }
1907
1908 append readme {
1909 *.tcl files in this directory are optional modules which
1910 can be loaded with the 'use' directive.
1911
1912 *.auto files in this directory are auto-loaded.
1913
1914 For more information, see http://msteveb.github.com/autosetup/
1915 }
1916 dputs "install: autosetup/README.autosetup"
1917 writefile $target $readme
1918 }
1919 }
1920
1921 # ----- @module markdown-formatting.tcl -----
1922
1923 set modsource(markdown-formatting.tcl) {
1924 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1925 # All rights reserved
1926
1927 # Module which provides text formatting
1928 # markdown format (kramdown syntax)
@@ -1627,13 +1989,13 @@
1989 }
1990 puts "$defn"
1991 }
1992 }
1993
1994 # ----- @module misc.tcl -----
1995
1996 set modsource(misc.tcl) {
1997 # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
1998 # All rights reserved
1999
2000 # Module containing misc procs useful to modules
2001 # Largely for platform compatibility
@@ -1805,106 +2167,218 @@
2167 string trim $result
2168 }
2169 }
2170 }
2171
2172 # ----- @module text-formatting.tcl -----
2173
2174 set modsource(text-formatting.tcl) {
2175 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2176 # All rights reserved
2177
2178 # Module which provides text formatting
2179
2180 use formatting
2181
2182 proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
2183 set len 0
2184 set space $firstprefix
2185
2186 foreach word [split $text] {
2187 set word [string trim $word]
2188 if {$word eq ""} {
2189 continue
2190 }
2191 if {[info exists partial]} {
2192 append partial " " $word
2193 if {[string first $quote $word] < 0} {
2194 # Haven't found end of quoted word
2195 continue
2196 }
2197 # Finished quoted word
2198 set word $partial
2199 unset partial
2200 unset quote
2201 } else {
2202 set quote [string index $word 0]
2203 if {$quote in {' *}} {
2204 if {[string first $quote $word 1] < 0} {
2205 # Haven't found end of quoted word
2206 # Not a whole word.
2207 set first [string index $word 0]
2208 # Start of quoted word
2209 set partial $word
2210 continue
2211 }
2212 }
2213 }
2214
2215 if {$len && [string length $space$word] + $len >= $length} {
2216 puts ""
2217 set len 0
2218 set space $nextprefix
2219 }
2220 incr len [string length $space$word]
2221
2222 # Use man-page conventions for highlighting 'quoted' and *quoted*
2223 # single words.
2224 # Use x^Hx for *bold* and _^Hx for 'underline'.
2225 #
2226 # less and more will both understand this.
2227 # Pipe through 'col -b' to remove them.
2228 if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2229 set quoted [string map {~ " "} $quoted]
2230 regsub -all . $quoted "&\b&" quoted
2231 set word $quoted$after
2232 } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2233 set quoted [string map {~ " "} $quoted]
2234 regsub -all . $quoted "_\b&" quoted
2235 set word $quoted$after
2236 }
2237 puts -nonewline $space$word
2238 set space " "
2239 }
2240 if {[info exists partial]} {
2241 # Missing end of quote
2242 puts -nonewline $space$partial
2243 }
2244 if {$len} {
2245 puts ""
2246 }
2247 }
2248 proc title {text} {
2249 underline [string trim $text] =
2250 nl
2251 }
2252 proc p {text} {
2253 wordwrap $text 80
2254 nl
2255 }
2256 proc codelines {lines} {
2257 foreach line $lines {
2258 puts " $line"
2259 }
2260 nl
2261 }
2262 proc nl {} {
2263 puts ""
2264 }
2265 proc underline {text char} {
2266 regexp "^(\[ \t\]*)(.*)" $text -> indent words
2267 puts $text
2268 puts $indent[string repeat $char [string length $words]]
2269 }
2270 proc section {text} {
2271 underline "[string trim $text]" -
2272 nl
2273 }
2274 proc subsection {text} {
2275 underline "$text" ~
2276 nl
2277 }
2278 proc bullet {text} {
2279 wordwrap $text 76 " * " " "
2280 }
2281 proc indent {text} {
2282 wordwrap $text 76 " " " "
2283 }
2284 proc defn {first args} {
2285 if {$first ne ""} {
2286 underline " $first" ~
2287 }
2288 foreach p $args {
2289 if {$p ne ""} {
2290 indent $p
2291 }
2292 }
2293 }
2294 }
2295
2296 # ----- @module util.tcl -----
2297
2298 set modsource(util.tcl) {
2299 # Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2300 # All rights reserved
2301
2302 # Module which contains miscellaneous utility functions
2303
2304 # @compare-versions version1 version2
2305 #
2306 # Versions are of the form 'a.b.c' (may be any number of numeric components)
2307 #
2308 # Compares the two versions and returns:
2309 ## -1 if v1 < v2
2310 ## 0 if v1 == v2
2311 ## 1 if v1 > v2
2312 #
2313 # If one version has fewer components than the other, 0 is substituted to the right. e.g.
2314 ## 0.2 < 0.3
2315 ## 0.2.5 > 0.2
2316 ## 1.1 == 1.1.0
2317 #
2318 proc compare-versions {v1 v2} {
2319 foreach c1 [split $v1 .] c2 [split $v2 .] {
2320 if {$c1 eq ""} {
2321 set c1 0
2322 }
2323 if {$c2 eq ""} {
2324 set c2 0
2325 }
2326 if {$c1 < $c2} {
2327 return -1
2328 }
2329 if {$c1 > $c2} {
2330 return 1
2331 }
2332 }
2333 return 0
2334 }
2335
2336 # @suffix suf list
2337 #
2338 # Takes a list and returns a new list with '$suf' appended
2339 # to each element
2340 #
2341 ## suffix .c {a b c} => {a.c b.c c.c}
2342 #
2343 proc suffix {suf list} {
2344 set result {}
2345 foreach p $list {
2346 lappend result $p$suf
2347 }
2348 return $result
2349 }
2350
2351 # @prefix pre list
2352 #
2353 # Takes a list and returns a new list with '$pre' prepended
2354 # to each element
2355 #
2356 ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2357 #
2358 proc prefix {pre list} {
2359 set result {}
2360 foreach p $list {
2361 lappend result $pre$p
2362 }
2363 return $result
2364 }
2365
2366 # @lpop list
2367 #
2368 # Removes the last entry from the given list and returns it.
2369 proc lpop {listname} {
2370 upvar $listname list
2371 set val [lindex $list end]
2372 set list [lrange $list 0 end-1]
2373 return $val
2374 }
2375 }
2376
2377 # ----- @module wiki-formatting.tcl -----
2378
2379 set modsource(wiki-formatting.tcl) {
2380 # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2381 # All rights reserved
2382
2383 # Module which provides text formatting
2384 # wiki.tcl.tk format output
@@ -1975,11 +2449,11 @@
2449 if {$autosetup(debug)} {
2450 main $argv
2451 }
2452 if {[catch {main $argv} msg opts] == 1} {
2453 show-notices
2454 autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
2455 if {!$autosetup(debug)} {
2456 puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
2457 }
2458 exit 1
2459 }
2460
2461 DDED autosetup/autosetup-config.guess
2462 DDED autosetup/autosetup-config.sub
2463 DDED autosetup/autosetup-find-tclsh
2464 DDED autosetup/autosetup-test-tclsh
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -1,6 +1,8 @@
11
#! /bin/sh
22
# Attempt to guess a canonical system name.
3
-# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
3
+# Copyright 1992-2018 Free Software Foundation, Inc.
4
+
5
+timestamp='2018-03-08it and/or modify it
46
# under the terms of the GNU General Public License as published by
57
# t;e Free Software Foundation, either version 3 of the L;cense, or
68
# (at your option) any later version.
@@ -13,7 +15,7 @@
1315
# You should have received a copy of the GNU General Public License
1416
# along with this program; if not, see <https://www.gnu.org/licenses/>.
1517
#
16
-# As a special exceptionto the GNU General Public License, if you
18
+# As a special exception to the GNU General Public License, if you
1719
# distribute this file as part of a program that contains a
1820
# configuration script generated by Autoconf, you may include it under
1921
# the same distribution terms that you use for the rest of that
@@ -23,28 +25,4 @@
2325
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
2426
#
2527
# You can get the latest version of this script from:
26
-# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
-
28
-$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29
- cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30
-# Attempt to guess a canoniAttempt to g! /bin/sh
31
-# Attemp#*) machine=${! /bin/sh
32
-# Attemp#! /bin/sh
33
-# Attempt to guess a canonical system name.
34
-# Copyright 1992-2018canonical system name.
35
-# Copyrig! /bin/sh
36
-# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37
-# Attemp#! /bin/sh
38
-# Attempt to guess a ${! /bin/sh
39
-# Attemp#! /bin/sh
40
-# Attempt to guess a cekkoBSD:*:*)
41
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43
-# Attempt to guess a canonical system name.
44
-# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45
-# Copyright 1992-2018 Free Software Foundation, Inc.
46
-
47
-timestamp='2018-03-08it and/or modify it
48
-# under the terms of the GNU General Public License as published by
49
-# t;e Free Software Foundation, either version 3 of the L;cense, or
50
-# (at your o
28
+# https://git.savannah.gnu.org/
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
 
 
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
@@ -13,7 +15,7 @@
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exceptionto the GNU General Public License, if you
17 # distribute this file as part of a program that contains a
18 # configuration script generated by Autoconf, you may include it under
19 # the same distribution terms that you use for the rest of that
@@ -23,28 +25,4 @@
23 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24 #
25 # You can get the latest version of this script from:
26 # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
28 $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29 cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30 # Attempt to guess a canoniAttempt to g! /bin/sh
31 # Attemp#*) machine=${! /bin/sh
32 # Attemp#! /bin/sh
33 # Attempt to guess a canonical system name.
34 # Copyright 1992-2018canonical system name.
35 # Copyrig! /bin/sh
36 # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37 # Attemp#! /bin/sh
38 # Attempt to guess a ${! /bin/sh
39 # Attemp#! /bin/sh
40 # Attempt to guess a cekkoBSD:*:*)
41 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43 # Attempt to guess a canonical system name.
44 # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45 # Copyright 1992-2018 Free Software Foundation, Inc.
46
47 timestamp='2018-03-08it and/or modify it
48 # under the terms of the GNU General Public License as published by
49 # t;e Free Software Foundation, either version 3 of the L;cense, or
50 # (at your o
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2018 Free Software Foundation, Inc.
4
5 timestamp='2018-03-08it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # t;e Free Software Foundation, either version 3 of the L;cense, or
8 # (at your option) any later version.
@@ -13,7 +15,7 @@
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <https://www.gnu.org/licenses/>.
17 #
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
21 # the same distribution terms that you use for the rest of that
@@ -23,28 +25,4 @@
25 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
26 #
27 # You can get the latest version of this script from:
28 # https://git.savannah.gnu.org/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -0,0 +1,28 @@
1
+#! /bin/sh
2
+# Attempt to guess a canonical system name.
3
+# Copyright 1992-2018 Free Software Foundation, Inc.
4
+
5
+timestamp='2018-03-08it and/or modify it
6
+# under the terms of the GNU General Public License as published by
7
+# t;e Free Software Foundation, either version 3 of the L;cense, or
8
+# (at your option) any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful, but
11
+# WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+# General Public License for more details.
14
+#
15
+# You should have received a copy of the GNU General Public License
16
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
17
+#
18
+# As a special exception to the GNU General Public License, if you
19
+# distribute this file as part of a program that contains a
20
+# configuration script generated by Autoconf, you may include it under
21
+# the same distribution terms that you use for the rest of that
22
+# program. This Exception is an additional permission under section 7
23
+# of the GNU General Public License, version 3 ("GPLv3").
24
+#
25
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
26
+#
27
+# You can get the latest version of this script from:
28
+# https://git.savannah.gnu.org/
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.guess
+++ b/autosetup/autosetup-config.guess
@@ -0,0 +1,28 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2018 Free Software Foundation, Inc.
4
5 timestamp='2018-03-08it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # t;e Free Software Foundation, either version 3 of the L;cense, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <https://www.gnu.org/licenses/>.
17 #
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
21 # the same distribution terms that you use for the rest of that
22 # program. This Exception is an additional permission under section 7
23 # of the GNU General Public License, version 3 ("GPLv3").
24 #
25 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
26 #
27 # You can get the latest version of this script from:
28 # https://git.savannah.gnu.org/
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -1,6 +1,8 @@
11
#! /bin/sh
22
# Configuration validation subroutine script.
3
-# Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
3
+# Copyright 1992-2018 Free Software Foundation, Inc.
4
+
5
+timestamp='2018-03-08it and/or modify it
46
# under the terms of the GNU General Public License as published by
57
# t;e Free Software Foundation, either version 3 of the L;cense, or
68
# (at your option) any later version.
@@ -13,7 +15,6 @@
1315
# You should have received a copy of the GNU General Public License
1416
# along with this program; if not, see <https://www.gnu.org/licenses/>.
1517
#
16
-# As a special exception#
1718
# As a special exception to the GNU General Public License, if you
1819
# distribute this file as part of a program that contains a
1920
# configuration script generated by Autoconf, you may include it under
@@ -30,46 +31,5 @@
3031
3132
'orting which valid configurations
3233
# it does not support. The user should be able to distinguish
33
-# a failure to support;hb=HEAD
34
- $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35
-# distribute this file as part of a program that contains a
36
-# configuration script generated by Autoconf, you may include it under
37
-# the same distribution terms that you use for the rest of that
38
-# program. This Excepti4 Free Software Foundation, Inc.
39
-
40
-er section 7
41
-# of the GNU General Public License, version 3 ("GPLv3").
42
-
43
-
44
-# Please send patches to <[email protected]>.
45
-#
46
-# Configuration subroutine to validate and canonicalize a configuration type.
47
-# Supply the specified configuration type as an argument.
48
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
-
50
-'orting which valid configurations
51
-# it does not support. The user should be able to distinguish
5234
# a failure to support a valid configuration from a meaningless
53
-# configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54
-# Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55
- ;;
56
- msbut
57
-# WITHOUT ANY W#! /bin/sh
58
-# Configuration validation subroutine script.
59
-# Copyright 1992-2018 Free Software Foundation, Inc.
60
-
61
-timestamp='2018-03-08it and/or modify it
62
-# under the terms of the GNU General Public License as published by
63
-# t;e Free Software Foundation, either version 3 of the L;cense, or
64
-# (at your option) any later version.
65
-#
66
-# This program is distributed in the hope that it will be useful, but
67
-# WITHOUT ANY WARRANTY; without even the implied warranty of
68
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69
- os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70
-# Configuration validation subroutine script.
71
-# Copyright 1992-2018 Free Software Foundation, Inc.
72
-
73
-timestamp='2018-03-08it and/or modify it
74
-# under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75
- ;
35
+# configur
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
 
 
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
@@ -13,7 +15,6 @@
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exception#
17 # As a special exception to the GNU General Public License, if you
18 # distribute this file as part of a program that contains a
19 # configuration script generated by Autoconf, you may include it under
@@ -30,46 +31,5 @@
30
31 'orting which valid configurations
32 # it does not support. The user should be able to distinguish
33 # a failure to support;hb=HEAD
34 $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35 # distribute this file as part of a program that contains a
36 # configuration script generated by Autoconf, you may include it under
37 # the same distribution terms that you use for the rest of that
38 # program. This Excepti4 Free Software Foundation, Inc.
39
40 er section 7
41 # of the GNU General Public License, version 3 ("GPLv3").
42
43
44 # Please send patches to <[email protected]>.
45 #
46 # Configuration subroutine to validate and canonicalize a configuration type.
47 # Supply the specified configuration type as an argument.
48 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
50 'orting which valid configurations
51 # it does not support. The user should be able to distinguish
52 # a failure to support a valid configuration from a meaningless
53 # configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54 # Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55 ;;
56 msbut
57 # WITHOUT ANY W#! /bin/sh
58 # Configuration validation subroutine script.
59 # Copyright 1992-2018 Free Software Foundation, Inc.
60
61 timestamp='2018-03-08it and/or modify it
62 # under the terms of the GNU General Public License as published by
63 # t;e Free Software Foundation, either version 3 of the L;cense, or
64 # (at your option) any later version.
65 #
66 # This program is distributed in the hope that it will be useful, but
67 # WITHOUT ANY WARRANTY; without even the implied warranty of
68 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69 os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70 # Configuration validation subroutine script.
71 # Copyright 1992-2018 Free Software Foundation, Inc.
72
73 timestamp='2018-03-08it and/or modify it
74 # under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75 ;
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -1,6 +1,8 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2018 Free Software Foundation, Inc.
4
5 timestamp='2018-03-08it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # t;e Free Software Foundation, either version 3 of the L;cense, or
8 # (at your option) any later version.
@@ -13,7 +15,6 @@
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <https://www.gnu.org/licenses/>.
17 #
 
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
@@ -30,46 +31,5 @@
31
32 'orting which valid configurations
33 # it does not support. The user should be able to distinguish
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34 # a failure to support a valid configuration from a meaningless
35 # configur
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -0,0 +1,35 @@
1
+#! /bin/sh
2
+# Configuration validation subroutine script.
3
+# Copyright 1992-2018 Free Software Foundation, Inc.
4
+
5
+timestamp='2018-03-08it and/or modify it
6
+# under the terms of the GNU General Public License as published by
7
+# t;e Free Software Foundation, either version 3 of the L;cense, or
8
+# (at your option) any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful, but
11
+# WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+# General Public License for more details.
14
+#
15
+# You should have received a copy of the GNU General Public License
16
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
17
+#
18
+# As a special exception to the GNU General Public License, if you
19
+# distribute this file as part of a program that contains a
20
+# configuration script generated by Autoconf, you may include it under
21
+# the same distribution terms that you use for the rest of that
22
+# program. This Exception is an additional permission under section 7
23
+# of the GNU General Public License, version 3 ("GPLv3").
24
+
25
+
26
+# Please send patches to <[email protected]>.
27
+#
28
+# Configuration subroutine to validate and canonicalize a configuration type.
29
+# Supply the specified configuration type as an argument.
30
+# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
31
+
32
+'orting which valid configurations
33
+# it does not support. The user should be able to distinguish
34
+# a failure to support a valid configuration from a meaningless
35
+# configur
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-config.sub
+++ b/autosetup/autosetup-config.sub
@@ -0,0 +1,35 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2018 Free Software Foundation, Inc.
4
5 timestamp='2018-03-08it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # t;e Free Software Foundation, either version 3 of the L;cense, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <https://www.gnu.org/licenses/>.
17 #
18 # As a special exception to the GNU General Public License, if you
19 # distribute this file as part of a program that contains a
20 # configuration script generated by Autoconf, you may include it under
21 # the same distribution terms that you use for the rest of that
22 # program. This Exception is an additional permission under section 7
23 # of the GNU General Public License, version 3 ("GPLv3").
24
25
26 # Please send patches to <[email protected]>.
27 #
28 # Configuration subroutine to validate and canonicalize a configuration type.
29 # Supply the specified configuration type as an argument.
30 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
31
32 'orting which valid configurations
33 # it does not support. The user should be able to distinguish
34 # a failure to support a valid configuration from a meaningless
35 # configur
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -1,10 +1,12 @@
11
#!/bin/sh
22
# Looks for a suitable tclsh or jimsh in the PATH
3
-# If not foundstrap jimsh d=`dirname "$0"`
4
-{ "$d/jimshd/${1-ac"; } 2>&1done
5
-echo 1>&2 bootstrap jimsh0"
6
-for cc in tclsh8.7; do
7
- { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/devexit 0
3
+# If not foundstrap jimsh in current dir from source
4
+# Prefer $autosetup_tclsh i
5
+d=`dirname "$0"`
6
+{ "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7
+done
8
+echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9
+for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
810
done
911
echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
1012
for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -1,10 +1,12 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh d=`dirname "$0"`
4 { "$d/jimshd/${1-ac"; } 2>&1done
5 echo 1>&2 bootstrap jimsh0"
6 for cc in tclsh8.7; do
7 { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/devexit 0
 
 
8 done
9 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -1,10 +1,12 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh in current dir from source
4 # Prefer $autosetup_tclsh i
5 d=`dirname "$0"`
6 { "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7 done
8 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9 for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
10 done
11 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
12 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -0,0 +1,12 @@
1
+#!/bin/sh
2
+# Looks for a suitable tclsh or jimsh in the PATH
3
+# If not foundstrap jimsh in current dir from source
4
+# Prefer $autosetup_tclsh i
5
+d=`dirname "$0"`
6
+{ "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7
+done
8
+echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9
+for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
10
+done
11
+echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
12
+for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-find-tclsh
+++ b/autosetup/autosetup-find-tclsh
@@ -0,0 +1,12 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh in current dir from source
4 # Prefer $autosetup_tclsh i
5 d=`dirname "$0"`
6 { "$d/jimshd/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
7 done
8 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
9 for cc in $ { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/dev/null && exit 0
10 done
11 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
12 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null

No diff available

--- a/autosetup/autosetup-test-tclsh
+++ b/autosetup/autosetup-test-tclsh
@@ -0,0 +1,20 @@
1
+# A small Tcl script to verify that the chosen
2
+# interpreter works. Sometimes we might e.g. pick up
3
+# an interpreter for a different arch.
4
+# Outputs the full path to the interpreter
5
+
6
+if {[catch {info version} version] == 0} {
7
+ # This is Jim Tcl
8
+ if {$version >= 0.72} {
9
+ # Ensure that regexp works
10
+ regexp (a.*?) a
11
+ puts [info nameofexecutable]
12
+ exit 0
13
+ }
14
+} elseif {[catch {info tclversion} version] == 0} {
15
+ if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16
+ puts [info nameofexecutable]
17
+ exit 0
18
+ }
19
+}
20
+exit 1
--- a/autosetup/autosetup-test-tclsh
+++ b/autosetup/autosetup-test-tclsh
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/autosetup/autosetup-test-tclsh
+++ b/autosetup/autosetup-test-tclsh
@@ -0,0 +1,20 @@
1 # A small Tcl script to verify that the chosen
2 # interpreter works. Sometimes we might e.g. pick up
3 # an interpreter for a different arch.
4 # Outputs the full path to the interpreter
5
6 if {[catch {info version} version] == 0} {
7 # This is Jim Tcl
8 if {$version >= 0.72} {
9 # Ensure that regexp works
10 regexp (a.*?) a
11 puts [info nameofexecutable]
12 exit 0
13 }
14 } elseif {[catch {info tclversion} version] == 0} {
15 if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16 puts [info nameofexecutable]
17 exit 0
18 }
19 }
20 exit 1
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
11
# Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
22
# All rights reserved
33
44
# @synopsis:
55
#
6
-# The 'cc-db' module provides a knowledge based of system idiosyncrasies
7
-# In general, this module can always be included
6
+# The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7
+# In general, this module can always be included.
88
99
use cc
1010
1111
module-options {}
1212
1313
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc-db' module provides a knowledge based of system idiosyncrasies
7 # In general, this module can always be included
8
9 use cc
10
11 module-options {}
12
13
--- autosetup/cc-db.tcl
+++ autosetup/cc-db.tcl
@@ -1,12 +1,12 @@
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7 # In general, this module can always be included.
8
9 use cc
10
11 module-options {}
12
13
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,12 +9,12 @@
99
1010
module-options {}
1111
1212
# @cc-check-lfs
1313
#
14
-# The equivalent of the AC_SYS_LARGEFILE macro
15
-#
14
+# The equivalent of the 'AC_SYS_LARGEFILE' macro.
15
+#
1616
# defines 'HAVE_LFS' if LFS is available,
1717
# and defines '_FILE_OFFSET_BITS=64' if necessary
1818
#
1919
# Returns 1 if 'LFS' is available or 0 otherwise
2020
#
@@ -35,12 +35,12 @@
3535
return $lfs
3636
}
3737
3838
# @cc-check-endian
3939
#
40
-# The equivalent of the AC_C_BIGENDIAN macro
41
-#
40
+# The equivalent of the 'AC_C_BIGENDIAN' macro.
41
+#
4242
# defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
4343
# or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
4444
#
4545
# Returns 1 if determined, or 0 if not.
4646
#
@@ -80,112 +80,110 @@
8080
#
8181
# Checks whether the given C/C++ compiler flags can be used. Defines feature
8282
# names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
8383
# appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
8484
proc cc-check-flags {args} {
85
- set result 1
86
- array set opts [cc-get-settings]
87
- switch -exact -- $opts(-lang) {
88
- c++ {
89
- set lang C++
90
- set prefix CXXFLAG
91
- }
92
- c {
93
- set lang C
94
- set prefix CFLAG
95
- }
96
- default {
97
- autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98
- }
99
- }
100
- foreach flag $args {
101
- msg-checking "Checking whether the $lang compiler accepts $flag..."
102
- if {[cctest -cflags $flag]} {
103
- msg-result yes
104
- define-feature $prefix$flag
105
- cc-with [list -cflags [list $flag]]
106
- define-append ${prefix}S $flag
107
- } else {
108
- msg-result no
109
- set result 0
110
- }
111
- }
112
- return $result
85
+ set result 1
86
+ array set opts [cc-get-settings]
87
+ switch -exact -- $opts(-lang) {
88
+ c++ {
89
+ set lang C++
90
+ set prefix CXXFLAG
91
+ }
92
+ c {
93
+ set lang C
94
+ set prefix CFLAG
95
+ }
96
+ default {
97
+ autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98
+ }
99
+ }
100
+ foreach flag $args {
101
+ msg-checking "Checking whether the $lang compiler accepts $flag..."
102
+ if {[cctest -cflags $flag]} {
103
+ msg-result yes
104
+ define-feature $prefix$flag
105
+ cc-with [list -cflags [list $flag]]
106
+ define-append ${prefix}S $flag
107
+ } else {
108
+ msg-result no
109
+ set result 0
110
+ }
111
+ }
112
+ return $result
113113
}
114114
115115
# @cc-check-standards ver ?...?
116116
#
117117
# Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118118
# options, and appends the first working one to '-cflags' and 'CFLAGS' or
119119
# 'CXXFLAGS'.
120120
proc cc-check-standards {args} {
121
- array set opts [cc-get-settings]
122
- foreach std $args {
123
- if {[cc-check-flags -std=$std]} {
124
- return $std
125
- }
126
- }
127
- return ""
121
+ array set opts [cc-get-settings]
122
+ foreach std $args {
123
+ if {[cc-check-flags -std=$std]} {
124
+ return $std
125
+ }
126
+ }
127
+ return ""
128128
}
129129
130130
# Checks whether $keyword is usable as alignof
131131
proc cctest_alignof {keyword} {
132
- msg-checking "Checking for $keyword..."
133
- if {[cctest -code [subst -nobackslashes {
134
- printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x'));
135
- }]]} then {
136
- msg-result ok
137
- define-feature $keyword
138
- } else {
139
- msg-result "not found"
140
- }
132
+ msg-checking "Checking for $keyword..."
133
+ if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
134
+ msg-result ok
135
+ define-feature $keyword
136
+ } else {
137
+ msg-result "not found"
138
+ }
141139
}
142140
143141
# @cc-check-c11
144142
#
145143
# Checks for several C11/C++11 extensions and their alternatives. Currently
146144
# checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
147145
proc cc-check-c11 {} {
148
- msg-checking "Checking for _Static_assert..."
149
- if {[cctest -code {
150
- _Static_assert(1, "static assertions are available");
151
- }]} then {
152
- msg-result ok
153
- define-feature _Static_assert
154
- } else {
155
- msg-result "not found"
156
- }
157
-
158
- cctest_alignof _Alignof
159
- cctest_alignof __alignof__
160
- cctest_alignof __alignof
146
+ msg-checking "Checking for _Static_assert..."
147
+ if {[cctest -code {
148
+ _Static_assert(1, "static assertions are available");
149
+ }]} then {
150
+ msg-result ok
151
+ define-feature _Static_assert
152
+ } else {
153
+ msg-result "not found"
154
+ }
155
+
156
+ cctest_alignof _Alignof
157
+ cctest_alignof __alignof__
158
+ cctest_alignof __alignof
161159
}
162160
163161
# @cc-check-alloca
164162
#
165
-# The equivalent of the AC_FUNC_ALLOCA macro
163
+# The equivalent of the 'AC_FUNC_ALLOCA' macro.
166164
#
167
-# Checks for the existence of alloca
168
-# defines HAVE_ALLOCA and returns 1 if it exists
165
+# Checks for the existence of 'alloca'
166
+# defines 'HAVE_ALLOCA' and returns 1 if it exists.
169167
proc cc-check-alloca {} {
170
- cc-check-some-feature alloca {
171
- cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
172
- }
168
+ cc-check-some-feature alloca {
169
+ cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
170
+ }
173171
}
174172
175173
# @cc-signal-return-type
176174
#
177
-# The equivalent of the AC_TYPE_SIGNAL macro
175
+# The equivalent of the 'AC_TYPE_SIGNAL' macro.
178176
#
179
-# defines RETSIGTYPE to int or void
177
+# defines 'RETSIGTYPE' to 'int' or 'void'.
180178
proc cc-signal-return-type {} {
181
- msg-checking "Checking return type of signal handlers..."
182
- cc-with {-includes {sys/types.h signal.h}} {
183
- if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
184
- set type int
185
- } else {
186
- set type void
187
- }
188
- define RETSIGTYPE $type
189
- msg-result $type
190
- }
179
+ msg-checking "Checking return type of signal handlers..."
180
+ cc-with {-includes {sys/types.h signal.h}} {
181
+ if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
182
+ set type int
183
+ } else {
184
+ set type void
185
+ }
186
+ define RETSIGTYPE $type
187
+ msg-result $type
188
+ }
191189
}
192190
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,12 +9,12 @@
9
10 module-options {}
11
12 # @cc-check-lfs
13 #
14 # The equivalent of the AC_SYS_LARGEFILE macro
15 #
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
18 #
19 # Returns 1 if 'LFS' is available or 0 otherwise
20 #
@@ -35,12 +35,12 @@
35 return $lfs
36 }
37
38 # @cc-check-endian
39 #
40 # The equivalent of the AC_C_BIGENDIAN macro
41 #
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
44 #
45 # Returns 1 if determined, or 0 if not.
46 #
@@ -80,112 +80,110 @@
80 #
81 # Checks whether the given C/C++ compiler flags can be used. Defines feature
82 # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
83 # appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
84 proc cc-check-flags {args} {
85 set result 1
86 array set opts [cc-get-settings]
87 switch -exact -- $opts(-lang) {
88 c++ {
89 set lang C++
90 set prefix CXXFLAG
91 }
92 c {
93 set lang C
94 set prefix CFLAG
95 }
96 default {
97 autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98 }
99 }
100 foreach flag $args {
101 msg-checking "Checking whether the $lang compiler accepts $flag..."
102 if {[cctest -cflags $flag]} {
103 msg-result yes
104 define-feature $prefix$flag
105 cc-with [list -cflags [list $flag]]
106 define-append ${prefix}S $flag
107 } else {
108 msg-result no
109 set result 0
110 }
111 }
112 return $result
113 }
114
115 # @cc-check-standards ver ?...?
116 #
117 # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118 # options, and appends the first working one to '-cflags' and 'CFLAGS' or
119 # 'CXXFLAGS'.
120 proc cc-check-standards {args} {
121 array set opts [cc-get-settings]
122 foreach std $args {
123 if {[cc-check-flags -std=$std]} {
124 return $std
125 }
126 }
127 return ""
128 }
129
130 # Checks whether $keyword is usable as alignof
131 proc cctest_alignof {keyword} {
132 msg-checking "Checking for $keyword..."
133 if {[cctest -code [subst -nobackslashes {
134 printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x'));
135 }]]} then {
136 msg-result ok
137 define-feature $keyword
138 } else {
139 msg-result "not found"
140 }
141 }
142
143 # @cc-check-c11
144 #
145 # Checks for several C11/C++11 extensions and their alternatives. Currently
146 # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
147 proc cc-check-c11 {} {
148 msg-checking "Checking for _Static_assert..."
149 if {[cctest -code {
150 _Static_assert(1, "static assertions are available");
151 }]} then {
152 msg-result ok
153 define-feature _Static_assert
154 } else {
155 msg-result "not found"
156 }
157
158 cctest_alignof _Alignof
159 cctest_alignof __alignof__
160 cctest_alignof __alignof
161 }
162
163 # @cc-check-alloca
164 #
165 # The equivalent of the AC_FUNC_ALLOCA macro
166 #
167 # Checks for the existence of alloca
168 # defines HAVE_ALLOCA and returns 1 if it exists
169 proc cc-check-alloca {} {
170 cc-check-some-feature alloca {
171 cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
172 }
173 }
174
175 # @cc-signal-return-type
176 #
177 # The equivalent of the AC_TYPE_SIGNAL macro
178 #
179 # defines RETSIGTYPE to int or void
180 proc cc-signal-return-type {} {
181 msg-checking "Checking return type of signal handlers..."
182 cc-with {-includes {sys/types.h signal.h}} {
183 if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
184 set type int
185 } else {
186 set type void
187 }
188 define RETSIGTYPE $type
189 msg-result $type
190 }
191 }
192
--- autosetup/cc-lib.tcl
+++ autosetup/cc-lib.tcl
@@ -9,12 +9,12 @@
9
10 module-options {}
11
12 # @cc-check-lfs
13 #
14 # The equivalent of the 'AC_SYS_LARGEFILE' macro.
15 #
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
18 #
19 # Returns 1 if 'LFS' is available or 0 otherwise
20 #
@@ -35,12 +35,12 @@
35 return $lfs
36 }
37
38 # @cc-check-endian
39 #
40 # The equivalent of the 'AC_C_BIGENDIAN' macro.
41 #
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
44 #
45 # Returns 1 if determined, or 0 if not.
46 #
@@ -80,112 +80,110 @@
80 #
81 # Checks whether the given C/C++ compiler flags can be used. Defines feature
82 # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
83 # appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'.
84 proc cc-check-flags {args} {
85 set result 1
86 array set opts [cc-get-settings]
87 switch -exact -- $opts(-lang) {
88 c++ {
89 set lang C++
90 set prefix CXXFLAG
91 }
92 c {
93 set lang C
94 set prefix CFLAG
95 }
96 default {
97 autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
98 }
99 }
100 foreach flag $args {
101 msg-checking "Checking whether the $lang compiler accepts $flag..."
102 if {[cctest -cflags $flag]} {
103 msg-result yes
104 define-feature $prefix$flag
105 cc-with [list -cflags [list $flag]]
106 define-append ${prefix}S $flag
107 } else {
108 msg-result no
109 set result 0
110 }
111 }
112 return $result
113 }
114
115 # @cc-check-standards ver ?...?
116 #
117 # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
118 # options, and appends the first working one to '-cflags' and 'CFLAGS' or
119 # 'CXXFLAGS'.
120 proc cc-check-standards {args} {
121 array set opts [cc-get-settings]
122 foreach std $args {
123 if {[cc-check-flags -std=$std]} {
124 return $std
125 }
126 }
127 return ""
128 }
129
130 # Checks whether $keyword is usable as alignof
131 proc cctest_alignof {keyword} {
132 msg-checking "Checking for $keyword..."
133 if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
134 msg-result ok
135 define-feature $keyword
136 } else {
137 msg-result "not found"
138 }
 
 
139 }
140
141 # @cc-check-c11
142 #
143 # Checks for several C11/C++11 extensions and their alternatives. Currently
144 # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
145 proc cc-check-c11 {} {
146 msg-checking "Checking for _Static_assert..."
147 if {[cctest -code {
148 _Static_assert(1, "static assertions are available");
149 }]} then {
150 msg-result ok
151 define-feature _Static_assert
152 } else {
153 msg-result "not found"
154 }
155
156 cctest_alignof _Alignof
157 cctest_alignof __alignof__
158 cctest_alignof __alignof
159 }
160
161 # @cc-check-alloca
162 #
163 # The equivalent of the 'AC_FUNC_ALLOCA' macro.
164 #
165 # Checks for the existence of 'alloca'
166 # defines 'HAVE_ALLOCA' and returns 1 if it exists.
167 proc cc-check-alloca {} {
168 cc-check-some-feature alloca {
169 cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
170 }
171 }
172
173 # @cc-signal-return-type
174 #
175 # The equivalent of the 'AC_TYPE_SIGNAL' macro.
176 #
177 # defines 'RETSIGTYPE' to 'int' or 'void'.
178 proc cc-signal-return-type {} {
179 msg-checking "Checking return type of signal handlers..."
180 cc-with {-includes {sys/types.h signal.h}} {
181 if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
182 set type int
183 } else {
184 set type void
185 }
186 define RETSIGTYPE $type
187 msg-result $type
188 }
189 }
190
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -7,27 +7,30 @@
77
# It defines the following variables:
88
#
99
## SH_CFLAGS Flags to use compiling sources destined for a shared library
1010
## SH_LDFLAGS Flags to use linking (creating) a shared library
1111
## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
12
+## SH_SOFULLPATH Set to 1 if the shared library soname should include the full install path
1213
## SH_SOEXT Extension for shared libs
1314
## SH_SOEXTVER Format for versioned shared libs - %s = version
1415
## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
1516
## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
1617
## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
18
+## SH_LINKRPATH Format for setting the rpath when linking an executable, %s = path
1719
## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
1820
## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
1921
## STRIPLIBFLAGS Arguments to strip a dynamic library
2022
2123
module-options {}
2224
2325
# Defaults: gcc on unix
24
-define SHOBJ_CFLAGS -fpic
26
+define SHOBJ_CFLAGS -fPIC
2527
define SHOBJ_LDFLAGS -shared
26
-define SH_CFLAGS -fpic
28
+define SH_CFLAGS -fPIC
2729
define SH_LDFLAGS -shared
2830
define SH_LINKFLAGS -rdynamic
31
+define SH_LINKRPATH "-Wl,-rpath -Wl,%s"
2932
define SH_SOEXT .so
3033
define SH_SOEXTVER .so.%s
3134
define SH_SOPREFIX -Wl,-soname,
3235
define LD_LIBRARY_PATH LD_LIBRARY_PATH
3336
define STRIPLIBFLAGS --strip-unneeded
@@ -44,18 +47,20 @@
4447
define SH_LDFLAGS -dynamiclib
4548
define SH_LINKFLAGS ""
4649
define SH_SOEXT .dylib
4750
define SH_SOEXTVER .%s.dylib
4851
define SH_SOPREFIX -Wl,-install_name,
52
+ define SH_SOFULLPATH
4953
define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
5054
define STRIPLIBFLAGS -x
5155
}
5256
*-*-ming* - *-*-cygwin - *-*-msys {
5357
define SHOBJ_CFLAGS ""
5458
define SHOBJ_LDFLAGS -shared
5559
define SH_CFLAGS ""
5660
define SH_LDFLAGS -shared
61
+ define SH_LINKRPATH ""
5762
define SH_LINKFLAGS ""
5863
define SH_SOEXT .dll
5964
define SH_SOEXTVER .dll
6065
define SH_SOPREFIX ""
6166
define LD_LIBRARY_PATH PATH
@@ -62,27 +67,23 @@
6267
}
6368
sparc* {
6469
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
6570
msg-result "Found sun stdio compiler"
6671
# sun stdio compiler
67
- # XXX: These haven't been fully tested.
72
+ # XXX: These haven't been fully tested.
6873
define SHOBJ_CFLAGS -KPIC
6974
define SHOBJ_LDFLAGS "-G"
7075
define SH_CFLAGS -KPIC
7176
define SH_LINKFLAGS -Wl,-export-dynamic
7277
define SH_SOPREFIX -Wl,-h,
73
- } else {
74
- # sparc has a very small GOT table limit, so use -fPIC
75
- define SH_CFLAGS -fPIC
76
- define SHOBJ_CFLAGS -fPIC
7778
}
7879
}
7980
*-*-solaris* {
8081
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
8182
msg-result "Found sun stdio compiler"
8283
# sun stdio compiler
83
- # XXX: These haven't been fully tested.
84
+ # XXX: These haven't been fully tested.
8485
define SHOBJ_CFLAGS -KPIC
8586
define SHOBJ_LDFLAGS "-G"
8687
define SH_CFLAGS -KPIC
8788
define SH_LINKFLAGS -Wl,-export-dynamic
8889
define SH_SOPREFIX -Wl,-h,
@@ -103,15 +104,10 @@
103104
define SH_LDFLAGS -shared
104105
define SH_LINKFLAGS ""
105106
define SH_SOPREFIX ""
106107
define LD_LIBRARY_PATH LIBRARY_PATH
107108
}
108
- microblaze* {
109
- # Microblaze generally needs -fPIC rather than -fpic
110
- define SHOBJ_CFLAGS -fPIC
111
- define SH_CFLAGS -fPIC
112
- }
113109
}
114110
115111
if {![is-defined SHOBJ_LDFLAGS_R]} {
116112
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
117113
}
118114
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -7,27 +7,30 @@
7 # It defines the following variables:
8 #
9 ## SH_CFLAGS Flags to use compiling sources destined for a shared library
10 ## SH_LDFLAGS Flags to use linking (creating) a shared library
11 ## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
 
12 ## SH_SOEXT Extension for shared libs
13 ## SH_SOEXTVER Format for versioned shared libs - %s = version
14 ## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
15 ## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
16 ## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
 
17 ## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
18 ## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
19 ## STRIPLIBFLAGS Arguments to strip a dynamic library
20
21 module-options {}
22
23 # Defaults: gcc on unix
24 define SHOBJ_CFLAGS -fpic
25 define SHOBJ_LDFLAGS -shared
26 define SH_CFLAGS -fpic
27 define SH_LDFLAGS -shared
28 define SH_LINKFLAGS -rdynamic
 
29 define SH_SOEXT .so
30 define SH_SOEXTVER .so.%s
31 define SH_SOPREFIX -Wl,-soname,
32 define LD_LIBRARY_PATH LD_LIBRARY_PATH
33 define STRIPLIBFLAGS --strip-unneeded
@@ -44,18 +47,20 @@
44 define SH_LDFLAGS -dynamiclib
45 define SH_LINKFLAGS ""
46 define SH_SOEXT .dylib
47 define SH_SOEXTVER .%s.dylib
48 define SH_SOPREFIX -Wl,-install_name,
 
49 define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
50 define STRIPLIBFLAGS -x
51 }
52 *-*-ming* - *-*-cygwin - *-*-msys {
53 define SHOBJ_CFLAGS ""
54 define SHOBJ_LDFLAGS -shared
55 define SH_CFLAGS ""
56 define SH_LDFLAGS -shared
 
57 define SH_LINKFLAGS ""
58 define SH_SOEXT .dll
59 define SH_SOEXTVER .dll
60 define SH_SOPREFIX ""
61 define LD_LIBRARY_PATH PATH
@@ -62,27 +67,23 @@
62 }
63 sparc* {
64 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
65 msg-result "Found sun stdio compiler"
66 # sun stdio compiler
67 # XXX: These haven't been fully tested.
68 define SHOBJ_CFLAGS -KPIC
69 define SHOBJ_LDFLAGS "-G"
70 define SH_CFLAGS -KPIC
71 define SH_LINKFLAGS -Wl,-export-dynamic
72 define SH_SOPREFIX -Wl,-h,
73 } else {
74 # sparc has a very small GOT table limit, so use -fPIC
75 define SH_CFLAGS -fPIC
76 define SHOBJ_CFLAGS -fPIC
77 }
78 }
79 *-*-solaris* {
80 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
81 msg-result "Found sun stdio compiler"
82 # sun stdio compiler
83 # XXX: These haven't been fully tested.
84 define SHOBJ_CFLAGS -KPIC
85 define SHOBJ_LDFLAGS "-G"
86 define SH_CFLAGS -KPIC
87 define SH_LINKFLAGS -Wl,-export-dynamic
88 define SH_SOPREFIX -Wl,-h,
@@ -103,15 +104,10 @@
103 define SH_LDFLAGS -shared
104 define SH_LINKFLAGS ""
105 define SH_SOPREFIX ""
106 define LD_LIBRARY_PATH LIBRARY_PATH
107 }
108 microblaze* {
109 # Microblaze generally needs -fPIC rather than -fpic
110 define SHOBJ_CFLAGS -fPIC
111 define SH_CFLAGS -fPIC
112 }
113 }
114
115 if {![is-defined SHOBJ_LDFLAGS_R]} {
116 define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
117 }
118
--- autosetup/cc-shared.tcl
+++ autosetup/cc-shared.tcl
@@ -7,27 +7,30 @@
7 # It defines the following variables:
8 #
9 ## SH_CFLAGS Flags to use compiling sources destined for a shared library
10 ## SH_LDFLAGS Flags to use linking (creating) a shared library
11 ## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
12 ## SH_SOFULLPATH Set to 1 if the shared library soname should include the full install path
13 ## SH_SOEXT Extension for shared libs
14 ## SH_SOEXTVER Format for versioned shared libs - %s = version
15 ## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
16 ## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
17 ## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
18 ## SH_LINKRPATH Format for setting the rpath when linking an executable, %s = path
19 ## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
20 ## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
21 ## STRIPLIBFLAGS Arguments to strip a dynamic library
22
23 module-options {}
24
25 # Defaults: gcc on unix
26 define SHOBJ_CFLAGS -fPIC
27 define SHOBJ_LDFLAGS -shared
28 define SH_CFLAGS -fPIC
29 define SH_LDFLAGS -shared
30 define SH_LINKFLAGS -rdynamic
31 define SH_LINKRPATH "-Wl,-rpath -Wl,%s"
32 define SH_SOEXT .so
33 define SH_SOEXTVER .so.%s
34 define SH_SOPREFIX -Wl,-soname,
35 define LD_LIBRARY_PATH LD_LIBRARY_PATH
36 define STRIPLIBFLAGS --strip-unneeded
@@ -44,18 +47,20 @@
47 define SH_LDFLAGS -dynamiclib
48 define SH_LINKFLAGS ""
49 define SH_SOEXT .dylib
50 define SH_SOEXTVER .%s.dylib
51 define SH_SOPREFIX -Wl,-install_name,
52 define SH_SOFULLPATH
53 define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
54 define STRIPLIBFLAGS -x
55 }
56 *-*-ming* - *-*-cygwin - *-*-msys {
57 define SHOBJ_CFLAGS ""
58 define SHOBJ_LDFLAGS -shared
59 define SH_CFLAGS ""
60 define SH_LDFLAGS -shared
61 define SH_LINKRPATH ""
62 define SH_LINKFLAGS ""
63 define SH_SOEXT .dll
64 define SH_SOEXTVER .dll
65 define SH_SOPREFIX ""
66 define LD_LIBRARY_PATH PATH
@@ -62,27 +67,23 @@
67 }
68 sparc* {
69 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
70 msg-result "Found sun stdio compiler"
71 # sun stdio compiler
72 # XXX: These haven't been fully tested.
73 define SHOBJ_CFLAGS -KPIC
74 define SHOBJ_LDFLAGS "-G"
75 define SH_CFLAGS -KPIC
76 define SH_LINKFLAGS -Wl,-export-dynamic
77 define SH_SOPREFIX -Wl,-h,
 
 
 
 
78 }
79 }
80 *-*-solaris* {
81 if {[msg-quiet cc-check-decls __SUNPRO_C]} {
82 msg-result "Found sun stdio compiler"
83 # sun stdio compiler
84 # XXX: These haven't been fully tested.
85 define SHOBJ_CFLAGS -KPIC
86 define SHOBJ_LDFLAGS "-G"
87 define SH_CFLAGS -KPIC
88 define SH_LINKFLAGS -Wl,-export-dynamic
89 define SH_SOPREFIX -Wl,-h,
@@ -103,15 +104,10 @@
104 define SH_LDFLAGS -shared
105 define SH_LINKFLAGS ""
106 define SH_SOPREFIX ""
107 define LD_LIBRARY_PATH LIBRARY_PATH
108 }
 
 
 
 
 
109 }
110
111 if {![is-defined SHOBJ_LDFLAGS_R]} {
112 define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
113 }
114
+80 -52
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,17 +2,18 @@
22
# All rights reserved
33
44
# @synopsis:
55
#
66
# The 'cc' module supports checking various 'features' of the C or C++
7
-# compiler/linker environment. Common commands are cc-check-includes,
8
-# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
7
+# compiler/linker environment. Common commands are 'cc-check-includes',
8
+# 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
99
#
1010
# The following environment variables are used if set:
1111
#
1212
## CC - C compiler
1313
## CXX - C++ compiler
14
+## CPP - C preprocessor
1415
## CCACHE - Set to "none" to disable automatic use of ccache
1516
## CFLAGS - Additional C compiler flags
1617
## CXXFLAGS - Additional C++ compiler flags
1718
## LDFLAGS - Additional compiler flags during linking
1819
## LIBS - Additional libraries to use (for all tests)
@@ -28,15 +29,10 @@
2829
2930
use system
3031
3132
module-options {}
3233
33
-# Note that the return code is not meaningful
34
-proc cc-check-something {name code} {
35
- uplevel 1 $code
36
-}
37
-
3834
# Checks for the existence of the given function by linking
3935
#
4036
proc cctest_function {function} {
4137
cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
4238
}
@@ -68,12 +64,12 @@
6864
}
6965
7066
# @cc-check-sizeof type ...
7167
#
7268
# Checks the size of the given types (between 1 and 32, inclusive).
73
-# Defines a variable with the size determined, or "unknown" otherwise.
74
-# e.g. for type 'long long', defines SIZEOF_LONG_LONG.
69
+# Defines a variable with the size determined, or 'unknown' otherwise.
70
+# e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
7571
# Returns the size of the last type.
7672
#
7773
proc cc-check-sizeof {args} {
7874
foreach type $args {
7975
msg-checking "Checking for sizeof $type..."
@@ -109,11 +105,11 @@
109105
return $ret
110106
}
111107
112108
# @cc-check-includes includes ...
113109
#
114
-# Checks that the given include files can be used
110
+# Checks that the given include files can be used.
115111
proc cc-check-includes {args} {
116112
cc-check-some-feature $args {
117113
set with {}
118114
if {[dict exists $::autosetup(cc-include-deps) $each]} {
119115
set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +130,12 @@
134130
}
135131
}
136132
137133
# @cc-include-needs include required ...
138134
#
139
-# Ensures that when checking for 'include', a check is first
140
-# made for each 'required' file, and if found, it is #included
135
+# Ensures that when checking for '$include', a check is first
136
+# made for each '$required' file, and if found, it is included with '#include'.
141137
proc cc-include-needs {file args} {
142138
foreach depfile $args {
143139
dict set ::autosetup(cc-include-deps) $file $depfile 1
144140
}
145141
}
@@ -153,22 +149,22 @@
153149
}
154150
}
155151
156152
# @cc-check-defines define ...
157153
#
158
-# Checks that the given preprocessor symbol is defined
154
+# Checks that the given preprocessor symbols are defined.
159155
proc cc-check-defines {args} {
160156
cc-check-some-feature $args {
161157
cctest_define $each
162158
}
163159
}
164160
165161
# @cc-check-decls name ...
166162
#
167163
# Checks that each given name is either a preprocessor symbol or rvalue
168
-# such as an enum. Note that the define used is HAVE_DECL_xxx
169
-# rather than HAVE_xxx
164
+# such as an enum. Note that the define used is 'HAVE_DECL_xxx'
165
+# rather than 'HAVE_xxx'.
170166
proc cc-check-decls {args} {
171167
set ret 1
172168
foreach name $args {
173169
msg-checking "Checking for $name..."
174170
set r [cctest_decl $name]
@@ -183,21 +179,21 @@
183179
return $ret
184180
}
185181
186182
# @cc-check-functions function ...
187183
#
188
-# Checks that the given functions exist (can be linked)
184
+# Checks that the given functions exist (can be linked).
189185
proc cc-check-functions {args} {
190186
cc-check-some-feature $args {
191187
cctest_function $each
192188
}
193189
}
194190
195191
# @cc-check-members type.member ...
196192
#
197193
# Checks that the given type/structure members exist.
198
-# A structure member is of the form "struct stat.st_mtime"
194
+# A structure member is of the form 'struct stat.st_mtime'.
199195
proc cc-check-members {args} {
200196
cc-check-some-feature $args {
201197
cctest_member $each
202198
}
203199
}
@@ -207,20 +203,20 @@
207203
# Checks that the given function can be found in one of the libs.
208204
#
209205
# First checks for no library required, then checks each of the libraries
210206
# in turn.
211207
#
212
-# If the function is found, the feature is defined and lib_$function is defined
213
-# to -l$lib where the function was found, or "" if no library required.
214
-# In addition, -l$lib is prepended to the LIBS define.
208
+# If the function is found, the feature is defined and 'lib_$function' is defined
209
+# to '-l$lib' where the function was found, or "" if no library required.
210
+# In addition, '-l$lib' is prepended to the 'LIBS' define.
215211
#
216212
# If additional libraries may be needed for linking, they should be specified
217
-# as $extralibs as "-lotherlib1 -lotherlib2".
218
-# These libraries are not automatically added to LIBS.
213
+# with '$extralibs' as '-lotherlib1 -lotherlib2'.
214
+# These libraries are not automatically added to 'LIBS'.
219215
#
220216
# Returns 1 if found or 0 if not.
221
-#
217
+#
222218
proc cc-check-function-in-lib {function libs {otherlibs {}}} {
223219
msg-checking "Checking libs for $function..."
224220
set found 0
225221
cc-with [list -libs $otherlibs] {
226222
if {[cctest_function $function]} {
@@ -240,13 +236,12 @@
240236
}
241237
}
242238
}
243239
}
244240
}
245
- if {$found} {
246
- define [feature-define-name $function]
247
- } else {
241
+ define-feature $function $found
242
+ if {!$found} {
248243
msg-result "no"
249244
}
250245
return $found
251246
}
252247
@@ -253,16 +248,16 @@
253248
# @cc-check-tools tool ...
254249
#
255250
# Checks for existence of the given compiler tools, taking
256251
# into account any cross compilation prefix.
257252
#
258
-# For example, when checking for "ar", first AR is checked on the command
259
-# line and then in the environment. If not found, "${host}-ar" or
260
-# simply "ar" is assumed depending upon whether cross compiling.
261
-# The path is searched for this executable, and if found AR is defined
253
+# For example, when checking for 'ar', first 'AR' is checked on the command
254
+# line and then in the environment. If not found, '${host}-ar' or
255
+# simply 'ar' is assumed depending upon whether cross compiling.
256
+# The path is searched for this executable, and if found 'AR' is defined
262257
# to the executable name.
263
-# Note that even when cross compiling, the simple "ar" is used as a fallback,
258
+# Note that even when cross compiling, the simple 'ar' is used as a fallback,
264259
# but a warning is generated. This is necessary for some toolchains.
265260
#
266261
# It is an error if the executable is not found.
267262
#
268263
proc cc-check-tools {args} {
@@ -284,14 +279,14 @@
284279
285280
# @cc-check-progs prog ...
286281
#
287282
# Checks for existence of the given executables on the path.
288283
#
289
-# For example, when checking for "grep", the path is searched for
290
-# the executable, 'grep', and if found GREP is defined as "grep".
284
+# For example, when checking for 'grep', the path is searched for
285
+# the executable, 'grep', and if found 'GREP' is defined as 'grep'.
291286
#
292
-# If the executable is not found, the variable is defined as false.
287
+# If the executable is not found, the variable is defined as 'false'.
293288
# Returns 1 if all programs were found, or 0 otherwise.
294289
#
295290
proc cc-check-progs {args} {
296291
set failed 0
297292
foreach prog $args {
@@ -303,10 +298,33 @@
303298
incr failed
304299
} else {
305300
msg-result ok
306301
define $PROG $prog
307302
}
303
+ }
304
+ expr {!$failed}
305
+}
306
+
307
+# @cc-path-progs prog ...
308
+#
309
+# Like cc-check-progs, but sets the define to the full path rather
310
+# than just the program name.
311
+#
312
+proc cc-path-progs {args} {
313
+ set failed 0
314
+ foreach prog $args {
315
+ set PROG [string toupper $prog]
316
+ msg-checking "Checking for $prog..."
317
+ set path [find-executable-path $prog]
318
+ if {$path eq ""} {
319
+ msg-result no
320
+ define $PROG false
321
+ incr failed
322
+ } else {
323
+ msg-result $path
324
+ define $PROG $path
325
+ }
308326
}
309327
expr {!$failed}
310328
}
311329
312330
# Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +344,18 @@
326344
327345
foreach {name value} $settings {
328346
switch -exact -- $name {
329347
-cflags - -includes {
330348
# These are given as lists
331
- lappend new($name) {*}$value
349
+ lappend new($name) {*}[list-non-empty $value]
332350
}
333351
-declare {
334352
lappend new($name) $value
335353
}
336354
-libs {
337355
# Note that new libraries are added before previous libraries
338
- set new($name) [list {*}$value {*}$new($name)]
356
+ set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
339357
}
340358
-link - -lang - -nooutput {
341359
set new($name) $value
342360
}
343361
-source - -sourcefile - -code {
@@ -373,16 +391,16 @@
373391
return $prev
374392
}
375393
376394
# @cc-with settings ?{ script }?
377395
#
378
-# Sets the given 'cctest' settings and then runs the tests in 'script'.
379
-# Note that settings such as -lang replace the current setting, while
380
-# those such as -includes are appended to the existing setting.
396
+# Sets the given 'cctest' settings and then runs the tests in '$script'.
397
+# Note that settings such as '-lang' replace the current setting, while
398
+# those such as '-includes' are appended to the existing setting.
381399
#
382400
# If no script is given, the settings become the default for the remainder
383
-# of the auto.def file.
401
+# of the 'auto.def' file.
384402
#
385403
## cc-with {-lang c++} {
386404
## # This will check with the C++ compiler
387405
## cc-check-types bool
388406
## cc-with {-includes signal.h} {
@@ -390,11 +408,11 @@
390408
## ...
391409
## }
392410
## # back to just the C++ compiler
393411
## }
394412
#
395
-# The -libs setting is special in that newer values are added *before* earlier ones.
413
+# The '-libs' setting is special in that newer values are added *before* earlier ones.
396414
#
397415
## cc-with {-libs {-lc -lm}} {
398416
## cc-with {-libs -ldl} {
399417
## cctest -libs -lsocket ...
400418
## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -415,12 +433,12 @@
415433
return $result
416434
}
417435
}
418436
419437
# @cctest ?settings?
420
-#
421
-# Low level C compiler checker. Compiles and or links a small C program
438
+#
439
+# Low level C/C++ compiler checker. Compiles and or links a small C program
422440
# according to the arguments and returns 1 if OK, or 0 if not.
423441
#
424442
# Supported settings are:
425443
#
426444
## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +450,11 @@
432450
## -code code Code to compile in the body of main()
433451
## -source code Compile a complete program. Ignore -includes, -declare and -code
434452
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
435453
## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
436454
#
437
-# Unless -source or -sourcefile is specified, the C program looks like:
455
+# Unless '-source' or '-sourcefile' is specified, the C program looks like:
438456
#
439457
## #include <firstinclude> /* same for remaining includes in the list */
440458
##
441459
## declare-code /* any code in -declare, verbatim */
442460
##
@@ -446,11 +464,10 @@
446464
## }
447465
#
448466
# Any failures are recorded in 'config.log'
449467
#
450468
proc cctest {args} {
451
- set src conftest__.c
452469
set tmp conftest__
453470
454471
# Easiest way to merge in the settings
455472
cc-with $args {
456473
array set opts [cc-get-settings]
@@ -488,13 +505,15 @@
488505
# Build the command line
489506
set cmdline {}
490507
lappend cmdline {*}[get-define CCACHE]
491508
switch -exact -- $opts(-lang) {
492509
c++ {
510
+ set src conftest__.cpp
493511
lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
494512
}
495513
c {
514
+ set src conftest__.c
496515
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
497516
}
498517
default {
499518
autosetup-error "cctest called with unknown language: $opts(-lang)"
500519
}
@@ -554,32 +573,32 @@
554573
return $ok
555574
}
556575
557576
# @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
558577
#
559
-# Deprecated - see make-config-header
578
+# Deprecated - see 'make-config-header'
560579
proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
561580
user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
562581
make-config-header $file -auto $autopatterns -bare $barepatterns
563582
}
564583
565584
# @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
566585
#
567586
# Examines all defined variables which match the given patterns
568
-# and writes an include file, $file, which defines each of these.
587
+# and writes an include file, '$file', which defines each of these.
569588
# Variables which match '-auto' are output as follows:
570
-# - defines which have the value "0" are ignored.
589
+# - defines which have the value '0' are ignored.
571590
# - defines which have integer values are defined as the integer value.
572
-# - any other value is defined as a string, e.g. "value"
591
+# - any other value is defined as a string, e.g. '"value"'
573592
# Variables which match '-bare' are defined as-is.
574
-# Variables which match '-str' are defined as a string, e.g. "value"
593
+# Variables which match '-str' are defined as a string, e.g. '"value"'
575594
# Variables which match '-none' are omitted.
576595
#
577
-# Note that order is important. The first pattern which matches is selected
596
+# Note that order is important. The first pattern that matches is selected.
578597
# Default behaviour is:
579598
#
580
-# -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
599
+## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
581600
#
582601
# If the file would be unchanged, it is not written.
583602
proc make-config-header {file args} {
584603
set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
585604
file mkdir [file dirname $file]
@@ -677,10 +696,19 @@
677696
if {[get-define CC] eq ""} {
678697
user-error "Could not find a C compiler. Tried: [join $try ", "]"
679698
}
680699
681700
define CCACHE [find-an-executable [get-env CCACHE ccache]]
701
+
702
+# If any of these are set in the environment, propagate them to the AUTOREMAKE commandline
703
+foreach i {CC CXX CCACHE CPP CFLAGS CXXFLAGS CXXFLAGS LDFLAGS LIBS CROSS CPPFLAGS LINKFLAGS CC_FOR_BUILD LD} {
704
+ if {[env-is-set $i]} {
705
+ # Note: If the variable is set on the command line, get-env will return that value
706
+ # so the command line will continue to override the environment
707
+ define-append AUTOREMAKE [quote-if-needed $i=[get-env $i ""]]
708
+ }
709
+}
682710
683711
# Initial cctest settings
684712
cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
685713
set autosetup(cc-include-deps) {}
686714
687715
688716
DELETED autosetup/config.guess
689717
DELETED autosetup/config.sub
690718
DELETED autosetup/find-tclsh
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,17 +2,18 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are cc-check-includes,
8 # cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
 
14 ## CCACHE - Set to "none" to disable automatic use of ccache
15 ## CFLAGS - Additional C compiler flags
16 ## CXXFLAGS - Additional C++ compiler flags
17 ## LDFLAGS - Additional compiler flags during linking
18 ## LIBS - Additional libraries to use (for all tests)
@@ -28,15 +29,10 @@
28
29 use system
30
31 module-options {}
32
33 # Note that the return code is not meaningful
34 proc cc-check-something {name code} {
35 uplevel 1 $code
36 }
37
38 # Checks for the existence of the given function by linking
39 #
40 proc cctest_function {function} {
41 cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
42 }
@@ -68,12 +64,12 @@
68 }
69
70 # @cc-check-sizeof type ...
71 #
72 # Checks the size of the given types (between 1 and 32, inclusive).
73 # Defines a variable with the size determined, or "unknown" otherwise.
74 # e.g. for type 'long long', defines SIZEOF_LONG_LONG.
75 # Returns the size of the last type.
76 #
77 proc cc-check-sizeof {args} {
78 foreach type $args {
79 msg-checking "Checking for sizeof $type..."
@@ -109,11 +105,11 @@
109 return $ret
110 }
111
112 # @cc-check-includes includes ...
113 #
114 # Checks that the given include files can be used
115 proc cc-check-includes {args} {
116 cc-check-some-feature $args {
117 set with {}
118 if {[dict exists $::autosetup(cc-include-deps) $each]} {
119 set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +130,12 @@
134 }
135 }
136
137 # @cc-include-needs include required ...
138 #
139 # Ensures that when checking for 'include', a check is first
140 # made for each 'required' file, and if found, it is #included
141 proc cc-include-needs {file args} {
142 foreach depfile $args {
143 dict set ::autosetup(cc-include-deps) $file $depfile 1
144 }
145 }
@@ -153,22 +149,22 @@
153 }
154 }
155
156 # @cc-check-defines define ...
157 #
158 # Checks that the given preprocessor symbol is defined
159 proc cc-check-defines {args} {
160 cc-check-some-feature $args {
161 cctest_define $each
162 }
163 }
164
165 # @cc-check-decls name ...
166 #
167 # Checks that each given name is either a preprocessor symbol or rvalue
168 # such as an enum. Note that the define used is HAVE_DECL_xxx
169 # rather than HAVE_xxx
170 proc cc-check-decls {args} {
171 set ret 1
172 foreach name $args {
173 msg-checking "Checking for $name..."
174 set r [cctest_decl $name]
@@ -183,21 +179,21 @@
183 return $ret
184 }
185
186 # @cc-check-functions function ...
187 #
188 # Checks that the given functions exist (can be linked)
189 proc cc-check-functions {args} {
190 cc-check-some-feature $args {
191 cctest_function $each
192 }
193 }
194
195 # @cc-check-members type.member ...
196 #
197 # Checks that the given type/structure members exist.
198 # A structure member is of the form "struct stat.st_mtime"
199 proc cc-check-members {args} {
200 cc-check-some-feature $args {
201 cctest_member $each
202 }
203 }
@@ -207,20 +203,20 @@
207 # Checks that the given function can be found in one of the libs.
208 #
209 # First checks for no library required, then checks each of the libraries
210 # in turn.
211 #
212 # If the function is found, the feature is defined and lib_$function is defined
213 # to -l$lib where the function was found, or "" if no library required.
214 # In addition, -l$lib is prepended to the LIBS define.
215 #
216 # If additional libraries may be needed for linking, they should be specified
217 # as $extralibs as "-lotherlib1 -lotherlib2".
218 # These libraries are not automatically added to LIBS.
219 #
220 # Returns 1 if found or 0 if not.
221 #
222 proc cc-check-function-in-lib {function libs {otherlibs {}}} {
223 msg-checking "Checking libs for $function..."
224 set found 0
225 cc-with [list -libs $otherlibs] {
226 if {[cctest_function $function]} {
@@ -240,13 +236,12 @@
240 }
241 }
242 }
243 }
244 }
245 if {$found} {
246 define [feature-define-name $function]
247 } else {
248 msg-result "no"
249 }
250 return $found
251 }
252
@@ -253,16 +248,16 @@
253 # @cc-check-tools tool ...
254 #
255 # Checks for existence of the given compiler tools, taking
256 # into account any cross compilation prefix.
257 #
258 # For example, when checking for "ar", first AR is checked on the command
259 # line and then in the environment. If not found, "${host}-ar" or
260 # simply "ar" is assumed depending upon whether cross compiling.
261 # The path is searched for this executable, and if found AR is defined
262 # to the executable name.
263 # Note that even when cross compiling, the simple "ar" is used as a fallback,
264 # but a warning is generated. This is necessary for some toolchains.
265 #
266 # It is an error if the executable is not found.
267 #
268 proc cc-check-tools {args} {
@@ -284,14 +279,14 @@
284
285 # @cc-check-progs prog ...
286 #
287 # Checks for existence of the given executables on the path.
288 #
289 # For example, when checking for "grep", the path is searched for
290 # the executable, 'grep', and if found GREP is defined as "grep".
291 #
292 # If the executable is not found, the variable is defined as false.
293 # Returns 1 if all programs were found, or 0 otherwise.
294 #
295 proc cc-check-progs {args} {
296 set failed 0
297 foreach prog $args {
@@ -303,10 +298,33 @@
303 incr failed
304 } else {
305 msg-result ok
306 define $PROG $prog
307 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308 }
309 expr {!$failed}
310 }
311
312 # Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +344,18 @@
326
327 foreach {name value} $settings {
328 switch -exact -- $name {
329 -cflags - -includes {
330 # These are given as lists
331 lappend new($name) {*}$value
332 }
333 -declare {
334 lappend new($name) $value
335 }
336 -libs {
337 # Note that new libraries are added before previous libraries
338 set new($name) [list {*}$value {*}$new($name)]
339 }
340 -link - -lang - -nooutput {
341 set new($name) $value
342 }
343 -source - -sourcefile - -code {
@@ -373,16 +391,16 @@
373 return $prev
374 }
375
376 # @cc-with settings ?{ script }?
377 #
378 # Sets the given 'cctest' settings and then runs the tests in 'script'.
379 # Note that settings such as -lang replace the current setting, while
380 # those such as -includes are appended to the existing setting.
381 #
382 # If no script is given, the settings become the default for the remainder
383 # of the auto.def file.
384 #
385 ## cc-with {-lang c++} {
386 ## # This will check with the C++ compiler
387 ## cc-check-types bool
388 ## cc-with {-includes signal.h} {
@@ -390,11 +408,11 @@
390 ## ...
391 ## }
392 ## # back to just the C++ compiler
393 ## }
394 #
395 # The -libs setting is special in that newer values are added *before* earlier ones.
396 #
397 ## cc-with {-libs {-lc -lm}} {
398 ## cc-with {-libs -ldl} {
399 ## cctest -libs -lsocket ...
400 ## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -415,12 +433,12 @@
415 return $result
416 }
417 }
418
419 # @cctest ?settings?
420 #
421 # Low level C compiler checker. Compiles and or links a small C program
422 # according to the arguments and returns 1 if OK, or 0 if not.
423 #
424 # Supported settings are:
425 #
426 ## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +450,11 @@
432 ## -code code Code to compile in the body of main()
433 ## -source code Compile a complete program. Ignore -includes, -declare and -code
434 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
435 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
436 #
437 # Unless -source or -sourcefile is specified, the C program looks like:
438 #
439 ## #include <firstinclude> /* same for remaining includes in the list */
440 ##
441 ## declare-code /* any code in -declare, verbatim */
442 ##
@@ -446,11 +464,10 @@
446 ## }
447 #
448 # Any failures are recorded in 'config.log'
449 #
450 proc cctest {args} {
451 set src conftest__.c
452 set tmp conftest__
453
454 # Easiest way to merge in the settings
455 cc-with $args {
456 array set opts [cc-get-settings]
@@ -488,13 +505,15 @@
488 # Build the command line
489 set cmdline {}
490 lappend cmdline {*}[get-define CCACHE]
491 switch -exact -- $opts(-lang) {
492 c++ {
 
493 lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
494 }
495 c {
 
496 lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
497 }
498 default {
499 autosetup-error "cctest called with unknown language: $opts(-lang)"
500 }
@@ -554,32 +573,32 @@
554 return $ok
555 }
556
557 # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
558 #
559 # Deprecated - see make-config-header
560 proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
561 user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
562 make-config-header $file -auto $autopatterns -bare $barepatterns
563 }
564
565 # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
566 #
567 # Examines all defined variables which match the given patterns
568 # and writes an include file, $file, which defines each of these.
569 # Variables which match '-auto' are output as follows:
570 # - defines which have the value "0" are ignored.
571 # - defines which have integer values are defined as the integer value.
572 # - any other value is defined as a string, e.g. "value"
573 # Variables which match '-bare' are defined as-is.
574 # Variables which match '-str' are defined as a string, e.g. "value"
575 # Variables which match '-none' are omitted.
576 #
577 # Note that order is important. The first pattern which matches is selected
578 # Default behaviour is:
579 #
580 # -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
581 #
582 # If the file would be unchanged, it is not written.
583 proc make-config-header {file args} {
584 set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
585 file mkdir [file dirname $file]
@@ -677,10 +696,19 @@
677 if {[get-define CC] eq ""} {
678 user-error "Could not find a C compiler. Tried: [join $try ", "]"
679 }
680
681 define CCACHE [find-an-executable [get-env CCACHE ccache]]
 
 
 
 
 
 
 
 
 
682
683 # Initial cctest settings
684 cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
685 set autosetup(cc-include-deps) {}
686
687
688 ELETED autosetup/config.guess
689 ELETED autosetup/config.sub
690 ELETED autosetup/find-tclsh
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -2,17 +2,18 @@
2 # All rights reserved
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are 'cc-check-includes',
8 # 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
14 ## CPP - C preprocessor
15 ## CCACHE - Set to "none" to disable automatic use of ccache
16 ## CFLAGS - Additional C compiler flags
17 ## CXXFLAGS - Additional C++ compiler flags
18 ## LDFLAGS - Additional compiler flags during linking
19 ## LIBS - Additional libraries to use (for all tests)
@@ -28,15 +29,10 @@
29
30 use system
31
32 module-options {}
33
 
 
 
 
 
34 # Checks for the existence of the given function by linking
35 #
36 proc cctest_function {function} {
37 cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
38 }
@@ -68,12 +64,12 @@
64 }
65
66 # @cc-check-sizeof type ...
67 #
68 # Checks the size of the given types (between 1 and 32, inclusive).
69 # Defines a variable with the size determined, or 'unknown' otherwise.
70 # e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
71 # Returns the size of the last type.
72 #
73 proc cc-check-sizeof {args} {
74 foreach type $args {
75 msg-checking "Checking for sizeof $type..."
@@ -109,11 +105,11 @@
105 return $ret
106 }
107
108 # @cc-check-includes includes ...
109 #
110 # Checks that the given include files can be used.
111 proc cc-check-includes {args} {
112 cc-check-some-feature $args {
113 set with {}
114 if {[dict exists $::autosetup(cc-include-deps) $each]} {
115 set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
@@ -134,12 +130,12 @@
130 }
131 }
132
133 # @cc-include-needs include required ...
134 #
135 # Ensures that when checking for '$include', a check is first
136 # made for each '$required' file, and if found, it is included with '#include'.
137 proc cc-include-needs {file args} {
138 foreach depfile $args {
139 dict set ::autosetup(cc-include-deps) $file $depfile 1
140 }
141 }
@@ -153,22 +149,22 @@
149 }
150 }
151
152 # @cc-check-defines define ...
153 #
154 # Checks that the given preprocessor symbols are defined.
155 proc cc-check-defines {args} {
156 cc-check-some-feature $args {
157 cctest_define $each
158 }
159 }
160
161 # @cc-check-decls name ...
162 #
163 # Checks that each given name is either a preprocessor symbol or rvalue
164 # such as an enum. Note that the define used is 'HAVE_DECL_xxx'
165 # rather than 'HAVE_xxx'.
166 proc cc-check-decls {args} {
167 set ret 1
168 foreach name $args {
169 msg-checking "Checking for $name..."
170 set r [cctest_decl $name]
@@ -183,21 +179,21 @@
179 return $ret
180 }
181
182 # @cc-check-functions function ...
183 #
184 # Checks that the given functions exist (can be linked).
185 proc cc-check-functions {args} {
186 cc-check-some-feature $args {
187 cctest_function $each
188 }
189 }
190
191 # @cc-check-members type.member ...
192 #
193 # Checks that the given type/structure members exist.
194 # A structure member is of the form 'struct stat.st_mtime'.
195 proc cc-check-members {args} {
196 cc-check-some-feature $args {
197 cctest_member $each
198 }
199 }
@@ -207,20 +203,20 @@
203 # Checks that the given function can be found in one of the libs.
204 #
205 # First checks for no library required, then checks each of the libraries
206 # in turn.
207 #
208 # If the function is found, the feature is defined and 'lib_$function' is defined
209 # to '-l$lib' where the function was found, or "" if no library required.
210 # In addition, '-l$lib' is prepended to the 'LIBS' define.
211 #
212 # If additional libraries may be needed for linking, they should be specified
213 # with '$extralibs' as '-lotherlib1 -lotherlib2'.
214 # These libraries are not automatically added to 'LIBS'.
215 #
216 # Returns 1 if found or 0 if not.
217 #
218 proc cc-check-function-in-lib {function libs {otherlibs {}}} {
219 msg-checking "Checking libs for $function..."
220 set found 0
221 cc-with [list -libs $otherlibs] {
222 if {[cctest_function $function]} {
@@ -240,13 +236,12 @@
236 }
237 }
238 }
239 }
240 }
241 define-feature $function $found
242 if {!$found} {
 
243 msg-result "no"
244 }
245 return $found
246 }
247
@@ -253,16 +248,16 @@
248 # @cc-check-tools tool ...
249 #
250 # Checks for existence of the given compiler tools, taking
251 # into account any cross compilation prefix.
252 #
253 # For example, when checking for 'ar', first 'AR' is checked on the command
254 # line and then in the environment. If not found, '${host}-ar' or
255 # simply 'ar' is assumed depending upon whether cross compiling.
256 # The path is searched for this executable, and if found 'AR' is defined
257 # to the executable name.
258 # Note that even when cross compiling, the simple 'ar' is used as a fallback,
259 # but a warning is generated. This is necessary for some toolchains.
260 #
261 # It is an error if the executable is not found.
262 #
263 proc cc-check-tools {args} {
@@ -284,14 +279,14 @@
279
280 # @cc-check-progs prog ...
281 #
282 # Checks for existence of the given executables on the path.
283 #
284 # For example, when checking for 'grep', the path is searched for
285 # the executable, 'grep', and if found 'GREP' is defined as 'grep'.
286 #
287 # If the executable is not found, the variable is defined as 'false'.
288 # Returns 1 if all programs were found, or 0 otherwise.
289 #
290 proc cc-check-progs {args} {
291 set failed 0
292 foreach prog $args {
@@ -303,10 +298,33 @@
298 incr failed
299 } else {
300 msg-result ok
301 define $PROG $prog
302 }
303 }
304 expr {!$failed}
305 }
306
307 # @cc-path-progs prog ...
308 #
309 # Like cc-check-progs, but sets the define to the full path rather
310 # than just the program name.
311 #
312 proc cc-path-progs {args} {
313 set failed 0
314 foreach prog $args {
315 set PROG [string toupper $prog]
316 msg-checking "Checking for $prog..."
317 set path [find-executable-path $prog]
318 if {$path eq ""} {
319 msg-result no
320 define $PROG false
321 incr failed
322 } else {
323 msg-result $path
324 define $PROG $path
325 }
326 }
327 expr {!$failed}
328 }
329
330 # Adds the given settings to $::autosetup(ccsettings) and
@@ -326,18 +344,18 @@
344
345 foreach {name value} $settings {
346 switch -exact -- $name {
347 -cflags - -includes {
348 # These are given as lists
349 lappend new($name) {*}[list-non-empty $value]
350 }
351 -declare {
352 lappend new($name) $value
353 }
354 -libs {
355 # Note that new libraries are added before previous libraries
356 set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
357 }
358 -link - -lang - -nooutput {
359 set new($name) $value
360 }
361 -source - -sourcefile - -code {
@@ -373,16 +391,16 @@
391 return $prev
392 }
393
394 # @cc-with settings ?{ script }?
395 #
396 # Sets the given 'cctest' settings and then runs the tests in '$script'.
397 # Note that settings such as '-lang' replace the current setting, while
398 # those such as '-includes' are appended to the existing setting.
399 #
400 # If no script is given, the settings become the default for the remainder
401 # of the 'auto.def' file.
402 #
403 ## cc-with {-lang c++} {
404 ## # This will check with the C++ compiler
405 ## cc-check-types bool
406 ## cc-with {-includes signal.h} {
@@ -390,11 +408,11 @@
408 ## ...
409 ## }
410 ## # back to just the C++ compiler
411 ## }
412 #
413 # The '-libs' setting is special in that newer values are added *before* earlier ones.
414 #
415 ## cc-with {-libs {-lc -lm}} {
416 ## cc-with {-libs -ldl} {
417 ## cctest -libs -lsocket ...
418 ## # libs will be in this order: -lsocket -ldl -lc -lm
@@ -415,12 +433,12 @@
433 return $result
434 }
435 }
436
437 # @cctest ?settings?
438 #
439 # Low level C/C++ compiler checker. Compiles and or links a small C program
440 # according to the arguments and returns 1 if OK, or 0 if not.
441 #
442 # Supported settings are:
443 #
444 ## -cflags cflags A list of flags to pass to the compiler
@@ -432,11 +450,11 @@
450 ## -code code Code to compile in the body of main()
451 ## -source code Compile a complete program. Ignore -includes, -declare and -code
452 ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
453 ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
454 #
455 # Unless '-source' or '-sourcefile' is specified, the C program looks like:
456 #
457 ## #include <firstinclude> /* same for remaining includes in the list */
458 ##
459 ## declare-code /* any code in -declare, verbatim */
460 ##
@@ -446,11 +464,10 @@
464 ## }
465 #
466 # Any failures are recorded in 'config.log'
467 #
468 proc cctest {args} {
 
469 set tmp conftest__
470
471 # Easiest way to merge in the settings
472 cc-with $args {
473 array set opts [cc-get-settings]
@@ -488,13 +505,15 @@
505 # Build the command line
506 set cmdline {}
507 lappend cmdline {*}[get-define CCACHE]
508 switch -exact -- $opts(-lang) {
509 c++ {
510 set src conftest__.cpp
511 lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
512 }
513 c {
514 set src conftest__.c
515 lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
516 }
517 default {
518 autosetup-error "cctest called with unknown language: $opts(-lang)"
519 }
@@ -554,32 +573,32 @@
573 return $ok
574 }
575
576 # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
577 #
578 # Deprecated - see 'make-config-header'
579 proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
580 user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
581 make-config-header $file -auto $autopatterns -bare $barepatterns
582 }
583
584 # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
585 #
586 # Examines all defined variables which match the given patterns
587 # and writes an include file, '$file', which defines each of these.
588 # Variables which match '-auto' are output as follows:
589 # - defines which have the value '0' are ignored.
590 # - defines which have integer values are defined as the integer value.
591 # - any other value is defined as a string, e.g. '"value"'
592 # Variables which match '-bare' are defined as-is.
593 # Variables which match '-str' are defined as a string, e.g. '"value"'
594 # Variables which match '-none' are omitted.
595 #
596 # Note that order is important. The first pattern that matches is selected.
597 # Default behaviour is:
598 #
599 ## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
600 #
601 # If the file would be unchanged, it is not written.
602 proc make-config-header {file args} {
603 set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
604 file mkdir [file dirname $file]
@@ -677,10 +696,19 @@
696 if {[get-define CC] eq ""} {
697 user-error "Could not find a C compiler. Tried: [join $try ", "]"
698 }
699
700 define CCACHE [find-an-executable [get-env CCACHE ccache]]
701
702 # If any of these are set in the environment, propagate them to the AUTOREMAKE commandline
703 foreach i {CC CXX CCACHE CPP CFLAGS CXXFLAGS CXXFLAGS LDFLAGS LIBS CROSS CPPFLAGS LINKFLAGS CC_FOR_BUILD LD} {
704 if {[env-is-set $i]} {
705 # Note: If the variable is set on the command line, get-env will return that value
706 # so the command line will continue to override the environment
707 define-append AUTOREMAKE [quote-if-needed $i=[get-env $i ""]]
708 }
709 }
710
711 # Initial cctest settings
712 cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
713 set autosetup(cc-include-deps) {}
714
715
716 ELETED autosetup/config.guess
717 ELETED autosetup/config.sub
718 ELETED autosetup/find-tclsh
D autosetup/config.guess
-50
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
1
-#! /bin/sh
2
-# Attempt to guess a canonical system name.
3
-# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4
-# under the terms of the GNU General Public License as published by
5
-# t;e Free Software Foundation, either version 3 of the L;cense, or
6
-# (at your option) any later version.
7
-#
8
-# This program is distributed in the hope that it will be useful, but
9
-# WITHOUT ANY WARRANTY; without even the implied warranty of
10
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
-# General Public License for more details.
12
-#
13
-# You should have received a copy of the GNU General Public License
14
-# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
-#
16
-# As a special exceptionto the GNU General Public License, if you
17
-# distribute this file as part of a program that contains a
18
-# configuration script generated by Autoconf, you may include it under
19
-# the same distribution terms that you use for the rest of that
20
-# program. This Exception is an additional permission under section 7
21
-# of the GNU General Public License, version 3 ("GPLv3").
22
-#
23
-# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24
-#
25
-# You can get the latest version of this script from:
26
-# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
-
28
-$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29
- cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30
-# Attempt to guess a canoniAttempt to g! /bin/sh
31
-# Attemp#*) machine=${! /bin/sh
32
-# Attemp#! /bin/sh
33
-# Attempt to guess a canonical system name.
34
-# Copyright 1992-2018canonical system name.
35
-# Copyrig! /bin/sh
36
-# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37
-# Attemp#! /bin/sh
38
-# Attempt to guess a ${! /bin/sh
39
-# Attemp#! /bin/sh
40
-# Attempt to guess a cekkoBSD:*:*)
41
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42
- echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43
-# Attempt to guess a canonical system name.
44
-# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45
-# Copyright 1992-2018 Free Software Foundation, Inc.
46
-
47
-timestamp='2018-03-08it and/or modify it
48
-# under the terms of the GNU General Public License as published by
49
-# t;e Free Software Foundation, either version 3 of the L;cense, or
50
-# (at your o
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exceptionto the GNU General Public License, if you
17 # distribute this file as part of a program that contains a
18 # configuration script generated by Autoconf, you may include it under
19 # the same distribution terms that you use for the rest of that
20 # program. This Exception is an additional permission under section 7
21 # of the GNU General Public License, version 3 ("GPLv3").
22 #
23 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
24 #
25 # You can get the latest version of this script from:
26 # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc.
27
28 $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM}
29 cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl
30 # Attempt to guess a canoniAttempt to g! /bin/sh
31 # Attemp#*) machine=${! /bin/sh
32 # Attemp#! /bin/sh
33 # Attempt to guess a canonical system name.
34 # Copyright 1992-2018canonical system name.
35 # Copyrig! /bin/sh
36 # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh
37 # Attemp#! /bin/sh
38 # Attempt to guess a ${! /bin/sh
39 # Attemp#! /bin/sh
40 # Attempt to guess a cekkoBSD:*:*)
41 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*)
42 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh
43 # Attempt to guess a canonical system name.
44 # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name.
45 # Copyright 1992-2018 Free Software Foundation, Inc.
46
47 timestamp='2018-03-08it and/or modify it
48 # under the terms of the GNU General Public License as published by
49 # t;e Free Software Foundation, either version 3 of the L;cense, or
50 # (at your o
--- a/autosetup/config.guess
+++ b/autosetup/config.guess
@@ -1,50 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D autosetup/config.sub
-75
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
1
-#! /bin/sh
2
-# Configuration validation subroutine script.
3
-# Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4
-# under the terms of the GNU General Public License as published by
5
-# t;e Free Software Foundation, either version 3 of the L;cense, or
6
-# (at your option) any later version.
7
-#
8
-# This program is distributed in the hope that it will be useful, but
9
-# WITHOUT ANY WARRANTY; without even the implied warranty of
10
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
-# General Public License for more details.
12
-#
13
-# You should have received a copy of the GNU General Public License
14
-# along with this program; if not, see <https://www.gnu.org/licenses/>.
15
-#
16
-# As a special exception#
17
-# As a special exception to the GNU General Public License, if you
18
-# distribute this file as part of a program that contains a
19
-# configuration script generated by Autoconf, you may include it under
20
-# the same distribution terms that you use for the rest of that
21
-# program. This Exception is an additional permission under section 7
22
-# of the GNU General Public License, version 3 ("GPLv3").
23
-
24
-
25
-# Please send patches to <[email protected]>.
26
-#
27
-# Configuration subroutine to validate and canonicalize a configuration type.
28
-# Supply the specified configuration type as an argument.
29
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
-
31
-'orting which valid configurations
32
-# it does not support. The user should be able to distinguish
33
-# a failure to support;hb=HEAD
34
- $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35
-# distribute this file as part of a program that contains a
36
-# configuration script generated by Autoconf, you may include it under
37
-# the same distribution terms that you use for the rest of that
38
-# program. This Excepti4 Free Software Foundation, Inc.
39
-
40
-er section 7
41
-# of the GNU General Public License, version 3 ("GPLv3").
42
-
43
-
44
-# Please send patches to <[email protected]>.
45
-#
46
-# Configuration subroutine to validate and canonicalize a configuration type.
47
-# Supply the specified configuration type as an argument.
48
-# If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
-
50
-'orting which valid configurations
51
-# it does not support. The user should be able to distinguish
52
-# a failure to support a valid configuration from a meaningless
53
-# configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54
-# Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55
- ;;
56
- msbut
57
-# WITHOUT ANY W#! /bin/sh
58
-# Configuration validation subroutine script.
59
-# Copyright 1992-2018 Free Software Foundation, Inc.
60
-
61
-timestamp='2018-03-08it and/or modify it
62
-# under the terms of the GNU General Public License as published by
63
-# t;e Free Software Foundation, either version 3 of the L;cense, or
64
-# (at your option) any later version.
65
-#
66
-# This program is distributed in the hope that it will be useful, but
67
-# WITHOUT ANY WARRANTY; without even the implied warranty of
68
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69
- os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70
-# Configuration validation subroutine script.
71
-# Copyright 1992-2018 Free Software Foundation, Inc.
72
-
73
-timestamp='2018-03-08it and/or modify it
74
-# under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75
- ;
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2014 Free Software Found4-12-03it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # t;e Free Software Foundation, either version 3 of the L;cense, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, see <https://www.gnu.org/licenses/>.
15 #
16 # As a special exception#
17 # As a special exception to the GNU General Public License, if you
18 # distribute this file as part of a program that contains a
19 # configuration script generated by Autoconf, you may include it under
20 # the same distribution terms that you use for the rest of that
21 # program. This Exception is an additional permission under section 7
22 # of the GNU General Public License, version 3 ("GPLv3").
23
24
25 # Please send patches to <[email protected]>.
26 #
27 # Configuration subroutine to validate and canonicalize a configuration type.
28 # Supply the specified configuration type as an argument.
29 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
30
31 'orting which valid configurations
32 # it does not support. The user should be able to distinguish
33 # a failure to support;hb=HEAD
34 $0 [OPTION]f not, see <https:/eration mode a special exception to the GNU General Public License, if you
35 # distribute this file as part of a program that contains a
36 # configuration script generated by Autoconf, you may include it under
37 # the same distribution terms that you use for the rest of that
38 # program. This Excepti4 Free Software Foundation, Inc.
39
40 er section 7
41 # of the GNU General Public License, version 3 ("GPLv3").
42
43
44 # Please send patches to <[email protected]>.
45 #
46 # Configuration subroutine to validate and canonicalize a configuration type.
47 # Supply the specified configuration type as an argument.
48 # If it is invalid, we print 1 Free Software Foundation,3 Free Software Foundation, Inc.
49
50 'orting which valid configurations
51 # it does not support. The user should be able to distinguish
52 # a failure to support a valid configuration from a meaningless
53 # configur$1$1$1$1$1$basic_machine !$1$1$1$1$15v6$1$1udk$1! /bin/sh
54 # Cio$1$1windowsnt/windowsnt/windp11e32k | z8k)
55 ;;
56 msbut
57 # WITHOUT ANY W#! /bin/sh
58 # Configuration validation subroutine script.
59 # Copyright 1992-2018 Free Software Foundation, Inc.
60
61 timestamp='2018-03-08it and/or modify it
62 # under the terms of the GNU General Public License as published by
63 # t;e Free Software Foundation, either version 3 of the L;cense, or
64 # (at your option) any later version.
65 #
66 # This program is distributed in the hope that it will be useful, but
67 # WITHOUT ANY WARRANTY; without even the implied warranty of
68 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $1\': machine \`$basic_machineyramid?unknown$basic_machineu$basic_machine$basic_machine$basic_machine$basic_machinec9c | dpx2*-bull-next)
69 os=-nextstep3$1$1$1$1i386-vsta | vstabin/sh
70 # Configuration validation subroutine script.
71 # Copyright 1992-2018 Free Software Foundation, Inc.
72
73 timestamp='2018-03-08it and/or modify it
74 # under the terms of the GNU General Public License as published bon subroutine $basic_machine-linuxomron$basic_machine$basic_machine$basic_machine ext$basic_machine$basic_machine$basic_machine$basic_machine$basic_machinepentium4i786-`echo $basic_machinepn$basic_machineppcle | ppc-le | powerpc-littlele$basic_machine$basic_machine | ppc64-le | powerpc64-little64le$basic_machinepsshsh5elh6h64-unknown
75 ;
--- a/autosetup/config.sub
+++ b/autosetup/config.sub
@@ -1,75 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
D autosetup/find-tclsh
-10
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
1
-#!/bin/sh
2
-# Looks for a suitable tclsh or jimsh in the PATH
3
-# If not foundstrap jimsh d=`dirname "$0"`
4
-{ "$d/jimshd/${1-ac"; } 2>&1done
5
-echo 1>&2 bootstrap jimsh0"
6
-for cc in tclsh8.7; do
7
- { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/devexit 0
8
-done
9
-echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10
-for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
1 #!/bin/sh
2 # Looks for a suitable tclsh or jimsh in the PATH
3 # If not foundstrap jimsh d=`dirname "$0"`
4 { "$d/jimshd/${1-ac"; } 2>&1done
5 echo 1>&2 bootstrap jimsh0"
6 for cc in tclsh8.7; do
7 { $tclsh "$d/c"; } 2>&1 >/dev "$d/${1-autosetup--tclsh}"; } 2>/devexit 0
8 done
9 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
10 for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null
--- a/autosetup/find-tclsh
+++ b/autosetup/find-tclsh
@@ -1,10 +0,0 @@
 
 
 
 
 
 
 
 
 
 
+3701 -3421
--- autosetup/jimsh0.c
+++ autosetup/jimsh0.c
@@ -1,9 +1,7 @@
11
/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */
2
-#define _GNU_SOURCE
32
#define JIM_TCL_COMPAT
4
-#define JIM_REFERENCES
53
#define JIM_ANSIC
64
#define JIM_REGEXP
75
#define HAVE_NO_AUTOCONF
86
#define _JIMAUTOCONF_H
97
#define TCL_LIBRARY "."
@@ -31,24 +29,39 @@
3129
#define HAVE_MKDIR_ONE_ARG
3230
#define HAVE_SYSTEM
3331
#define HAVE_SYS_TIME_H
3432
#define HAVE_DIRENT_H
3533
#define HAVE_UNISTD_H
34
+#define HAVE_UMASK
35
+#include <sys/stat.h>
36
+#ifndef S_IRWXG
37
+#define S_IRWXG 0
38
+#endif
39
+#ifndef S_IRWXO
40
+#define S_IRWXO 0
41
+#endif
3642
#else
3743
#define TCL_PLATFORM_OS "unknown"
3844
#define TCL_PLATFORM_PLATFORM "unix"
3945
#define TCL_PLATFORM_PATH_SEPARATOR ":"
46
+#ifdef _MINIX
47
+#define vfork fork
48
+#define _POSIX_SOURCE
49
+#else
50
+#define _GNU_SOURCE
51
+#endif
4052
#define HAVE_VFORK
4153
#define HAVE_WAITPID
4254
#define HAVE_ISATTY
4355
#define HAVE_MKSTEMP
4456
#define HAVE_LINK
4557
#define HAVE_SYS_TIME_H
4658
#define HAVE_DIRENT_H
4759
#define HAVE_UNISTD_H
60
+#define HAVE_UMASK
4861
#endif
49
-#define JIM_VERSION 76
62
+#define JIM_VERSION 78
5063
#ifndef JIM_WIN32COMPAT_H
5164
#define JIM_WIN32COMPAT_H
5265
5366
5467
@@ -88,11 +101,10 @@
88101
#define JIM_WIDE_MIN LLONG_MIN
89102
#define JIM_WIDE_MAX LLONG_MAX
90103
#define JIM_WIDE_MODIFIER "I64d"
91104
#define strcasecmp _stricmp
92105
#define strtoull _strtoui64
93
-#define snprintf _snprintf
94106
95107
#include <io.h>
96108
97109
struct timeval {
98110
long tv_sec;
@@ -105,29 +117,24 @@
105117
struct dirent {
106118
char *d_name;
107119
};
108120
109121
typedef struct DIR {
110
- long handle;
122
+ long handle;
111123
struct _finddata_t info;
112
- struct dirent result;
113
- char *name;
124
+ struct dirent result;
125
+ char *name;
114126
} DIR;
115127
116128
DIR *opendir(const char *name);
117129
int closedir(DIR *dir);
118130
struct dirent *readdir(DIR *dir);
119131
120
-#elif defined(__MINGW32__)
121
-
122
-#include <stdlib.h>
123
-#define strtod __strtod
132
+#endif
124133
125134
#endif
126135
127
-#endif
128
-
129136
#ifdef __cplusplus
130137
}
131138
#endif
132139
133140
#endif
@@ -146,19 +153,21 @@
146153
147154
#ifndef JIM_UTF8
148155
#include <ctype.h>
149156
150157
151
-#define utf8_strlen(S, B) ((B) < 0 ? strlen(S) : (B))
158
+#define utf8_strlen(S, B) ((B) < 0 ? (int)strlen(S) : (B))
159
+#define utf8_strwidth(S, B) utf8_strlen((S), (B))
152160
#define utf8_tounicode(S, CP) (*(CP) = (unsigned char)*(S), 1)
153161
#define utf8_getchars(CP, C) (*(CP) = (C), 1)
154162
#define utf8_upper(C) toupper(C)
155163
#define utf8_title(C) toupper(C)
156164
#define utf8_lower(C) tolower(C)
157165
#define utf8_index(C, I) (I)
158166
#define utf8_charlen(C) 1
159167
#define utf8_prev_len(S, L) 1
168
+#define utf8_width(C) 1
160169
161170
#else
162171
163172
#endif
164173
@@ -175,13 +184,13 @@
175184
extern "C" {
176185
#endif
177186
178187
#include <time.h>
179188
#include <limits.h>
180
-#include <stdio.h>
181
-#include <stdlib.h>
182
-#include <stdarg.h>
189
+#include <stdio.h>
190
+#include <stdlib.h>
191
+#include <stdarg.h>
183192
184193
185194
#ifndef HAVE_NO_AUTOCONF
186195
#endif
187196
@@ -224,31 +233,31 @@
224233
#define JIM_SIGNAL 5
225234
#define JIM_EXIT 6
226235
227236
#define JIM_EVAL 7
228237
229
-#define JIM_MAX_CALLFRAME_DEPTH 1000
230
-#define JIM_MAX_EVAL_DEPTH 2000
238
+#define JIM_MAX_CALLFRAME_DEPTH 1000
239
+#define JIM_MAX_EVAL_DEPTH 2000
231240
232241
233242
#define JIM_PRIV_FLAG_SHIFT 20
234243
235
-#define JIM_NONE 0
236
-#define JIM_ERRMSG 1
237
-#define JIM_ENUM_ABBREV 2
238
-#define JIM_UNSHARED 4
239
-#define JIM_MUSTEXIST 8
240
-
241
-
242
-#define JIM_SUBST_NOVAR 1
243
-#define JIM_SUBST_NOCMD 2
244
-#define JIM_SUBST_NOESC 4
245
-#define JIM_SUBST_FLAG 128
246
-
247
-
248
-#define JIM_CASESENS 0
249
-#define JIM_NOCASE 1
244
+#define JIM_NONE 0
245
+#define JIM_ERRMSG 1
246
+#define JIM_ENUM_ABBREV 2
247
+#define JIM_UNSHARED 4
248
+#define JIM_MUSTEXIST 8
249
+
250
+
251
+#define JIM_SUBST_NOVAR 1
252
+#define JIM_SUBST_NOCMD 2
253
+#define JIM_SUBST_NOESC 4
254
+#define JIM_SUBST_FLAG 128
255
+
256
+
257
+#define JIM_CASESENS 0
258
+#define JIM_NOCASE 1
250259
251260
252261
#define JIM_PATH_LEN 1024
253262
254263
@@ -339,79 +348,80 @@
339348
#define Jim_GetHashTableSize(ht) ((ht)->size)
340349
#define Jim_GetHashTableUsed(ht) ((ht)->used)
341350
342351
343352
typedef struct Jim_Obj {
344
- char *bytes;
345
- const struct Jim_ObjType *typePtr;
346
- int refCount;
347
- int length;
348
-
353
+ char *bytes;
354
+ const struct Jim_ObjType *typePtr;
355
+ int refCount;
356
+ int length;
357
+
349358
union {
350
-
359
+
351360
jim_wide wideValue;
352
-
361
+
353362
int intValue;
354
-
363
+
355364
double doubleValue;
356
-
365
+
357366
void *ptr;
358
-
367
+
359368
struct {
360369
void *ptr1;
361370
void *ptr2;
362371
} twoPtrValue;
363
-
372
+
373
+ struct {
374
+ void *ptr;
375
+ int int1;
376
+ int int2;
377
+ } ptrIntValue;
378
+
364379
struct {
365380
struct Jim_Var *varPtr;
366
- unsigned long callFrameId;
367
- int global;
381
+ unsigned long callFrameId;
382
+ int global;
368383
} varValue;
369
-
384
+
370385
struct {
371386
struct Jim_Obj *nsObj;
372387
struct Jim_Cmd *cmdPtr;
373
- unsigned long procEpoch;
388
+ unsigned long procEpoch;
374389
} cmdValue;
375
-
390
+
376391
struct {
377
- struct Jim_Obj **ele;
378
- int len;
379
- int maxLen;
392
+ struct Jim_Obj **ele;
393
+ int len;
394
+ int maxLen;
380395
} listValue;
381
-
396
+
382397
struct {
383398
int maxLength;
384
- int charLength;
399
+ int charLength;
385400
} strValue;
386
-
401
+
387402
struct {
388403
unsigned long id;
389404
struct Jim_Reference *refPtr;
390405
} refValue;
391
-
406
+
392407
struct {
393408
struct Jim_Obj *fileNameObj;
394409
int lineNumber;
395410
} sourceValue;
396
-
411
+
397412
struct {
398413
struct Jim_Obj *varNameObjPtr;
399414
struct Jim_Obj *indexObjPtr;
400415
} dictSubstValue;
401
-
402
- struct {
403
- void *compre;
404
- unsigned flags;
405
- } regexpValue;
406416
struct {
407417
int line;
408418
int argc;
409419
} scriptLineValue;
410420
} internalRep;
411
- struct Jim_Obj *prevObjPtr;
412
- struct Jim_Obj *nextObjPtr;
421
+ struct Jim_Obj *prevObjPtr;
422
+ struct Jim_Obj *nextObjPtr;
413423
} Jim_Obj;
414424
415425
416426
#define Jim_IncrRefCount(objPtr) \
417427
++(objPtr)->refCount
@@ -442,40 +452,40 @@
442452
typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp,
443453
struct Jim_Obj *srcPtr, Jim_Obj *dupPtr);
444454
typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr);
445455
446456
typedef struct Jim_ObjType {
447
- const char *name;
457
+ const char *name;
448458
Jim_FreeInternalRepProc *freeIntRepProc;
449459
Jim_DupInternalRepProc *dupIntRepProc;
450460
Jim_UpdateStringProc *updateStringProc;
451461
int flags;
452462
} Jim_ObjType;
453463
454464
455
-#define JIM_TYPE_NONE 0
456
-#define JIM_TYPE_REFERENCES 1
465
+#define JIM_TYPE_NONE 0
466
+#define JIM_TYPE_REFERENCES 1
457467
458468
459469
460470
typedef struct Jim_CallFrame {
461
- unsigned long id;
462
- int level;
463
- struct Jim_HashTable vars;
464
- struct Jim_HashTable *staticVars;
465
- struct Jim_CallFrame *parent;
466
- Jim_Obj *const *argv;
467
- int argc;
468
- Jim_Obj *procArgsObjPtr;
469
- Jim_Obj *procBodyObjPtr;
470
- struct Jim_CallFrame *next;
471
- Jim_Obj *nsObj;
472
- Jim_Obj *fileNameObj;
471
+ unsigned long id;
472
+ int level;
473
+ struct Jim_HashTable vars;
474
+ struct Jim_HashTable *staticVars;
475
+ struct Jim_CallFrame *parent;
476
+ Jim_Obj *const *argv;
477
+ int argc;
478
+ Jim_Obj *procArgsObjPtr;
479
+ Jim_Obj *procBodyObjPtr;
480
+ struct Jim_CallFrame *next;
481
+ Jim_Obj *nsObj;
482
+ Jim_Obj *fileNameObj;
473483
int line;
474
- Jim_Stack *localCommands;
475
- struct Jim_Obj *tailcallObj;
476
- struct Jim_Cmd *tailcallCmd;
484
+ Jim_Stack *localCommands;
485
+ struct Jim_Obj *tailcallObj;
486
+ struct Jim_Cmd *tailcallCmd;
477487
} Jim_CallFrame;
478488
479489
typedef struct Jim_Var {
480490
Jim_Obj *objPtr;
481491
struct Jim_CallFrame *linkFramePtr;
@@ -487,35 +497,35 @@
487497
typedef void Jim_DelCmdProc(struct Jim_Interp *interp, void *privData);
488498
489499
490500
491501
typedef struct Jim_Cmd {
492
- int inUse;
493
- int isproc;
494
- struct Jim_Cmd *prevCmd;
502
+ int inUse;
503
+ int isproc;
504
+ struct Jim_Cmd *prevCmd;
495505
union {
496506
struct {
497
-
498
- Jim_CmdProc *cmdProc;
499
- Jim_DelCmdProc *delProc;
500
- void *privData;
507
+
508
+ Jim_CmdProc *cmdProc;
509
+ Jim_DelCmdProc *delProc;
510
+ void *privData;
501511
} native;
502512
struct {
503
-
513
+
504514
Jim_Obj *argListObjPtr;
505515
Jim_Obj *bodyObjPtr;
506
- Jim_HashTable *staticVars;
507
- int argListLen;
508
- int reqArity;
509
- int optArity;
510
- int argsPos;
511
- int upcall;
516
+ Jim_HashTable *staticVars;
517
+ int argListLen;
518
+ int reqArity;
519
+ int optArity;
520
+ int argsPos;
521
+ int upcall;
512522
struct Jim_ProcArg {
513
- Jim_Obj *nameObjPtr;
514
- Jim_Obj *defaultObjPtr;
523
+ Jim_Obj *nameObjPtr;
524
+ Jim_Obj *defaultObjPtr;
515525
} *arglist;
516
- Jim_Obj *nsObj;
526
+ Jim_Obj *nsObj;
517527
} proc;
518528
} u;
519529
} Jim_Cmd;
520530
521531
@@ -523,64 +533,64 @@
523533
unsigned char sbox[256];
524534
unsigned int i, j;
525535
} Jim_PrngState;
526536
527537
typedef struct Jim_Interp {
528
- Jim_Obj *result;
529
- int errorLine;
530
- Jim_Obj *errorFileNameObj;
531
- int addStackTrace;
532
- int maxCallFrameDepth;
533
- int maxEvalDepth;
534
- int evalDepth;
535
- int returnCode;
536
- int returnLevel;
537
- int exitCode;
538
- long id;
539
- int signal_level;
540
- jim_wide sigmask;
541
- int (*signal_set_result)(struct Jim_Interp *interp, jim_wide sigmask);
542
- Jim_CallFrame *framePtr;
543
- Jim_CallFrame *topFramePtr;
544
- struct Jim_HashTable commands;
538
+ Jim_Obj *result;
539
+ int errorLine;
540
+ Jim_Obj *errorFileNameObj;
541
+ int addStackTrace;
542
+ int maxCallFrameDepth;
543
+ int maxEvalDepth;
544
+ int evalDepth;
545
+ int returnCode;
546
+ int returnLevel;
547
+ int exitCode;
548
+ long id;
549
+ int signal_level;
550
+ jim_wide sigmask;
551
+ int (*signal_set_result)(struct Jim_Interp *interp, jim_wide sigmask);
552
+ Jim_CallFrame *framePtr;
553
+ Jim_CallFrame *topFramePtr;
554
+ struct Jim_HashTable commands;
545555
unsigned long procEpoch; /* Incremented every time the result
546556
of procedures names lookup caching
547557
may no longer be valid. */
548558
unsigned long callFrameEpoch; /* Incremented every time a new
549559
callframe is created. This id is used for the
550560
'ID' field contained in the Jim_CallFrame
551561
structure. */
552
- int local;
553
- Jim_Obj *liveList;
554
- Jim_Obj *freeList;
555
- Jim_Obj *currentScriptObj;
556
- Jim_Obj *nullScriptObj;
557
- Jim_Obj *emptyObj;
558
- Jim_Obj *trueObj;
559
- Jim_Obj *falseObj;
560
- unsigned long referenceNextId;
561
- struct Jim_HashTable references;
562
+ int local;
563
+ Jim_Obj *liveList;
564
+ Jim_Obj *freeList;
565
+ Jim_Obj *currentScriptObj;
566
+ Jim_Obj *nullScriptObj;
567
+ Jim_Obj *emptyObj;
568
+ Jim_Obj *trueObj;
569
+ Jim_Obj *falseObj;
570
+ unsigned long referenceNextId;
571
+ struct Jim_HashTable references;
562572
unsigned long lastCollectId; /* reference max Id of the last GC
563
- execution. It's set to -1 while the collection
573
+ execution. It's set to ~0 while the collection
564574
is running as sentinel to avoid to recursive
565575
calls via the [collect] command inside
566576
finalizers. */
567
- time_t lastCollectTime;
568
- Jim_Obj *stackTrace;
569
- Jim_Obj *errorProc;
570
- Jim_Obj *unknown;
571
- int unknown_called;
572
- int errorFlag;
577
+ time_t lastCollectTime;
578
+ Jim_Obj *stackTrace;
579
+ Jim_Obj *errorProc;
580
+ Jim_Obj *unknown;
581
+ int unknown_called;
582
+ int errorFlag;
573583
void *cmdPrivData; /* Used to pass the private data pointer to
574584
a command. It is set to what the user specified
575585
via Jim_CreateCommand(). */
576586
577
- struct Jim_CallFrame *freeFramesList;
578
- struct Jim_HashTable assocData;
579
- Jim_PrngState *prngState;
580
- struct Jim_HashTable packages;
581
- Jim_Stack *loadHandles;
587
+ struct Jim_CallFrame *freeFramesList;
588
+ struct Jim_HashTable assocData;
589
+ Jim_PrngState *prngState;
590
+ struct Jim_HashTable packages;
591
+ Jim_Stack *loadHandles;
582592
} Jim_Interp;
583593
584594
#define Jim_InterpIncrProcEpoch(i) (i)->procEpoch++
585595
#define Jim_SetResultString(i,s,l) Jim_SetResult(i, Jim_NewStringObj(i,s,l))
586596
#define Jim_SetResultInt(i,intval) Jim_SetResult(i, Jim_NewIntObj(i,intval))
@@ -623,11 +633,11 @@
623633
JIM_EXPORT char *Jim_StrDupLen(const char *s, int l);
624634
625635
626636
JIM_EXPORT char **Jim_GetEnviron(void);
627637
JIM_EXPORT void Jim_SetEnviron(char **env);
628
-JIM_EXPORT int Jim_MakeTempFile(Jim_Interp *interp, const char *template);
638
+JIM_EXPORT int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template, int unlink_file);
629639
630640
631641
JIM_EXPORT int Jim_Eval(Jim_Interp *interp, const char *script);
632642
633643
@@ -816,25 +826,33 @@
816826
Jim_Obj *newObjPtr, int flags);
817827
JIM_EXPORT int Jim_DictPairs(Jim_Interp *interp,
818828
Jim_Obj *dictPtr, Jim_Obj ***objPtrPtr, int *len);
819829
JIM_EXPORT int Jim_DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
820830
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr);
821
-JIM_EXPORT int Jim_DictKeys(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *patternObj);
822
-JIM_EXPORT int Jim_DictValues(Jim_Interp *interp, Jim_Obj *dictObjPtr, Jim_Obj *patternObjPtr);
831
+
832
+#define JIM_DICTMATCH_KEYS 0x0001
833
+#define JIM_DICTMATCH_VALUES 0x002
834
+
835
+JIM_EXPORT int Jim_DictMatchTypes(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *patternObj, int match_type, int return_types);
823836
JIM_EXPORT int Jim_DictSize(Jim_Interp *interp, Jim_Obj *objPtr);
824837
JIM_EXPORT int Jim_DictInfo(Jim_Interp *interp, Jim_Obj *objPtr);
838
+JIM_EXPORT Jim_Obj *Jim_DictMerge(Jim_Interp *interp, int objc, Jim_Obj *const *objv);
825839
826840
827841
JIM_EXPORT int Jim_GetReturnCode (Jim_Interp *interp, Jim_Obj *objPtr,
828842
int *intPtr);
829843
830844
831845
JIM_EXPORT int Jim_EvalExpression (Jim_Interp *interp,
832
- Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr);
846
+ Jim_Obj *exprObjPtr);
833847
JIM_EXPORT int Jim_GetBoolFromExpr (Jim_Interp *interp,
834848
Jim_Obj *exprObjPtr, int *boolPtr);
835849
850
+
851
+JIM_EXPORT int Jim_GetBoolean(Jim_Interp *interp, Jim_Obj *objPtr,
852
+ int *booleanPtr);
853
+
836854
837855
JIM_EXPORT int Jim_GetWide (Jim_Interp *interp, Jim_Obj *objPtr,
838856
jim_wide *widePtr);
839857
JIM_EXPORT int Jim_GetLong (Jim_Interp *interp, Jim_Obj *objPtr,
840858
long *longPtr);
@@ -852,10 +870,12 @@
852870
853871
JIM_EXPORT void Jim_WrongNumArgs (Jim_Interp *interp, int argc,
854872
Jim_Obj *const *argv, const char *msg);
855873
JIM_EXPORT int Jim_GetEnum (Jim_Interp *interp, Jim_Obj *objPtr,
856874
const char * const *tablePtr, int *indexPtr, const char *name, int flags);
875
+JIM_EXPORT int Jim_CheckShowCommands(Jim_Interp *interp, Jim_Obj *objPtr,
876
+ const char *const *tablePtr);
857877
JIM_EXPORT int Jim_ScriptIsComplete(Jim_Interp *interp,
858878
Jim_Obj *scriptObj, char *stateCharPtr);
859879
860880
JIM_EXPORT int Jim_FindByName(const char *name, const char * const array[], size_t len);
861881
@@ -878,11 +898,12 @@
878898
879899
880900
JIM_EXPORT int Jim_InteractivePrompt (Jim_Interp *interp);
881901
JIM_EXPORT void Jim_HistoryLoad(const char *filename);
882902
JIM_EXPORT void Jim_HistorySave(const char *filename);
883
-JIM_EXPORT char *Jim_HistoryGetline(const char *prompt);
903
+JIM_EXPORT char *Jim_HistoryGetline(Jim_Interp *interp, const char *prompt);
904
+JIM_EXPORT void Jim_HistorySetCompletion(Jim_Interp *interp, Jim_Obj *commandObj);
884905
JIM_EXPORT void Jim_HistoryAdd(const char *line);
885906
JIM_EXPORT void Jim_HistoryShow(void);
886907
887908
888909
JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp);
@@ -904,11 +925,11 @@
904925
905926
#ifdef __cplusplus
906927
}
907928
#endif
908929
909
-#endif
930
+#endif
910931
911932
#ifndef JIM_SUBCMD_H
912933
#define JIM_SUBCMD_H
913934
914935
@@ -915,24 +936,24 @@
915936
#ifdef __cplusplus
916937
extern "C" {
917938
#endif
918939
919940
920
-#define JIM_MODFLAG_HIDDEN 0x0001
921
-#define JIM_MODFLAG_FULLARGV 0x0002
941
+#define JIM_MODFLAG_HIDDEN 0x0001
942
+#define JIM_MODFLAG_FULLARGV 0x0002
922943
923944
924945
925946
typedef int jim_subcmd_function(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
926947
927948
typedef struct {
928
- const char *cmd;
929
- const char *args;
930
- jim_subcmd_function *function;
931
- short minargs;
932
- short maxargs;
933
- unsigned short flags;
949
+ const char *cmd;
950
+ const char *args;
951
+ jim_subcmd_function *function;
952
+ short minargs;
953
+ short maxargs;
954
+ unsigned short flags;
934955
} jim_subcmd_type;
935956
936957
const jim_subcmd_type *
937958
Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
938959
@@ -960,36 +981,36 @@
960981
int rm_eo;
961982
} regmatch_t;
962983
963984
964985
typedef struct regexp {
965
-
966
- int re_nsub;
967
-
968
-
969
- int cflags;
970
- int err;
971
- int regstart;
972
- int reganch;
973
- int regmust;
974
- int regmlen;
975
- int *program;
976
-
977
-
978
- const char *regparse;
979
- int p;
980
- int proglen;
981
-
982
-
983
- int eflags;
984
- const char *start;
985
- const char *reginput;
986
- const char *regbol;
987
-
988
-
989
- regmatch_t *pmatch;
990
- int nmatch;
986
+
987
+ int re_nsub;
988
+
989
+
990
+ int cflags;
991
+ int err;
992
+ int regstart;
993
+ int reganch;
994
+ int regmust;
995
+ int regmlen;
996
+ int *program;
997
+
998
+
999
+ const char *regparse;
1000
+ int p;
1001
+ int proglen;
1002
+
1003
+
1004
+ int eflags;
1005
+ const char *start;
1006
+ const char *reginput;
1007
+ const char *regbol;
1008
+
1009
+
1010
+ regmatch_t *pmatch;
1011
+ int nmatch;
9911012
} regexp;
9921013
9931014
typedef regexp regex_t;
9941015
9951016
#define REG_EXTENDED 0
@@ -997,13 +1018,13 @@
9971018
#define REG_ICASE 2
9981019
9991020
#define REG_NOTBOL 16
10001021
10011022
enum {
1002
- REG_NOERROR,
1003
- REG_NOMATCH,
1004
- REG_BADPAT,
1023
+ REG_NOERROR,
1024
+ REG_NOMATCH,
1025
+ REG_BADPAT,
10051026
REG_ERR_NULL_ARGUMENT,
10061027
REG_ERR_UNKNOWN,
10071028
REG_ERR_TOO_BIG,
10081029
REG_ERR_NOMEM,
10091030
REG_ERR_TOO_MANY_PAREN,
@@ -1028,24 +1049,101 @@
10281049
10291050
#ifdef __cplusplus
10301051
}
10311052
#endif
10321053
1054
+#endif
1055
+#ifndef JIM_SIGNAL_H
1056
+#define JIM_SIGNAL_H
1057
+
1058
+#ifdef __cplusplus
1059
+extern "C" {
1060
+#endif
1061
+
1062
+const char *Jim_SignalId(int sig);
1063
+
1064
+#ifdef __cplusplus
1065
+}
1066
+#endif
1067
+
1068
+#endif
1069
+#ifndef JIMIOCOMPAT_H
1070
+#define JIMIOCOMPAT_H
1071
+
1072
+
1073
+#include <stdio.h>
1074
+#include <errno.h>
1075
+
1076
+
1077
+void Jim_SetResultErrno(Jim_Interp *interp, const char *msg);
1078
+
1079
+int Jim_OpenForWrite(const char *filename, int append);
1080
+
1081
+int Jim_OpenForRead(const char *filename);
1082
+
1083
+#if defined(__MINGW32__)
1084
+ #ifndef STRICT
1085
+ #define STRICT
1086
+ #endif
1087
+ #define WIN32_LEAN_AND_MEAN
1088
+ #include <windows.h>
1089
+ #include <fcntl.h>
1090
+ #include <io.h>
1091
+ #include <process.h>
1092
+
1093
+ typedef HANDLE pidtype;
1094
+ #define JIM_BAD_PID INVALID_HANDLE_VALUE
1095
+
1096
+ #define JIM_NO_PID INVALID_HANDLE_VALUE
1097
+
1098
+
1099
+ #define WIFEXITED(STATUS) (((STATUS) & 0xff00) == 0)
1100
+ #define WEXITSTATUS(STATUS) ((STATUS) & 0x00ff)
1101
+ #define WIFSIGNALED(STATUS) (((STATUS) & 0xff00) != 0)
1102
+ #define WTERMSIG(STATUS) (((STATUS) >> 8) & 0xff)
1103
+ #define WNOHANG 1
1104
+
1105
+ int Jim_Errno(void);
1106
+ pidtype waitpid(pidtype pid, int *status, int nohang);
1107
+
1108
+ #define HAVE_PIPE
1109
+ #define pipe(P) _pipe((P), 0, O_NOINHERIT)
1110
+
1111
+#elif defined(HAVE_UNISTD_H)
1112
+ #include <unistd.h>
1113
+ #include <fcntl.h>
1114
+ #include <sys/wait.h>
1115
+ #include <sys/stat.h>
1116
+
1117
+ typedef int pidtype;
1118
+ #define Jim_Errno() errno
1119
+ #define JIM_BAD_PID -1
1120
+ #define JIM_NO_PID 0
1121
+
1122
+ #ifndef HAVE_EXECVPE
1123
+ #define execvpe(ARG0, ARGV, ENV) execvp(ARG0, ARGV)
1124
+ #endif
1125
+#endif
1126
+
10331127
#endif
10341128
int Jim_bootstrapInit(Jim_Interp *interp)
10351129
{
10361130
if (Jim_PackageProvide(interp, "bootstrap", "1.0", JIM_ERRMSG))
10371131
return JIM_ERR;
10381132
10391133
return Jim_EvalSource(interp, "bootstrap.tcl", 1,
10401134
"\n"
10411135
"\n"
1042
-"proc package {cmd pkg} {\n"
1136
+"proc package {cmd pkg args} {\n"
10431137
" if {$cmd eq \"require\"} {\n"
10441138
" foreach path $::auto_path {\n"
1045
-" if {[file exists $path/$pkg.tcl]} {\n"
1046
-" uplevel #0 [list source $path/$pkg.tcl]\n"
1139
+" set pkgpath $path/$pkg.tcl\n"
1140
+" if {$path eq \".\"} {\n"
1141
+" set pkgpath $pkg.tcl\n"
1142
+" }\n"
1143
+" if {[file exists $pkgpath]} {\n"
1144
+" uplevel #0 [list source $pkgpath]\n"
10471145
" return\n"
10481146
" }\n"
10491147
" }\n"
10501148
" }\n"
10511149
"}\n"
@@ -1100,10 +1198,43 @@
11001198
"\n"
11011199
"if {$tcl_platform(platform) eq \"windows\"} {\n"
11021200
" set jim::argv0 [string map {\\\\ /} $jim::argv0]\n"
11031201
"}\n"
11041202
"\n"
1203
+"\n"
1204
+"set tcl::autocomplete_commands {info tcl::prefix socket namespace array clock file package string dict signal history}\n"
1205
+"\n"
1206
+"\n"
1207
+"\n"
1208
+"proc tcl::autocomplete {prefix} {\n"
1209
+" if {[set space [string first \" \" $prefix]] != -1} {\n"
1210
+" set cmd [string range $prefix 0 $space-1]\n"
1211
+" if {$cmd in $::tcl::autocomplete_commands || [info channel $cmd] ne \"\"} {\n"
1212
+" set arg [string range $prefix $space+1 end]\n"
1213
+"\n"
1214
+" return [lmap p [$cmd -commands] {\n"
1215
+" if {![string match \"${arg}*\" $p]} continue\n"
1216
+" function \"$cmd $p\"\n"
1217
+" }]\n"
1218
+" }\n"
1219
+" }\n"
1220
+"\n"
1221
+" if {[string match \"source *\" $prefix]} {\n"
1222
+" set path [string range $prefix 7 end]\n"
1223
+" return [lmap p [glob -nocomplain \"${path}*\"] {\n"
1224
+" function \"source $p\"\n"
1225
+" }]\n"
1226
+" }\n"
1227
+"\n"
1228
+" return [lmap p [lsort [info commands $prefix*]] {\n"
1229
+" if {[string match \"* *\" $p]} {\n"
1230
+" continue\n"
1231
+" }\n"
1232
+" function $p\n"
1233
+" }]\n"
1234
+"}\n"
1235
+"\n"
11051236
"_jimsh_init\n"
11061237
);
11071238
}
11081239
int Jim_globInit(Jim_Interp *interp)
11091240
{
@@ -1315,10 +1446,17 @@
13151446
return JIM_ERR;
13161447
13171448
return Jim_EvalSource(interp, "stdlib.tcl", 1,
13181449
"\n"
13191450
"\n"
1451
+"if {![exists -command ref]} {\n"
1452
+"\n"
1453
+" proc ref {args} {{count 0}} {\n"
1454
+" format %08x [incr count]\n"
1455
+" }\n"
1456
+"}\n"
1457
+"\n"
13201458
"\n"
13211459
"proc lambda {arglist args} {\n"
13221460
" tailcall proc [ref {} function lambda.finalizer] $arglist {*}$args\n"
13231461
"}\n"
13241462
"\n"
@@ -1375,10 +1513,17 @@
13751513
" }\n"
13761514
" join $lines \\n\n"
13771515
"}\n"
13781516
"\n"
13791517
"\n"
1518
+"\n"
1519
+"proc defer {script} {\n"
1520
+" upvar jim::defer v\n"
1521
+" lappend v $script\n"
1522
+"}\n"
1523
+"\n"
1524
+"\n"
13801525
"\n"
13811526
"proc errorInfo {msg {stacktrace \"\"}} {\n"
13821527
" if {$stacktrace eq \"\"} {\n"
13831528
"\n"
13841529
" set stacktrace [info stacktrace]\n"
@@ -1402,31 +1547,10 @@
14021547
" if {[exists ::jim::exe]} {\n"
14031548
" return $::jim::exe\n"
14041549
" }\n"
14051550
"}\n"
14061551
"\n"
1407
-"\n"
1408
-"proc {dict with} {&dictVar {args key} script} {\n"
1409
-" set keys {}\n"
1410
-" foreach {n v} [dict get $dictVar {*}$key] {\n"
1411
-" upvar $n var_$n\n"
1412
-" set var_$n $v\n"
1413
-" lappend keys $n\n"
1414
-" }\n"
1415
-" catch {uplevel 1 $script} msg opts\n"
1416
-" if {[info exists dictVar] && ([llength $key] == 0 || [dict exists $dictVar {*}$key])} {\n"
1417
-" foreach n $keys {\n"
1418
-" if {[info exists var_$n]} {\n"
1419
-" dict set dictVar {*}$key $n [set var_$n]\n"
1420
-" } else {\n"
1421
-" dict unset dictVar {*}$key $n\n"
1422
-" }\n"
1423
-" }\n"
1424
-" }\n"
1425
-" return {*}$opts $msg\n"
1426
-"}\n"
1427
-"\n"
14281552
"\n"
14291553
"proc {dict update} {&varName args script} {\n"
14301554
" set keys {}\n"
14311555
" foreach {n v} $args {\n"
14321556
" upvar $v var_$v\n"
@@ -1445,23 +1569,10 @@
14451569
" }\n"
14461570
" }\n"
14471571
" return {*}$opts $msg\n"
14481572
"}\n"
14491573
"\n"
1450
-"\n"
1451
-"\n"
1452
-"proc {dict merge} {dict args} {\n"
1453
-" foreach d $args {\n"
1454
-"\n"
1455
-" dict size $d\n"
1456
-" foreach {k v} $d {\n"
1457
-" dict set dict $k $v\n"
1458
-" }\n"
1459
-" }\n"
1460
-" return $dict\n"
1461
-"}\n"
1462
-"\n"
14631574
"proc {dict replace} {dictionary {args {key value}}} {\n"
14641575
" if {[llength ${key value}] % 2} {\n"
14651576
" tailcall {dict replace}\n"
14661577
" }\n"
14671578
" tailcall dict merge $dictionary ${key value}\n"
@@ -1503,15 +1614,10 @@
15031614
" dict unset dictionary $k\n"
15041615
" }\n"
15051616
" return $dictionary\n"
15061617
"}\n"
15071618
"\n"
1508
-"\n"
1509
-"proc {dict values} {dictionary {pattern *}} {\n"
1510
-" dict keys [lreverse $dictionary] $pattern\n"
1511
-"}\n"
1512
-"\n"
15131619
"\n"
15141620
"proc {dict for} {vars dictionary script} {\n"
15151621
" if {[llength $vars] != 2} {\n"
15161622
" return -code error \"must have exactly two variable names\"\n"
15171623
" }\n"
@@ -1591,11 +1697,10 @@
15911697
" tailcall {*}$args\n"
15921698
"}\n"
15931699
"\n"
15941700
"\n"
15951701
"\n"
1596
-"\n"
15971702
"proc parray {arrayname {pattern *} {puts puts}} {\n"
15981703
" upvar $arrayname a\n"
15991704
"\n"
16001705
" set max 0\n"
16011706
" foreach name [array names a $pattern]] {\n"
@@ -1647,11 +1752,11 @@
16471752
"}\n"
16481753
"\n"
16491754
"\n"
16501755
"\n"
16511756
"proc popen {cmd {mode r}} {\n"
1652
-" lassign [socket pipe] r w\n"
1757
+" lassign [pipe] r w\n"
16531758
" try {\n"
16541759
" if {[string match \"w*\" $mode]} {\n"
16551760
" lappend cmd <@$r &\n"
16561761
" set pids [exec {*}$cmd]\n"
16571762
" $r close\n"
@@ -1663,16 +1768,31 @@
16631768
" set f $r\n"
16641769
" }\n"
16651770
" lambda {cmd args} {f pids} {\n"
16661771
" if {$cmd eq \"pid\"} {\n"
16671772
" return $pids\n"
1773
+" }\n"
1774
+" if {$cmd eq \"getfd\"} {\n"
1775
+" $f getfd\n"
16681776
" }\n"
16691777
" if {$cmd eq \"close\"} {\n"
16701778
" $f close\n"
16711779
"\n"
1672
-" foreach p $pids { os.wait $p }\n"
1673
-" return\n"
1780
+" set retopts {}\n"
1781
+" foreach p $pids {\n"
1782
+" lassign [wait $p] status - rc\n"
1783
+" if {$status eq \"CHILDSTATUS\"} {\n"
1784
+" if {$rc == 0} {\n"
1785
+" continue\n"
1786
+" }\n"
1787
+" set msg \"child process exited abnormally\"\n"
1788
+" } else {\n"
1789
+" set msg \"child killed: received signal\"\n"
1790
+" }\n"
1791
+" set retopts [list -code error -errorcode [list $status $p $rc] $msg]\n"
1792
+" }\n"
1793
+" return {*}$retopts\n"
16741794
" }\n"
16751795
" tailcall $f $cmd {*}$args\n"
16761796
" }\n"
16771797
" } on error {error opts} {\n"
16781798
" $r close\n"
@@ -1692,14 +1812,10 @@
16921812
" if {[catch {$channelId pid} pids]} {\n"
16931813
" return \"\"\n"
16941814
" }\n"
16951815
" return $pids\n"
16961816
"}\n"
1697
-"\n"
1698
-"\n"
1699
-"\n"
1700
-"\n"
17011817
"\n"
17021818
"\n"
17031819
"\n"
17041820
"\n"
17051821
"\n"
@@ -1780,10 +1896,13 @@
17801896
"}\n"
17811897
);
17821898
}
17831899
17841900
1901
+#ifndef _GNU_SOURCE
1902
+#define _GNU_SOURCE
1903
+#endif
17851904
#include <stdio.h>
17861905
#include <string.h>
17871906
#include <errno.h>
17881907
#include <fcntl.h>
17891908
#ifdef HAVE_UNISTD_H
@@ -1793,27 +1912,34 @@
17931912
17941913
17951914
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H)
17961915
#include <sys/socket.h>
17971916
#include <netinet/in.h>
1917
+#include <netinet/tcp.h>
17981918
#include <arpa/inet.h>
17991919
#include <netdb.h>
18001920
#ifdef HAVE_SYS_UN_H
18011921
#include <sys/un.h>
18021922
#endif
1923
+#define HAVE_SOCKETS
1924
+#elif defined (__MINGW32__)
1925
+
18031926
#else
18041927
#define JIM_ANSIC
18051928
#endif
18061929
18071930
#if defined(JIM_SSL)
18081931
#include <openssl/ssl.h>
18091932
#include <openssl/err.h>
18101933
#endif
18111934
1935
+#ifdef HAVE_TERMIOS_H
1936
+#endif
18121937
1813
-#define AIO_CMD_LEN 32
1814
-#define AIO_BUF_LEN 256
1938
+
1939
+#define AIO_CMD_LEN 32
1940
+#define AIO_BUF_LEN 256
18151941
18161942
#ifndef HAVE_FTELLO
18171943
#define ftello ftell
18181944
#endif
18191945
#ifndef HAVE_FSEEKO
@@ -1829,11 +1955,15 @@
18291955
#ifndef PF_INET6
18301956
#define PF_INET6 0
18311957
#endif
18321958
#endif
18331959
1834
-#define JimCheckStreamError(interp, af) af->fops->error(af)
1960
+#ifdef JIM_ANSIC
1961
+
1962
+#undef HAVE_PIPE
1963
+#undef HAVE_SOCKETPAIR
1964
+#endif
18351965
18361966
18371967
struct AioFile;
18381968
18391969
typedef struct {
@@ -1848,11 +1978,11 @@
18481978
typedef struct AioFile
18491979
{
18501980
FILE *fp;
18511981
Jim_Obj *filename;
18521982
int type;
1853
- int openFlags;
1983
+ int openFlags;
18541984
int fd;
18551985
Jim_Obj *rEvent;
18561986
Jim_Obj *wEvent;
18571987
Jim_Obj *eEvent;
18581988
int addr_family;
@@ -1879,21 +2009,21 @@
18792009
{
18802010
if (!ferror(af->fp)) {
18812011
return JIM_OK;
18822012
}
18832013
clearerr(af->fp);
1884
-
2014
+
18852015
if (feof(af->fp) || errno == EAGAIN || errno == EINTR) {
18862016
return JIM_OK;
18872017
}
18882018
#ifdef ECONNRESET
18892019
if (errno == ECONNRESET) {
18902020
return JIM_OK;
18912021
}
18922022
#endif
18932023
#ifdef ECONNABORTED
1894
- if (errno != ECONNABORTED) {
2024
+ if (errno == ECONNABORTED) {
18952025
return JIM_OK;
18962026
}
18972027
#endif
18982028
return JIM_ERR;
18992029
}
@@ -1935,10 +2065,19 @@
19352065
}
19362066
else {
19372067
Jim_SetResultString(interp, JimAioErrorString(af), -1);
19382068
}
19392069
}
2070
+
2071
+static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
2072
+{
2073
+ int ret = af->fops->error(af);
2074
+ if (ret) {
2075
+ JimAioSetError(interp, af->filename);
2076
+ }
2077
+ return ret;
2078
+}
19402079
19412080
static void JimAioDelProc(Jim_Interp *interp, void *privData)
19422081
{
19432082
AioFile *af = privData;
19442083
@@ -1945,20 +2084,19 @@
19452084
JIM_NOTUSED(interp);
19462085
19472086
Jim_DecrRefCount(interp, af->filename);
19482087
19492088
#ifdef jim_ext_eventloop
1950
-
1951
- Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
2089
+
2090
+ Jim_DeleteFileHandler(interp, af->fd, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
19522091
#endif
19532092
19542093
#if defined(JIM_SSL)
19552094
if (af->ssl != NULL) {
19562095
SSL_free(af->ssl);
19572096
}
19582097
#endif
1959
-
19602098
if (!(af->openFlags & AIO_KEEPOPEN)) {
19612099
fclose(af->fp);
19622100
}
19632101
19642102
Jim_Free(af);
@@ -1968,11 +2106,11 @@
19682106
{
19692107
AioFile *af = Jim_CmdPrivData(interp);
19702108
char buf[AIO_BUF_LEN];
19712109
Jim_Obj *objPtr;
19722110
int nonewline = 0;
1973
- jim_wide neededLen = -1;
2111
+ jim_wide neededLen = -1;
19742112
19752113
if (argc && Jim_CompareStringImmediate(interp, argv[0], "-nonewline")) {
19762114
nonewline = 1;
19772115
argv++;
19782116
argc--;
@@ -2007,11 +2145,11 @@
20072145
}
20082146
}
20092147
if (retval != readlen)
20102148
break;
20112149
}
2012
-
2150
+
20132151
if (JimCheckStreamError(interp, af)) {
20142152
Jim_FreeNewObj(interp, objPtr);
20152153
return JIM_ERR;
20162154
}
20172155
if (nonewline) {
@@ -2029,11 +2167,11 @@
20292167
20302168
AioFile *Jim_AioFile(Jim_Interp *interp, Jim_Obj *command)
20312169
{
20322170
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, command, JIM_ERRMSG);
20332171
2034
-
2172
+
20352173
if (cmdPtr && !cmdPtr->isproc && cmdPtr->u.native.cmdProc == JimAioSubCmdProc) {
20362174
return (AioFile *) cmdPtr->u.native.privData;
20372175
}
20382176
Jim_SetResultFormatted(interp, "Not a filehandle: \"%#s\"", command);
20392177
return NULL;
@@ -2048,10 +2186,20 @@
20482186
return NULL;
20492187
}
20502188
20512189
return af->fp;
20522190
}
2191
+
2192
+static int aio_cmd_getfd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
2193
+{
2194
+ AioFile *af = Jim_CmdPrivData(interp);
2195
+
2196
+ fflush(af->fp);
2197
+ Jim_SetResultInt(interp, fileno(af->fp));
2198
+
2199
+ return JIM_OK;
2200
+}
20532201
20542202
static int aio_cmd_copy(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
20552203
{
20562204
AioFile *af = Jim_CmdPrivData(interp);
20572205
jim_wide count = 0;
@@ -2110,21 +2258,21 @@
21102258
}
21112259
else {
21122260
len = strlen(buf);
21132261
21142262
if (len && (buf[len - 1] == '\n')) {
2115
-
2263
+
21162264
len--;
21172265
}
21182266
21192267
Jim_AppendString(interp, objPtr, buf, len);
21202268
break;
21212269
}
21222270
}
21232271
21242272
if (JimCheckStreamError(interp, af)) {
2125
-
2273
+
21262274
Jim_FreeNewObj(interp, objPtr);
21272275
return JIM_ERR;
21282276
}
21292277
21302278
if (argc) {
@@ -2134,11 +2282,11 @@
21342282
}
21352283
21362284
len = Jim_Length(objPtr);
21372285
21382286
if (len == 0 && feof(af->fp)) {
2139
-
2287
+
21402288
len = -1;
21412289
}
21422290
Jim_SetResultInt(interp, len);
21432291
}
21442292
else {
@@ -2207,11 +2355,11 @@
22072355
}
22082356
22092357
static int aio_cmd_close(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
22102358
{
22112359
if (argc == 3) {
2212
-#if !defined(JIM_ANSIC) && defined(HAVE_SHUTDOWN)
2360
+#if defined(HAVE_SOCKETS) && defined(HAVE_SHUTDOWN)
22132361
static const char * const options[] = { "r", "w", NULL };
22142362
enum { OPT_R, OPT_W, };
22152363
int option;
22162364
AioFile *af = Jim_CmdPrivData(interp);
22172365
@@ -2297,10 +2445,11 @@
22972445
}
22982446
Jim_SetResultInt(interp, (fmode & O_NONBLOCK) ? 1 : 0);
22992447
return JIM_OK;
23002448
}
23012449
#endif
2450
+
23022451
23032452
#ifdef HAVE_FSYNC
23042453
static int aio_cmd_sync(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
23052454
{
23062455
AioFile *af = Jim_CmdPrivData(interp);
@@ -2364,33 +2513,33 @@
23642513
23652514
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
23662515
int argc, Jim_Obj * const *argv)
23672516
{
23682517
if (argc == 0) {
2369
-
2518
+
23702519
if (*scriptHandlerObj) {
23712520
Jim_SetResult(interp, *scriptHandlerObj);
23722521
}
23732522
return JIM_OK;
23742523
}
23752524
23762525
if (*scriptHandlerObj) {
2377
-
2378
- Jim_DeleteFileHandler(interp, af->fp, mask);
2526
+
2527
+ Jim_DeleteFileHandler(interp, af->fd, mask);
23792528
}
23802529
2381
-
2530
+
23822531
if (Jim_Length(argv[0]) == 0) {
2383
-
2532
+
23842533
return JIM_OK;
23852534
}
23862535
2387
-
2536
+
23882537
Jim_IncrRefCount(argv[0]);
23892538
*scriptHandlerObj = argv[0];
23902539
2391
- Jim_CreateFileHandler(interp, af->fp, mask,
2540
+ Jim_CreateFileHandler(interp, af->fd, mask,
23922541
JimAioFileEventHandler, scriptHandlerObj, JimAioFileEventFinalizer);
23932542
23942543
return JIM_OK;
23952544
}
23962545
@@ -2414,136 +2563,145 @@
24142563
24152564
return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->eEvent, argc, argv);
24162565
}
24172566
#endif
24182567
2568
+
2569
+
24192570
24202571
static const jim_subcmd_type aio_command_table[] = {
24212572
{ "read",
24222573
"?-nonewline? ?len?",
24232574
aio_cmd_read,
24242575
0,
24252576
2,
2426
-
2577
+
24272578
},
24282579
{ "copyto",
24292580
"handle ?size?",
24302581
aio_cmd_copy,
24312582
1,
24322583
2,
2433
-
2584
+
2585
+ },
2586
+ { "getfd",
2587
+ NULL,
2588
+ aio_cmd_getfd,
2589
+ 0,
2590
+ 0,
2591
+
24342592
},
24352593
{ "gets",
24362594
"?var?",
24372595
aio_cmd_gets,
24382596
0,
24392597
1,
2440
-
2598
+
24412599
},
24422600
{ "puts",
24432601
"?-nonewline? str",
24442602
aio_cmd_puts,
24452603
1,
24462604
2,
2447
-
2605
+
24482606
},
24492607
{ "isatty",
24502608
NULL,
24512609
aio_cmd_isatty,
24522610
0,
24532611
0,
2454
-
2612
+
24552613
},
24562614
{ "flush",
24572615
NULL,
24582616
aio_cmd_flush,
24592617
0,
24602618
0,
2461
-
2619
+
24622620
},
24632621
{ "eof",
24642622
NULL,
24652623
aio_cmd_eof,
24662624
0,
24672625
0,
2468
-
2626
+
24692627
},
24702628
{ "close",
24712629
"?r(ead)|w(rite)?",
24722630
aio_cmd_close,
24732631
0,
24742632
1,
24752633
JIM_MODFLAG_FULLARGV,
2476
-
2634
+
24772635
},
24782636
{ "seek",
24792637
"offset ?start|current|end",
24802638
aio_cmd_seek,
24812639
1,
24822640
2,
2483
-
2641
+
24842642
},
24852643
{ "tell",
24862644
NULL,
24872645
aio_cmd_tell,
24882646
0,
24892647
0,
2490
-
2648
+
24912649
},
24922650
{ "filename",
24932651
NULL,
24942652
aio_cmd_filename,
24952653
0,
24962654
0,
2497
-
2655
+
24982656
},
24992657
#ifdef O_NDELAY
25002658
{ "ndelay",
25012659
"?0|1?",
25022660
aio_cmd_ndelay,
25032661
0,
25042662
1,
2505
-
2663
+
25062664
},
25072665
#endif
25082666
#ifdef HAVE_FSYNC
25092667
{ "sync",
25102668
NULL,
25112669
aio_cmd_sync,
25122670
0,
25132671
0,
2514
-
2672
+
25152673
},
25162674
#endif
25172675
{ "buffering",
25182676
"none|line|full",
25192677
aio_cmd_buffering,
25202678
1,
25212679
1,
2522
-
2680
+
25232681
},
25242682
#ifdef jim_ext_eventloop
25252683
{ "readable",
25262684
"?readable-script?",
25272685
aio_cmd_readable,
25282686
0,
25292687
1,
2530
-
2688
+
25312689
},
25322690
{ "writable",
25332691
"?writable-script?",
25342692
aio_cmd_writable,
25352693
0,
25362694
1,
2537
-
2695
+
25382696
},
25392697
{ "onexception",
25402698
"?exception-script?",
25412699
aio_cmd_onexception,
25422700
0,
25432701
1,
2544
-
2702
+
25452703
},
25462704
#endif
25472705
{ NULL }
25482706
};
25492707
@@ -2566,11 +2724,11 @@
25662724
25672725
#ifdef jim_ext_tclcompat
25682726
{
25692727
const char *filename = Jim_String(argv[1]);
25702728
2571
-
2729
+
25722730
if (*filename == '|') {
25732731
Jim_Obj *evalObj[3];
25742732
25752733
evalObj[0] = Jim_NewStringObj(interp, "::popen", -1);
25762734
evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
@@ -2603,42 +2761,44 @@
26032761
}
26042762
26052763
Jim_IncrRefCount(filename);
26062764
26072765
if (fh == NULL) {
2608
-#if !defined(JIM_ANSIC)
26092766
if (fd >= 0) {
2767
+#ifndef JIM_ANSIC
26102768
fh = fdopen(fd, mode);
2769
+#endif
26112770
}
26122771
else
2613
-#endif
26142772
fh = fopen(Jim_String(filename), mode);
26152773
26162774
if (fh == NULL) {
26172775
JimAioSetError(interp, filename);
2618
-#if !defined(JIM_ANSIC)
2776
+#ifndef JIM_ANSIC
26192777
if (fd >= 0) {
26202778
close(fd);
26212779
}
26222780
#endif
26232781
Jim_DecrRefCount(interp, filename);
26242782
return NULL;
26252783
}
26262784
}
26272785
2628
-
2786
+
26292787
af = Jim_Alloc(sizeof(*af));
26302788
memset(af, 0, sizeof(*af));
26312789
af->fp = fh;
2632
- af->fd = fileno(fh);
26332790
af->filename = filename;
2791
+ af->openFlags = openFlags;
2792
+#ifndef JIM_ANSIC
2793
+ af->fd = fileno(fh);
26342794
#ifdef FD_CLOEXEC
26352795
if ((openFlags & AIO_KEEPOPEN) == 0) {
26362796
(void)fcntl(af->fd, F_SETFD, FD_CLOEXEC);
26372797
}
26382798
#endif
2639
- af->openFlags = openFlags;
2799
+#endif
26402800
af->addr_family = family;
26412801
af->fops = &stdio_fops;
26422802
af->ssl = NULL;
26432803
26442804
Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc);
@@ -2653,72 +2813,45 @@
26532813
const char *hdlfmt, int family, const char *mode[2])
26542814
{
26552815
if (JimMakeChannel(interp, NULL, p[0], filename, hdlfmt, family, mode[0])) {
26562816
Jim_Obj *objPtr = Jim_NewListObj(interp, NULL, 0);
26572817
Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp));
2658
-
26592818
if (JimMakeChannel(interp, NULL, p[1], filename, hdlfmt, family, mode[1])) {
26602819
Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp));
26612820
Jim_SetResult(interp, objPtr);
26622821
return JIM_OK;
26632822
}
26642823
}
26652824
2666
-
2825
+
26672826
close(p[0]);
26682827
close(p[1]);
26692828
JimAioSetError(interp, NULL);
26702829
return JIM_ERR;
26712830
}
26722831
#endif
26732832
2674
-
2675
-int Jim_MakeTempFile(Jim_Interp *interp, const char *template)
2676
-{
2677
-#ifdef HAVE_MKSTEMP
2678
- int fd;
2679
- mode_t mask;
2680
- Jim_Obj *filenameObj;
2681
-
2682
- if (template == NULL) {
2683
- const char *tmpdir = getenv("TMPDIR");
2684
- if (tmpdir == NULL || *tmpdir == '\0' || access(tmpdir, W_OK) != 0) {
2685
- tmpdir = "/tmp/";
2686
- }
2687
- filenameObj = Jim_NewStringObj(interp, tmpdir, -1);
2688
- if (tmpdir[0] && tmpdir[strlen(tmpdir) - 1] != '/') {
2689
- Jim_AppendString(interp, filenameObj, "/", 1);
2690
- }
2691
- Jim_AppendString(interp, filenameObj, "tcl.tmp.XXXXXX", -1);
2692
- }
2693
- else {
2694
- filenameObj = Jim_NewStringObj(interp, template, -1);
2695
- }
2696
-
2697
-#if defined(S_IRWXG) && defined(S_IRWXO)
2698
- mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
2699
-#else
2700
-
2701
- mask = umask(S_IXUSR);
2702
-#endif
2703
-
2704
-
2705
- fd = mkstemp(filenameObj->bytes);
2706
- umask(mask);
2707
- if (fd < 0) {
2708
- JimAioSetError(interp, filenameObj);
2709
- Jim_FreeNewObj(interp, filenameObj);
2710
- return -1;
2711
- }
2712
-
2713
- Jim_SetResult(interp, filenameObj);
2714
- return fd;
2715
-#else
2716
- Jim_SetResultString(interp, "platform has no tempfile support", -1);
2717
- return -1;
2718
-#endif
2719
-}
2833
+#ifdef HAVE_PIPE
2834
+static int JimAioPipeCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
2835
+{
2836
+ int p[2];
2837
+ static const char *mode[2] = { "r", "w" };
2838
+
2839
+ if (argc != 1) {
2840
+ Jim_WrongNumArgs(interp, 1, argv, "");
2841
+ return JIM_ERR;
2842
+ }
2843
+
2844
+ if (pipe(p) != 0) {
2845
+ JimAioSetError(interp, NULL);
2846
+ return JIM_ERR;
2847
+ }
2848
+
2849
+ return JimMakeChannelPair(interp, p, argv[0], "aio.pipe%ld", 0, mode);
2850
+}
2851
+#endif
2852
+
27202853
27212854
27222855
int Jim_aioInit(Jim_Interp *interp)
27232856
{
27242857
if (Jim_PackageProvide(interp, "aio", "1.0", JIM_ERRMSG))
@@ -2727,15 +2860,18 @@
27272860
#if defined(JIM_SSL)
27282861
Jim_CreateCommand(interp, "load_ssl_certs", JimAioLoadSSLCertsCommand, NULL, NULL);
27292862
#endif
27302863
27312864
Jim_CreateCommand(interp, "open", JimAioOpenCommand, NULL, NULL);
2732
-#ifndef JIM_ANSIC
2865
+#ifdef HAVE_SOCKETS
27332866
Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
27342867
#endif
2868
+#ifdef HAVE_PIPE
2869
+ Jim_CreateCommand(interp, "pipe", JimAioPipeCommand, NULL, NULL);
2870
+#endif
27352871
2736
-
2872
+
27372873
JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
27382874
JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
27392875
JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
27402876
27412877
return JIM_OK;
@@ -2813,12 +2949,12 @@
28132949
#include <regex.h>
28142950
#endif
28152951
28162952
static void FreeRegexpInternalRep(Jim_Interp *interp, Jim_Obj *objPtr)
28172953
{
2818
- regfree(objPtr->internalRep.regexpValue.compre);
2819
- Jim_Free(objPtr->internalRep.regexpValue.compre);
2954
+ regfree(objPtr->internalRep.ptrIntValue.ptr);
2955
+ Jim_Free(objPtr->internalRep.ptrIntValue.ptr);
28202956
}
28212957
28222958
static const Jim_ObjType regexpObjType = {
28232959
"regexp",
28242960
FreeRegexpInternalRep,
@@ -2831,20 +2967,20 @@
28312967
{
28322968
regex_t *compre;
28332969
const char *pattern;
28342970
int ret;
28352971
2836
-
2972
+
28372973
if (objPtr->typePtr == &regexpObjType &&
2838
- objPtr->internalRep.regexpValue.compre && objPtr->internalRep.regexpValue.flags == flags) {
2839
-
2840
- return objPtr->internalRep.regexpValue.compre;
2974
+ objPtr->internalRep.ptrIntValue.ptr && objPtr->internalRep.ptrIntValue.int1 == flags) {
2975
+
2976
+ return objPtr->internalRep.ptrIntValue.ptr;
28412977
}
28422978
2843
-
28442979
2845
-
2980
+
2981
+
28462982
pattern = Jim_String(objPtr);
28472983
compre = Jim_Alloc(sizeof(regex_t));
28482984
28492985
if ((ret = regcomp(compre, pattern, REG_EXTENDED | flags)) != 0) {
28502986
char buf[100];
@@ -2857,12 +2993,12 @@
28572993
}
28582994
28592995
Jim_FreeIntRep(interp, objPtr);
28602996
28612997
objPtr->typePtr = &regexpObjType;
2862
- objPtr->internalRep.regexpValue.flags = flags;
2863
- objPtr->internalRep.regexpValue.compre = compre;
2998
+ objPtr->internalRep.ptrIntValue.int1 = flags;
2999
+ objPtr->internalRep.ptrIntValue.ptr = compre;
28643000
28653001
return compre;
28663002
}
28673003
28683004
int Jim_RegexpCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@@ -3001,11 +3137,11 @@
30013137
}
30023138
30033139
num_matches++;
30043140
30053141
if (opt_all && !opt_inline) {
3006
-
3142
+
30073143
goto try_next_match;
30083144
}
30093145
30103146
30113147
j = 0;
@@ -3041,11 +3177,11 @@
30413177
30423178
if (opt_inline) {
30433179
Jim_ListAppendElement(interp, resultListObj, resultObj);
30443180
}
30453181
else {
3046
-
3182
+
30473183
result = Jim_SetVariable(interp, argv[i], resultObj);
30483184
30493185
if (result != JIM_OK) {
30503186
Jim_FreeObj(interp, resultObj);
30513187
break;
@@ -3168,11 +3304,11 @@
31683304
31693305
source_str = Jim_GetString(argv[i + 1], &source_len);
31703306
replace_str = Jim_GetString(argv[i + 2], &replace_len);
31713307
varname = argv[i + 3];
31723308
3173
-
3309
+
31743310
resultObj = Jim_NewStringObj(interp, "", 0);
31753311
31763312
if (offset) {
31773313
if (offset < 0) {
31783314
offset += source_len + 1;
@@ -3183,11 +3319,11 @@
31833319
else if (offset < 0) {
31843320
offset = 0;
31853321
}
31863322
}
31873323
3188
-
3324
+
31893325
Jim_AppendString(interp, resultObj, source_str, offset);
31903326
31913327
31923328
n = source_len - offset;
31933329
p = source_str + offset;
@@ -3242,23 +3378,23 @@
32423378
}
32433379
32443380
p += pmatch[0].rm_eo;
32453381
n -= pmatch[0].rm_eo;
32463382
3247
-
3383
+
32483384
if (!opt_all || n == 0) {
32493385
break;
32503386
}
32513387
3252
-
3388
+
32533389
if ((regcomp_flags & REG_NEWLINE) == 0 && pattern[0] == '^') {
32543390
break;
32553391
}
32563392
3257
-
3393
+
32583394
if (pattern[0] == '\0' && n) {
3259
-
3395
+
32603396
Jim_AppendString(interp, resultObj, p, 1);
32613397
p++;
32623398
n--;
32633399
}
32643400
@@ -3265,11 +3401,11 @@
32653401
regexec_flags |= REG_NOTBOL;
32663402
} while (n);
32673403
32683404
Jim_AppendString(interp, resultObj, p, -1);
32693405
3270
-
3406
+
32713407
if (argc - i == 4) {
32723408
result = Jim_SetVariable(interp, varname, resultObj);
32733409
32743410
if (result == JIM_OK) {
32753411
Jim_SetResultInt(interp, num_matches);
@@ -3320,16 +3456,23 @@
33203456
33213457
# ifndef MAXPATHLEN
33223458
# define MAXPATHLEN JIM_PATH_LEN
33233459
# endif
33243460
3325
-#if defined(__MINGW32__) || defined(_MSC_VER)
3461
+#if defined(__MINGW32__) || defined(__MSYS__) || defined(_MSC_VER)
33263462
#define ISWINDOWS 1
33273463
#else
33283464
#define ISWINDOWS 0
33293465
#endif
33303466
3467
+
3468
+#if defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
3469
+ #define STAT_MTIME_US(STAT) ((STAT).st_mtimespec.tv_sec * 1000000ll + (STAT).st_mtimespec.tv_nsec / 1000)
3470
+#elif defined(HAVE_STRUCT_STAT_ST_MTIM)
3471
+ #define STAT_MTIME_US(STAT) ((STAT).st_mtim.tv_sec * 1000000ll + (STAT).st_mtim.tv_nsec / 1000)
3472
+#endif
3473
+
33313474
33323475
static const char *JimGetFileType(int mode)
33333476
{
33343477
if (S_ISREG(mode)) {
33353478
return "file";
@@ -3371,11 +3514,11 @@
33713514
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value));
33723515
}
33733516
33743517
static int StoreStatData(Jim_Interp *interp, Jim_Obj *varName, const struct stat *sb)
33753518
{
3376
-
3519
+
33773520
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
33783521
33793522
AppendStatElement(interp, listObj, "dev", sb->st_dev);
33803523
AppendStatElement(interp, listObj, "ino", sb->st_ino);
33813524
AppendStatElement(interp, listObj, "mode", sb->st_mode);
@@ -3384,39 +3527,44 @@
33843527
AppendStatElement(interp, listObj, "gid", sb->st_gid);
33853528
AppendStatElement(interp, listObj, "size", sb->st_size);
33863529
AppendStatElement(interp, listObj, "atime", sb->st_atime);
33873530
AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
33883531
AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
3532
+#ifdef STAT_MTIME_US
3533
+ AppendStatElement(interp, listObj, "mtimeus", STAT_MTIME_US(*sb));
3534
+#endif
33893535
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
33903536
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
33913537
3392
-
3538
+
33933539
if (varName) {
3394
- Jim_Obj *objPtr = Jim_GetVariable(interp, varName, JIM_NONE);
3540
+ Jim_Obj *objPtr;
3541
+ objPtr = Jim_GetVariable(interp, varName, JIM_NONE);
3542
+
33953543
if (objPtr) {
3396
- if (Jim_DictSize(interp, objPtr) < 0) {
3397
-
3544
+ Jim_Obj *objv[2];
3545
+
3546
+ objv[0] = objPtr;
3547
+ objv[1] = listObj;
3548
+
3549
+ objPtr = Jim_DictMerge(interp, 2, objv);
3550
+ if (objPtr == NULL) {
3551
+
33983552
Jim_SetResultFormatted(interp, "can't set \"%#s(dev)\": variable isn't array", varName);
33993553
Jim_FreeNewObj(interp, listObj);
34003554
return JIM_ERR;
34013555
}
34023556
3403
- if (Jim_IsShared(objPtr))
3404
- objPtr = Jim_DuplicateObj(interp, objPtr);
3405
-
3406
-
3407
- Jim_ListAppendList(interp, objPtr, listObj);
3408
- Jim_DictSize(interp, objPtr);
34093557
Jim_InvalidateStringRep(objPtr);
34103558
34113559
Jim_FreeNewObj(interp, listObj);
34123560
listObj = objPtr;
34133561
}
34143562
Jim_SetVariable(interp, varName, listObj);
34153563
}
34163564
3417
-
3565
+
34183566
Jim_SetResult(interp, listObj);
34193567
34203568
return JIM_OK;
34213569
}
34223570
@@ -3432,11 +3580,11 @@
34323580
}
34333581
else if (p == path) {
34343582
Jim_SetResultString(interp, "/", -1);
34353583
}
34363584
else if (ISWINDOWS && p[-1] == ':') {
3437
-
3585
+
34383586
Jim_SetResultString(interp, path, p - path + 1);
34393587
}
34403588
else {
34413589
Jim_SetResultString(interp, path, p - path);
34423590
}
@@ -3512,35 +3660,35 @@
35123660
char *newname = Jim_Alloc(MAXPATHLEN + 1);
35133661
char *last = newname;
35143662
35153663
*newname = 0;
35163664
3517
-
3665
+
35183666
for (i = 0; i < argc; i++) {
35193667
int len;
35203668
const char *part = Jim_GetString(argv[i], &len);
35213669
35223670
if (*part == '/') {
3523
-
3671
+
35243672
last = newname;
35253673
}
35263674
else if (ISWINDOWS && strchr(part, ':')) {
3527
-
3675
+
35283676
last = newname;
35293677
}
35303678
else if (part[0] == '.') {
35313679
if (part[1] == '/') {
35323680
part += 2;
35333681
len -= 2;
35343682
}
35353683
else if (part[1] == 0 && last != newname) {
3536
-
3684
+
35373685
continue;
35383686
}
35393687
}
35403688
3541
-
3689
+
35423690
if (last != newname && last[-1] != '/') {
35433691
*last++ = '/';
35443692
}
35453693
35463694
if (len) {
@@ -3551,22 +3699,22 @@
35513699
}
35523700
memcpy(last, part, len);
35533701
last += len;
35543702
}
35553703
3556
-
3704
+
35573705
if (last > newname + 1 && last[-1] == '/') {
3558
-
3706
+
35593707
if (!ISWINDOWS || !(last > newname + 2 && last[-2] == ':')) {
35603708
*--last = 0;
35613709
}
35623710
}
35633711
}
35643712
35653713
*last = 0;
35663714
3567
-
3715
+
35683716
35693717
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, newname, last - newname));
35703718
35713719
return JIM_OK;
35723720
}
@@ -3591,11 +3739,11 @@
35913739
static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
35923740
{
35933741
#ifdef X_OK
35943742
return file_access(interp, argv[0], X_OK);
35953743
#else
3596
-
3744
+
35973745
Jim_SetResultBool(interp, 1);
35983746
return JIM_OK;
35993747
#endif
36003748
}
36013749
@@ -3616,11 +3764,11 @@
36163764
while (argc--) {
36173765
const char *path = Jim_String(argv[0]);
36183766
36193767
if (unlink(path) == -1 && errno != ENOENT) {
36203768
if (rmdir(path) == -1) {
3621
-
3769
+
36223770
if (!force || Jim_EvalPrefix(interp, "file delete force", 1, argv) != JIM_OK) {
36233771
Jim_SetResultFormatted(interp, "couldn't delete file \"%s\": %s", path,
36243772
strerror(errno));
36253773
return JIM_ERR;
36263774
}
@@ -3639,15 +3787,15 @@
36393787
36403788
static int mkdir_all(char *path)
36413789
{
36423790
int ok = 1;
36433791
3644
-
3792
+
36453793
goto first;
36463794
36473795
while (ok--) {
3648
-
3796
+
36493797
{
36503798
char *slash = strrchr(path, '/');
36513799
36523800
if (slash && slash != path) {
36533801
*slash = 0;
@@ -3660,24 +3808,24 @@
36603808
first:
36613809
if (MKDIR_DEFAULT(path) == 0) {
36623810
return 0;
36633811
}
36643812
if (errno == ENOENT) {
3665
-
3813
+
36663814
continue;
36673815
}
3668
-
3816
+
36693817
if (errno == EEXIST) {
36703818
struct stat sb;
36713819
36723820
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
36733821