Jim Tcl
Check-in [b5c6f1bdf0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:build: improve build for shared objects

Rather than listing the build rules for each shared object (loadable module) in the Makefile template, generate the build rules in configure.

Also, if an extension is configured as a module, any automatic dependencies required by the extension are configured as modules by default.

Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk |
Files: files | file ages | folders
SHA1: b5c6f1bdf0250b050345f136bcd904cf8f7d1481
User & Date: steveb@workware.net.au 2019-11-06 07:42:55
Context
2019-11-08
04:20
Improve comments for JimResetHashTable()

and Jim_FreeHashTable()

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: fc6a281ba4 user: steveb@workware.net.au tags: trunk,

2019-11-06
07:42
build: improve build for shared objects

Rather than listing the build rules for each shared object (loadable module) in the Makefile template, generate the build rules in configure.

Also, if an extension is configured as a module, any automatic dependencies required by the extension are configured as modules by default.

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: b5c6f1bdf0 user: steveb@workware.net.au tags: trunk,

07:39
docs: Formatting cleanups, consistency

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: da3b52d11c user: steveb@workware.net.au tags: trunk,

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Makefile.in.

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
	$(Q)$(AR) cr $@ $(OBJS)
	$(Q)$(RANLIB) $@
@else
	$(ECHO) "	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SH_LDFLAGS) -o $@ $(OBJS) $(LDLIBS) $(LIBS)
@endif

# Note that $> $^ is for compatibility with both GNU make and BSD make
readdir.so: jim-readdir.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-readdir.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-readdir.o $(SH_LIBJIM)

array.so: jim-array.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-array.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-array.o $(SH_LIBJIM)

clock.so: jim-clock.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-clock.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-clock.o $(SH_LIBJIM)

file.so: jim-file.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-file.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-file.o $(SH_LIBJIM)

interp.so: jim-interp.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-interp.o jim-interp.c
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-interp.o $(SH_LIBJIM) @LDLIBS_interp@

posix.so: jim-posix.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-posix.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-posix.o $(SH_LIBJIM)

regexp.so: jim-regexp.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-regexp.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-regexp.o $(SH_LIBJIM)

syslog.so: jim-syslog.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-syslog.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-syslog.o $(SH_LIBJIM)

readline.so: jim-readline.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-readline.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-readline.o $(SH_LIBJIM) @LDLIBS_readline@

pack.so: jim-pack.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-pack.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-pack.o $(SH_LIBJIM) @LDLIBS_pack@

tclprefix.so: jim-tclprefix.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-tclprefix.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-tclprefix.o $(SH_LIBJIM) @LDLIBS_tclprefix@

sqlite3.so: jim-sqlite3.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-sqlite3.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-sqlite3.o $(SH_LIBJIM) @LDLIBS_sqlite3@

win32.so: jim-win32.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-win32.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-win32.o $(SH_LIBJIM) @LDLIBS_win32@

mk.so: jim-mk.cpp
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CXX) $(CXXFLAGS) $(SHOBJ_CFLAGS) -c -o jim-mk.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-mk.o $(SH_LIBJIM) @LDLIBS_mk@

sdl.so: jim-sdl.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-sdl.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-sdl.o $(SH_LIBJIM) @LDLIBS_sdl@

zlib.so: jim-zlib.c
	$(ECHO)	"	CC	${@:.so=.o}"
	$(Q)$(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o jim-zlib.o $> $^
	$(ECHO)	"	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ jim-zlib.o $(SH_LIBJIM) @LDLIBS_zlib@

docs: Tcl.html

@if INSTALL_DOCS eq "nodocs"
install-docs:
@endif








|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







150
151
152
153
154
155
156
157































































































158
159
160
161
162
163
164
	$(Q)$(AR) cr $@ $(OBJS)
	$(Q)$(RANLIB) $@
@else
	$(ECHO) "	LDSO	$@"
	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(SH_LDFLAGS) -o $@ $(OBJS) $(LDLIBS) $(LIBS)
@endif

@BUILD_SHOBJS@
































































































docs: Tcl.html

@if INSTALL_DOCS eq "nodocs"
install-docs:
@endif

Changes to auto.def.

490
491
492
493
494
495
496

















497
498
499
500
501
502
503
504
505
define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)]
define C_EXT_SHOBJS [suffix .so $extinfo(module-c)]
define TCL_EXTS [suffix .tcl $extinfo(module-tcl)]
define EXTRA_OBJS $extra_objs

# Restore the user-specified LIBS
define LIBS $LIBS


















make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*}
make-template Makefile.in
make-template tests/Makefile.in
make-template build-jim-ext.in
make-template jimtcl.pc.in

