Tcl Extension Architecture (TEA) Sample Extension

Check-in [6f3945d120]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Moving most of the heavy lifting for install into the make.tcl file

The Makefile is evoloving into an inert bit that just invokes make.tcl calls.

Added a local make.tcl to the directory which redirects to the real make.tcl file in the source folder

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | practcl
Files: files | file ages | folders
SHA1: 6f3945d1208b4968a0e0fc58569fb8e69e23dc7d
User & Date: hypnotoad 2016-06-25 14:53:20
Context
2016-06-25
14:54
Tweak to ensure we don't overwrite the real make.tcl check-in: 13adaa3c2c user: hypnotoad tags: practcl
14:53
Moving most of the heavy lifting for install into the make.tcl file

The Makefile is evoloving into an inert bit that just invokes make.tcl calls.

Added a local make.tcl to the directory which redirects to the real make.tcl file in the source folder check-in: 6f3945d120 user: hypnotoad tags: practcl

2016-06-24
17:03
Modified the example to utilize practcl, but in a minimalist fashion while still preserving most of the inner workings of the existing TEA makefile and autoconf Leaf check-in: e027e8471f user: hypnotoad tags: practcl-make
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Makefile.in.

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
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
PKG_HEADERS	= @[email protected]

#========================================================================
# "PKG_LIB_FILE" refers to the library (dynamic or static as per
# configuration options) composed of the named objects.
#========================================================================

include sample.mk

PKG_LIB_FILE	= @[email protected]
PKG_STUB_LIB_FILE = @[email protected]

lib_BINARIES	= $(PKG_LIB_FILE)
BINARIES	= $(lib_BINARIES)

SHELL		= @[email protected]
................................................................................
#========================================================================
# The binaries target builds executable programs, Windows .dll's, unix
# shared/static libraries, and any other platform-dependent files.
# The list of targets to build for "binaries:" is specified at the top
# of the Makefile, in the "BINARIES" variable.
#========================================================================

binaries: $(BINARIES)


libraries:


#========================================================================
# Your doc target should differentiate from doc builds (by the developer)
# and doc installs (see install-doc), which just install the docs on the
# end user machine when building from source.
#========================================================================

doc:
	@echo "If you have documentation to create, place the commands to"
	@echo "build the docs in the 'doc:' target.  For example:"
	@echo "        xml2nroff sample.xml > sample.n"
	@echo "        xml2html sample.xml > sample.html"

install: all install-binaries install-libraries install-doc

install-binaries: binaries install-lib-binaries install-bin-binaries

#========================================================================
# This rule installs platform-independent files, such as header files.
# The list=...; for p in $$list handles the empty list case x-platform.
#========================================================================

install-libraries: libraries
	@$(INSTALL_DATA_DIR) $(DESTDIR)$(includedir)
	@echo "Installing header files in $(DESTDIR)$(includedir)"
	@list='$(PKG_HEADERS)'; for i in $$list; do \
	    echo "Installing $(srcdir)/$$i" ; \
	    $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir) ; \
	done;


#========================================================================
# Install documentation.  Unix manpages should go in the $(mandir)
# directory.
#========================================================================

install-doc: doc
	@$(INSTALL_DATA_DIR) $(DESTDIR)$(mandir)/mann
	@echo "Installing documentation in $(DESTDIR)$(mandir)"
	@list='$(srcdir)/doc/*.n'; for i in $$list; do \
	    echo "Installing $$i"; \
	    $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/mann ; \
	done


test: binaries libraries
	$(TCLSH) `@[email protected] $(srcdir)/tests/all.tcl` $(TESTFLAGS) \
		-load "package ifneeded ${PACKAGE_NAME} ${PACKAGE_VERSION} \
			[list load `@[email protected] $(PKG_LIB_FILE)` $(PACKAGE_NAME)]"

shell: binaries libraries






<
<







 







|
>
|

>













<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
>

<
<
<
<
<
|
<
<
<
<
<
<
>







50
51
52
53
54
55
56


57
58
59
60
61
62
63
...
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
PKG_HEADERS	= @[email protected]

#========================================================================
# "PKG_LIB_FILE" refers to the library (dynamic or static as per
# configuration options) composed of the named objects.
#========================================================================



PKG_LIB_FILE	= @[email protected]
PKG_STUB_LIB_FILE = @[email protected]