catch {exec chmod +x build-jim-ext}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)]
define C_EXT_SHOBJS [suffix .so $extinfo(module-c)]
define TCL_EXTS [suffix .tcl $extinfo(module-tcl)]
define EXTRA_OBJS $extra_objs

# Restore the user-specified LIBS
define LIBS $LIBS

# Now generate the Makefile rules to build the external C shared objects
# It is easier to do this here rather than listing them out explicitly in Makefile.in
set lines {}
foreach mod $extinfo(module-c) {
    set objs {}
    set libs [get-define LDLIBS_$mod]
    set src jim-$mod.c
    lappend lines "$mod.so: $src"
    set obj [file rootname $src].o
    lappend lines "\t\$(ECHO)\t\"\tCC\t$obj\""
    lappend lines "\t\$(Q)\$(CC) \$(CFLAGS) \$(SHOBJ_CFLAGS) -c -o $obj $src"
    lappend lines "\t\$(ECHO)\t\"\tLDSO\t\$@\""
    lappend lines "\t\$(Q)\$(CC) \$(CFLAGS) \$(LDFLAGS) \$(SHOBJ_LDFLAGS) -o \$@ $obj \$(SH_LIBJIM) $libs"
    lappend lines ""
}
define BUILD_SHOBJS [join $lines \n]

make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*}
make-template Makefile.in
make-template tests/Makefile.in
make-template build-jim-ext.in
make-template jimtcl.pc.in

catch {exec chmod +x build-jim-ext}

Changes to autosetup/local.tcl.

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
75
76
77
78
79
80
81


82




83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
proc ext-get-status {ext} {
    if {[dict exists $::extdb status $ext]} {
        return [dict get $::extdb status $ext]
    }
    return ?
}

proc check-extension-status {ext required} {
    global withinfo

    set status [ext-get-status $ext]

    if {$ext in $withinfo(without)} {
        # Disabled without further ado
        msg-result "Extension $ext...disabled"
................................................................................
            # "check" conditions are met
        } else {
            # not met
            incr depinfo(n)
        }
    }



    if {$ext in $withinfo(mod)} {




        # This is a module, so ignore LIBS
        # LDLIBS_$ext will contain the appropriate libs for this module
        define LIBS $LIBS
    }

    if {$depinfo(n) == 0} {
        # Now extension dependencies
        foreach i [ext-get $ext dep] {
            set status [check-extension-status $i $required]
            #puts "$ext: dep $i $required => $status"
            incr depinfo($status)
            if {$depinfo(n)} {
                break
            }
        }
    }
................................................................................
        if {$required eq "required"} {
            user-error "dependencies not met"
        }
        msg-result "disabled (dependencies)"
        return [ext-set-status $ext n]
    }

    # Selected as a module?
    if {$ext in $withinfo(mod)} {
        if {[ext-has $ext tcl]} {
            # Easy, a Tcl module
            msg-result "Extension $ext...tcl"
        } elseif {[ext-has $ext static]} {
            user-error "Extension $ext can't be a module"
        } else {
            msg-result "Extension $ext...module"







|







 







>
>
|
>
>
>
>








|







 







|
|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
proc ext-get-status {ext} {
    if {[dict exists $::extdb status $ext]} {
        return [dict get $::extdb status $ext]
    }
    return ?
}

proc check-extension-status {ext required {asmodule 0}} {
    global withinfo

    set status [ext-get-status $ext]

    if {$ext in $withinfo(without)} {
        # Disabled without further ado
        msg-result "Extension $ext...disabled"
................................................................................
            # "check" conditions are met
        } else {
            # not met
            incr depinfo(n)
        }
    }

    # asmodule=1 means that the parent is a module so
    # any automatically selected dependencies should also be modules
    if {$asmodule == 0 && $ext in $withinfo(mod)} {
        set asmodule 1
    }

    if {$asmodule} {
        # This is a module, so ignore LIBS
        # LDLIBS_$ext will contain the appropriate libs for this module
        define LIBS $LIBS
    }

    if {$depinfo(n) == 0} {
        # Now extension dependencies
        foreach i [ext-get $ext dep] {
            set status [check-extension-status $i $required $asmodule]
            #puts "$ext: dep $i $required => $status"
            incr depinfo($status)
            if {$depinfo(n)} {
                break
            }
        }
    }
................................................................................
        if {$required eq "required"} {
            user-error "dependencies not met"
        }
        msg-result "disabled (dependencies)"
        return [ext-set-status $ext n]
    }

    # Selected as a module directly or because of a parent dependency?
    if {$asmodule} {
        if {[ext-has $ext tcl]} {
            # Easy, a Tcl module
            msg-result "Extension $ext...tcl"
        } elseif {[ext-has $ext static]} {
            user-error "Extension $ext can't be a module"
        } else {
            msg-result "Extension $ext...module"