lib_BINARIES	= $(PKG_LIB_FILE)
BINARIES	= $(lib_BINARIES)

SHELL		= @[email protected]
................................................................................
#========================================================================
# The binaries target builds executable programs, Windows .dll's, unix
# shared/static libraries, and any other platform-dependent files.
# The list of targets to build for "binaries:" is specified at the top
# of the Makefile, in the "BINARIES" variable.
#========================================================================

binaries:
	$(TCLSH) ${srcdir}/make.tcl binaries
	
libraries:
	$(TCLSH) ${srcdir}/make.tcl library

#========================================================================
# Your doc target should differentiate from doc builds (by the developer)
# and doc installs (see install-doc), which just install the docs on the
# end user machine when building from source.
#========================================================================

doc:
	@echo "If you have documentation to create, place the commands to"
	@echo "build the docs in the 'doc:' target.  For example:"
	@echo "        xml2nroff sample.xml > sample.n"
	@echo "        xml2html sample.xml > sample.html"










install:






	$(TCLSH) ${srcdir}/make.tcl install $(DESTDIR)






install-package:






	$(TCLSH) ${srcdir}/make.tcl install-package $(DESTDIR)

test: binaries libraries
	$(TCLSH) `@[email protected] $(srcdir)/tests/all.tcl` $(TESTFLAGS) \
		-load "package ifneeded ${PACKAGE_NAME} ${PACKAGE_VERSION} \
			[list load `@[email protected] $(PKG_LIB_FILE)` $(PACKAGE_NAME)]"

shell: binaries libraries

Changes to make.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21

22





















23








24
25
26
27
28
29

30
31
32
33
34
35
36
37
38







39







































































































set CWD [pwd]
set ::project(builddir) $::CWD
set ::project(srcdir) [file dirname [file normalize [info script]]]
set ::project(sandbox)  [file dirname $::project(srcdir)]

if {[file exists [file join $CWD .. tclconfig practcl.tcl]]} {
  source [file join $CWD .. tclconfig practcl.tcl]
} else {
  source [file join $SRCPATH tclconfig practcl.tcl]
}


array set ::project [::practcl::config.tcl $CWD]
::practcl::library create LIBRARY [array get ::project]
LIBRARY add [file join $::project(srcdir) generic sample.c]
LIBRARY add [file join $::project(srcdir) generic sample.tcl]

###
# Create build targets
###

::practcl::target autoconf {}























switch [lindex $argv 0] {








  default {
    ::practcl::trigger {*}$argv
  }
}

if {$make(autoconf)} {

  LIBRARY implement $::project(builddir)
  set fout [open pkgIndex.tcl w]
  puts $fout "
  #
  # Tcl package index file
  #
  "
  puts $fout [LIBRARY package-ifneeded]
  close $fout







}











































































































|
|









|



>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>





|
>
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
set CWD [pwd]
set ::project(builddir) $::CWD
set ::project(srcdir) [file dirname [file normalize [info script]]]
set ::project(sandbox)  [file dirname $::project(srcdir)]

if {[file exists [file join $CWD $::project(sandbox) tclconfig practcl.tcl]]} {
  source [file join $CWD $::project(sandbox) tclconfig practcl.tcl]
} else {
  source [file join $SRCPATH tclconfig practcl.tcl]
}


array set ::project [::practcl::config.tcl $CWD]
::practcl::library create LIBRARY [array get ::project]
LIBRARY add [file join $::project(srcdir) generic sample.c]
LIBRARY add [file join $::project(srcdir) generic sample.tcl]
LIBRARY define add public-verbatim [file join $::project(srcdir) generic sample.h]
###
# Create build targets
###
::practcl::target implement {}
::practcl::target autoconf {
  triggers implement
}
::practcl::target all {
  triggers library
}
::practcl::target binaries {
  triggers library
}
::practcl::target libraries {
  triggers library
}
::practcl::target library {
  triggers implement
}
::practcl::target doc {}

::practcl::target install {
  depends {library doc}
  triggers {install-package}
}
::practcl::target install-package {
  depends {library doc}
}
switch [lindex $argv 0] {
  install {
    ::practcl::trigger install
    set DESTDIR [file normalize [string trimright [lindex $argv 1]]]
  }
  install-package {
    ::practcl::trigger install
    set DESTDIR [file normalize [string trimright [lindex $argv 1]]]
  }
  default {
    ::practcl::trigger {*}$argv
  }
}

if {$make(implement)} {
  LIBRARY go
  LIBRARY implement $::project(builddir)
  set fout [open pkgIndex.tcl w]
  puts $fout "
  #
  # Tcl package index file
  #
  "
  puts $fout [LIBRARY package-ifneeded]
  close $fout
  if {![file exists make.tcl]} {
    set fout [open make.tcl w]
    puts $fout "# Redirect to the make file that lives in the project's source dir"
    puts $fout [list source [file join $::project(srcdir) make.tcl]]
    close $fout
    if {$::tcl_platform(platform)!="windows"} {
      file attributes -permission a+x make.tcl
    }
  }
}

if {$make(autoconf)} {
  #set mkout [open sample.mk w]
  #puts $mkout [::practcl::build::Makefile $::project(builddir) LIBRARY]
  #close $mkout
  LIBRARY generate-decls [LIBRARY define get name] $::project(builddir)
  set fout [open make.tcl w]
  puts $fout [list source [file join $::project(srcdir) make.tcl]]
}

if {$make(library)} {
  puts "BUILDING [LIBRARY define get libfile]"
  ::practcl::build::library [LIBRARY define get libfile] LIBRARY
}

# Generate documentation
if {$make(doc)} {

}

if {![info exists DESTDIR] && [info exists ::env(DESTDIR)]} {
  set DESTDIR $::env(DESTDIR)
} else {
  set DESTDIR {}
}

###
# Build local variables needed for install
###
set dat [LIBRARY define dump]
set PKG_DIR [dict get $dat name][dict get $dat version]
dict with dat {}
if {$DESTDIR ne {}} {
  foreach path {
    includedir
    mandir
    datadir
    libdir
  } {
    set $path [file join [string trimright $DESTDIR /] [string trimleft [set $path] /]]
  }
}
set pkgdatadir [file join $datadir $PKG_DIR]
set pkglibdir [file join $libdir $PKG_DIR]
set pkgincludedir [file join $includedir $PKG_DIR]

if {$make(install)} {
  #========================================================================
  # This rule installs platform-independent files, such as header files.
  #========================================================================
  puts "Installing header files in ${includedir}"
  set result {}
  foreach hfile [LIBRARY install-headers] {
    ::practcl::installDir [file join $srcdir $hfile] ${includedir}
  }
  
  #========================================================================
  # Install documentation.  Unix manpages should go in the $(mandir)
  # directory.
  #========================================================================
  puts "Installing documentation in ${mandir}"
  foreach file [glob -nocomplain [file join $srcdir doc *.n]] {
    if {$DESTDIR ne {}} {
      ::practcl::installDir $file [file join ${DESTDIR} ${mandir} mann]
    } else {
      ::practcl::installDir $file [file join ${mandir} mann]
    }
  }
}

if {$make(install-package)} {
  #========================================================================
  # Install binary object libraries.  On Windows this includes both .dll and
  # .lib files.  Because the .lib files are not explicitly listed anywhere,
  # we need to deduce their existence from the .dll file of the same name.
  # Library files go into the lib directory.
  # In addition, this will generate the pkgIndex.tcl
  # file in the install location (assuming it can find a usable tclsh shell)
  #
  # You should not have to modify this target.
  #========================================================================
  puts "Installing Library to ${pkglibdir}"
  if {$DESTDIR ne {}} {
    ::practcl::installDir [LIBRARY define get libfile] [file join ${DESTDIR} $pkglibdir]
    foreach file [glob -nocomplain *.lib] {
      ::practcl::installDir $file [file join ${DESTDIR} $pkglibdir]
    }
    if {[LIBRARY define get output_tcl] ne {}} {
      ::practcl::installDir [LIBRARY define get output_tcl] [file join ${DESTDIR} $pkglibdir] 
    }
  } else {
    ::practcl::installDir [LIBRARY define get libfile] $pkglibdir
    foreach file [glob -nocomplain *.lib] {
      ::practcl::installDir $file $pkglibdir
    }
    ::practcl::installDir pkgIndex.tcl $pkglibdir
    if {[LIBRARY define get output_tcl] ne {}} {
      ::practcl::installDir [LIBRARY define get output_tcl] $pkglibdir
    }
  }
}