1all: 2# 3# Unless this file is named Makefile.in, you are probably looking 4# at an automatically generated/filtered copy and should probably not 5# edit it. 6# 7# This makefile is part of the teaish framework, a tool for building 8# Tcl extensions, conceptually related to TEA/tclconfig but using the 9# Autosetup configuration system instead of the GNU Autotools. 10# 11# A copy of this makefile gets processed for each extension separately 12# and populated with info about how to build, test, and install the 13# extension. 14# 15# Maintenance reminder: this file needs to stay portable with POSIX 16# Make, not just GNU Make. Yes, that's unfortunate because it makes 17# some things impossible (like skipping over swathes of rules when 18# 'make distclean' is invoked). 19# 20 21CC = @CC@ 22INSTALL = @BIN_INSTALL@ 23INSTALL.noexec = $(INSTALL) -m 0644 24 25# 26# Var name prefixes: 27# 28# teaish. => teaish core 29# tx. => teaish extension 30# 31# Vars with a "tx." or "teaish." prefix are all "public" for purposes 32# of the extension makefile, but the extension must not any "teaish." 33# vars and must only modify "tx." vars where that allowance is 34# specifically noted. 35# 36# Vars with a "teaish__" prefix are "private" and must not be used by 37# the extension makefile. They may change semantics or be removed in 38# any given teaish build. 39# 40tx.name = @TEAISH_NAME@ 41tx.version = @TEAISH_VERSION@ 42tx.name.pkg = @TEAISH_PKGNAME@ 43tx.libdir = @TEAISH_LIBDIR_NAME@ 44tx.loadPrefix = @TEAISH_LOAD_PREFIX@ 45tx.tcl = @TEAISH_TCL@ 46tx.makefile = @TEAISH_MAKEFILE@ 47tx.makefile.in = @TEAISH_MAKEFILE_IN@ 48tx.dll8.basename = @TEAISH_DLL8_BASENAME@ 49tx.dll9.basename = @TEAISH_DLL9_BASENAME@ 50tx.dll8 = @TEAISH_DLL8@ 51tx.dll9 = @TEAISH_DLL9@ 52tx.dll = $(tx.dll$(TCL_MAJOR_VERSION)) 53tx.dir = @TEAISH_EXT_DIR@ 54@if TEAISH_TM_TCL 55# Input filename for tcl::tm-style module 56tx.tm = @TEAISH_TM_TCL@ 57# Target filename for tcl::tm-style installation 58tx.tm.tgt = $(tx.name.pkg)-$(tx.version).tm 59@endif 60 61@if TEAISH_DIST_NAME 62tx.name.dist = @TEAISH_DIST_NAME@ 63@else 64tx.name.dist = $(teaish.name) 65@endif 66 67teaish.dir = @abs_top_srcdir@ 68#teaish.dir.autosetup = @TEAISH_AUTOSETUP_DIR@ 69teaish.makefile = Makefile 70teaish.makefile.in = $(teaish.dir)/Makefile.in 71teaish__auto.def = $(teaish.dir)/auto.def 72 73# 74# Autotools-conventional vars. We don't actually use these in this 75# makefile but some may be referenced by vars imported via 76# tclConfig.sh. They are part of the public API and may be reliably 77# depended on from teaish.make.in. 78# 79bindir = @bindir@ 80datadir = @datadir@ 81exec_prefix = @exec_prefix@ 82includedir = @includedir@ 83infodir = @infodir@ 84libdir = @libdir@ 85libexecdir = @libexecdir@ 86localstatedir = @localstatedir@ 87mandir = @mandir@ 88prefix = @prefix@ 89runstatedir = @runstatedir@ 90sbindir = @sbindir@ 91sharedstatedir = @sharedstatedir@ 92sysconfdir = @sysconfdir@ 93 94 95# 96# Vars derived (mostly) from tclConfig.sh. These may be reliably 97# used from the extension makefile. 98# 99TCLSH = @TCLSH_CMD@ 100TCL_CONFIG_SH = @TCL_CONFIG_SH@ 101TCL_EXEC_PREFIX = @TCL_EXEC_PREFIX@ 102TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@ 103TCL_LIBS = @TCL_LIBS@ 104TCL_LIB_SPEC = @TCL_LIB_SPEC@ 105TCL_MAJOR_VERSION = @TCL_MAJOR_VERSION@ 106TCL_MINOR_VERSION = @TCL_MINOR_VERSION@ 107TCL_PATCH_LEVEL = @TCL_PATCH_LEVEL@ 108TCL_PREFIX = @TCL_PREFIX@ 109TCL_SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@ 110TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@ 111TCL_VERSION = @TCL_VERSION@ 112TCLLIBDIR = @TCLLIBDIR@ 113 114# 115# CFLAGS.configure = CFLAGS as known at configure-time. 116# 117# This ordering is deliberate: flags populated via tcl's 118# [teaish-cflags-add] should preceed CFLAGS and CPPFLAGS (which 119# typically come from the ./configure command-line invocation). 120# 121CFLAGS.configure = @SH_CFLAGS@ @TEAISH_CFLAGS@ @CFLAGS@ @CPPFLAGS@ $(TCL_INCLUDE_SPEC) 122#CFLAGS.configure += -DUSE_TCL_STUBS=1 123 124# 125# LDFLAGS.configure = LDFLAGS as known at configure-time. 126# 127# This ordering is deliberate: flags populated via tcl's 128# [teaish-ldflags-add] should precede LDFLAGS (which typically 129# comes from the ./configure command-line invocation). 130# 131LDFLAGS.configure = @TEAISH_LDFLAGS@ @LDFLAGS@ 132 133# 134# Linker flags for linkhing a shared library. 135# 136LDFLAGS.shlib = @SH_LDFLAGS@ 137 138# 139# The following tx.XYZ vars may be populated/modified by teaish.tcl 140# and/or teaish.make. 141# 142 143# 144# tx.src is the list of source or object files to include in the 145# (single) compiler/linker invocation. This will initially contain any 146# sources passed to [teaish-src-add], but may also be appended to by 147# teaish.make. 148# 149tx.src =@TEAISH_EXT_SRC@ 150 151# 152# tx.CFLAGS is typically set by teaish.make, whereas TEAISH_CFLAGS 153# gets set up via the configure script. 154# 155tx.CFLAGS = 156 157# 158# tx.LDFLAGS is typically set by teaish.make, whereas TEAISH_LDFLAGS 159# gets set up via the configure script. 160# 161tx.LDFLAGS = 162 163# 164# The list of 'dist' files may be appended to from teaish.make.in. 165# It can also be set up from teaish.tcl using [teaish-dist-add] 166# and/or [teaish-src-add -dist ...]. 167# 168tx.dist.files = @TEAISH_DIST_FILES@ 169 170# List of deps which may trigger an auto-reconfigure. 171# 172teaish__autogen.deps = \ 173 $(tx.makefile.in) $(teaish.makefile.in) \ 174 $(tx.tcl) \ 175 @TEAISH_PKGINDEX_TCL_IN@ @TEAISH_TM_TCL_IN@ \ 176 @AUTODEPS@ 177 178@if TEAISH_MAKEFILE_IN 179$(tx.makefile): $(tx.makefile.in) 180@endif 181 182teaish.autoreconfig = \ 183 @TEAISH_AUTORECONFIG@ 184 185# 186# Problem: when more than one target can invoke TEAISH_AUTORECONFIG, 187# we can get parallel reconfigures running. Thus, targets which 188# may require reconfigure should depend on... 189# 190config.log: $(teaish__autogen.deps) 191 $(teaish.autoreconfig) 192# ^^^ We would love to skip this when running [dist]clean, but there's 193# no POSIX Make-portable way to do that. GNU Make can. 194.PHONY: reconfigure 195reconfigure: 196 $(teaish.autoreconfig) 197 198$(teaish.makefile): $(teaish__auto.def) $(teaish.makefile.in) \ 199 @AUTODEPS@ 200 201@if TEAISH_TESTER_TCL_IN 202@TEAISH_TESTER_TCL_IN@: 203@TEAISH_TESTER_TCL@: @TEAISH_TESTER_TCL_IN@ 204config.log: @TEAISH_TESTER_TCL@ 205@endif 206 207# 208# CC variant for compiling Tcl-using sources. 209# 210CC.tcl = \ 211 $(CC) -o $@ $(CFLAGS.configure) $(CFLAGS) $(tx.CFLAGS) 212 213# 214# CC variant for linking $(tx.src) into an extension DLL. Note that 215# $(tx.src) must come before $(LDFLAGS...) for linking to third-party 216# libs to work. 217# 218CC.dll = \ 219 $(CC.tcl) $(tx.src) $(LDFLAGS.shlib) \ 220 $(LDFLAGS.configure) $(LDFLAGS) $(tx.LDFLAGS) $(TCL_STUB_LIB_SPEC) 221 222@if TEAISH_ENABLE_DLL 223# 224# The rest of this makefile exists solely to support this brief 225# target: the extension shared lib. 226# 227$(tx.dll): $(tx.src) config.log 228 @if [ "x" = "x$(tx.src)" ]; then \ 229 echo "Makefile var tx.src (source/object files) is empty" 1>&2; \ 230 exit 1; \ 231 fi 232 $(CC.dll) 233 234all: $(tx.dll) 235@endif # TEAISH_ENABLE_DLL 236 237tclsh: $(teaish.makefile) config.log 238 @{ echo "#!/bin/sh"; echo 'exec $(TCLSH) "$$@"'; } > $@ 239 @chmod +x $@ 240 @echo "Created $@" 241 242# 243# Run the generated test script. 244# 245.PHONY: test-pre test-prepre test-core test test-post test-extension 246test-extension: # this name is reserved for use by teaish.make[.in] 247@if TEAISH_ENABLE_DLL 248test-prepre: $(tx.dll) 249@endif 250@if TEAISH_TESTER_TCL 251test-core.args = @TEAISH_TESTER_TCL@ 252@if TEAISH_ENABLE_DLL 253test-core.args += '$(tx.dll)' '$(tx.loadPrefix)' 254@else 255test-core.args += '' '' 256@endif 257test-core.args += @TEAISH_TESTUTIL_TCL@ 258test-core: test-pre 259 $(TCLSH) $(test-core.args) 260test-prepre: @TEAISH_TESTER_TCL@ 261@else # !TEAISH_TESTER_TCL 262test-prepre: 263@endif # TEAISH_TESTER_TCL 264test-pre: test-prepre 265test-core: test-pre 266test-post: test-core 267test: test-post 268 269# 270# Cleanup rules... 271# 272#.PHONY: clean-pre clean-core clean-post clean-extension 273# 274clean-pre: 275clean-core: clean-pre 276 rm -f $(tx.dll8) $(tx.dll9) tclsh 277clean-post: clean-core 278clean: clean-post 279 280.PHONY: distclean-pre distclean-core distclean-post clean-extension 281distclean-pre: clean 282distclean-core: distclean-pre 283 rm -f Makefile 284 rm -f config.log config.defines.txt 285@if TEAISH_MAKEFILE_IN 286@if TEAISH_MAKEFILE 287 rm -f @TEAISH_MAKEFILE@ 288@endif 289@endif 290@if TEAISH_TESTER_TCL_IN 291 rm -f @TEAISH_TESTER_TCL@ 292@endif 293@if TEAISH_PKGINDEX_TCL_IN 294 rm -f @TEAISH_PKGINDEX_TCL@ 295@endif 296@if TEAISH_PKGINIT_TCL_IN 297 rm -f @TEAISH_PKGINIT_TCL@ 298@endif 299@if TEAISH_TEST_TCL_IN 300 rm -f @TEAISH_TEST_TCL@ 301@endif 302distclean-post: distclean-core 303distclean: distclean-post 304# 305# The (dist)clean-extension targets are reserved for use by 306# client-side teaish.make. 307# 308# Client code which wants to clean up extra stuff should do so by 309# adding their cleanup target (e.g. clean-extension) as a dependency 310# to the 'clean' target, like so: 311# 312# clean: distclean-extension 313# distclean: distclean-extension 314# 315distclean-extension: 316clean-extension: 317 318# 319# Installation rules... 320# 321@if TEAISH_ENABLE_INSTALL 322.PHONY: install-pre install-core install-post install-test install-prepre install-extension 323install-extension: # this name is reserved for use by teaish.make 324 325@if TEAISH_ENABLE_DLL 326install-prepre: $(tx.dll) 327@else 328install-prepre: 329@endif 330 331@if TEAISH_TM_TCL 332install-core.tmdir = $(DESTDIR)@TEAISH_TCL_TM_DIR@ 333@endif 334 335install-pre: install-prepre 336install-core: install-pre 337 @if [ ! -d "$(DESTDIR)$(TCLLIBDIR)" ]; then \ 338 set -x; $(INSTALL) -d "$(DESTDIR)$(TCLLIBDIR)"; \ 339 fi 340# ^^^^ on some platforms, install -d fails if the target already exists. 341@if TEAISH_ENABLE_DLL 342 $(INSTALL) $(tx.dll) "$(DESTDIR)$(TCLLIBDIR)" 343@endif 344@if TEAISH_PKGINDEX_TCL 345 $(INSTALL.noexec) "@TEAISH_PKGINDEX_TCL@" "$(DESTDIR)$(TCLLIBDIR)" 346@endif 347@if TEAISH_PKGINIT_TCL 348 $(INSTALL.noexec) "@TEAISH_PKGINIT_TCL@" "$(DESTDIR)$(TCLLIBDIR)" 349@endif 350@if TEAISH_TM_TCL 351 @if [ ! -d "$(install-core.tmdir)" ]; then \ 352 set -x; $(INSTALL) -d "$(install-core.tmdir)"; \ 353 fi 354 $(INSTALL.noexec) "@TEAISH_TM_TCL@" "$(install-core.tmdir)/$(tx.tm.tgt)" 355@endif 356install-test: install-core 357 @echo "Post-install test of [package require $(tx.name.pkg) $(tx.version)]..."; \ 358 if echo \ 359 'set c 0; ' \ 360 '@TEAISH_POSTINST_PREREQUIRE@' \ 361 'if {[catch {package require $(tx.name.pkg) $(tx.version)}]} {incr c};' \ 362 'exit $$c' \ 363 | $(TCLSH) ; then \ 364 echo "passed"; \ 365 else \ 366 echo "FAILED"; \ 367 exit 1; \ 368 fi 369install-post: install-test 370install: install-post 371 372# 373# Uninstall rules... 374# 375.PHONY: uninstall uninstall-pre uninstall-core uninstall-post uninstall-extension 376uninstall-extension: # this name is reserved for use by teaish.make 377uninstall-pre: 378uninstall-core: uninstall-pre 379@if TEAISH_ENABLE_DLL 380 rm -fr "$(DESTDIR)$(TCLLIBDIR)" 381@endif 382@if TEAISH_TM_TCL 383 rm -f "$(DESTDIR)$(install-core.tmdir)/$(tx.tm.tgt)" 384@endif 385 386uninstall-post: uninstall-core 387 @echo "Uninstalled Tcl extension $(tx.name) $(tx.version)" 388uninstall: uninstall-post 389@endif # TEAISH_ENABLE_INSTALL 390 391@if TEAISH_MAKEFILE_IN 392Makefile: $(tx.makefile.in) 393config.log: $(teaish.makefile.in) 394@endif 395 396# 397# Package archive generation ("dist") rules... 398# 399@if TEAISH_ENABLE_DIST 400@if BIN_TAR 401@if BIN_ZIP 402 403# When installing teaish as part of "make dist", we need to run 404# configure with similar flags to what we last configured with but we 405# must not pass on any extension-specific flags, as those won't be 406# recognized when running in --teaish-install mode, causing 407# the sub-configure to fail. 408dist.flags = --with-tclsh=$(TCLSH) 409dist.reconfig = $(teaish.dir)/configure $(dist.flags) 410 411# Temp dir for dist.zip. Must be different than dist.tgz or else 412# parallel builds may hose the dist. 413teaish__dist.tmp.zip = teaish__dist_zip 414# 415# Make a distribution zip file... 416# 417dist.basename = $(tx.name.dist)-$(tx.version) 418dist.zip = $(dist.basename).zip 419.PHONY: dist.zip dist.zip-core dist.zip-post 420#dist.zip-pre: 421# We apparently can't add a pre-hook here, else "make dist" rebuilds 422# the archive each time it's run. 423$(dist.zip): $(tx.dist.files) 424 @rm -fr $(teaish__dist.tmp.zip) 425 @mkdir -p $(teaish__dist.tmp.zip)/$(dist.basename) 426 @tar cf $(teaish__dist.tmp.zip)/tmp.tar $(tx.dist.files) 427 @tar xf $(teaish__dist.tmp.zip)/tmp.tar -C $(teaish__dist.tmp.zip)/$(dist.basename) 428@if TEAISH_DIST_FULL 429 @$(dist.reconfig) \ 430 --teaish-install=$(teaish__dist.tmp.zip)/$(dist.basename) \ 431 --t-e-d=$(teaish__dist.tmp.zip)/$(dist.basename) >/dev/null 432@endif 433 @rm -f $(dist.basename)/tmp.tar $(dist.zip) 434 @cd $(teaish__dist.tmp.zip) && zip -q -r ../$(dist.zip) $(dist.basename) 435 @rm -fr $(teaish__dist.tmp.zip) 436 @ls -la $(dist.zip) 437dist.zip-core: $(dist.zip) 438dist.zip-post: dist.zip-core 439dist.zip: dist.zip-post 440dist: dist.zip 441undist-zip: 442 rm -f $(dist.zip) 443undist: undist-zip 444@endif #BIN_ZIP 445 446# 447# Make a distribution tarball... 448# 449teaish__dist.tmp.tgz = teaish__dist_tgz 450dist.tgz = $(dist.basename).tar.gz 451.PHONY: dist.tgz dist.tgz-core dist.tgz-post 452# dist.tgz-pre: 453# see notes in dist.zip 454$(dist.tgz): $(tx.dist.files) 455 @rm -fr $(teaish__dist.tmp.tgz) 456 @mkdir -p $(teaish__dist.tmp.tgz)/$(dist.basename) 457 @tar cf $(teaish__dist.tmp.tgz)/tmp.tar $(tx.dist.files) 458 @tar xf $(teaish__dist.tmp.tgz)/tmp.tar -C $(teaish__dist.tmp.tgz)/$(dist.basename) 459@if TEAISH_DIST_FULL 460 @rm -f $(teaish__dist.tmp.tgz)/$(dist.basename)/pkgIndex.tcl.in; # kludge 461 @$(dist.reconfig) \ 462 --teaish-install=$(teaish__dist.tmp.tgz)/$(dist.basename) \ 463 --t-e-d=$(teaish__dist.tmp.zip)/$(dist.basename) >/dev/null 464@endif 465 @rm -f $(dist.basename)/tmp.tar $(dist.tgz) 466 @cd $(teaish__dist.tmp.tgz) && tar czf ../$(dist.tgz) $(dist.basename) 467 @rm -fr $(teaish__dist.tmp.tgz) 468 @ls -la $(dist.tgz) 469dist.tgz-core: $(dist.tgz) 470dist.tgz-post: dist.tgz-core 471dist.tgz: dist.tgz-post 472dist: dist.tgz 473undist-tgz: 474 rm -f $(dist.tgz) 475undist: undist-tgz 476@else #!BIN_TAR 477dist: 478 @echo "The dist rules require tar, which configure did not find." 1>&2; exit 1 479@endif #BIN_TAR 480@else #!TEAISH_ENABLE_DIST 481undist: 482dist: 483@if TEAISH_OUT_OF_EXT_TREE 484 @echo "'dist' can only be used from an extension's home dir" 1>&2; \ 485 echo "In this case: @TEAISH_EXT_DIR@" 1>&2; exit 1 486@endif 487@endif #TEAISH_ENABLE_DIST 488 489Makefile: @TEAISH_TCL@ 490 491@if TEAISH_MAKEFILE_CODE 492# 493# TEAISH_MAKEFILE_CODE may contain literal makefile code, which 494# gets pasted verbatim here. Either [define TEAISH_MAKEFILE_CODE 495# ...] or use [teaish-make-add] to incrementally build up this 496# content. 497# 498# <TEAISH_MAKEFILE_CODE> 499@TEAISH_MAKEFILE_CODE@ 500# </TEAISH_MAKEFILE_CODE> 501@endif 502 503@if TEAISH_MAKEFILE 504# 505# TEAISH_MAKEFILE[_IN] defines any extension-specific state this file 506# needs. 507# 508# It must set the following vars if they're not already accounted for 509# via teaish.tcl. 510# 511# - tx.src = list of the extension's source files, being sure to 512# prefix each with $(tx.dir) (if it's in the same dir as the 513# extension) so that out-of-tree builds can find them. Optionally, 514# [define] TEAISH_EXT_SRC or pass them to [teaish-src-add]. 515# 516# It may optionally set the following vars: 517# 518# - tx.CFLAGS = CFLAGS/CPPFLAGS. Optionally, [define] TEAISH_CFLAGS 519# or pass them to [teaish-cflags-add]. 520# 521# - tx.LDFLAGS = LDFLAGS. Optionally, [define] TEAISH_LDFLAGS or 522# pass them to [teaish-ldflags-add]. 523# 524# It may optionally hook into various targets as documented in 525# /doc/extensions.md in the canonical teaish source tree. 526# 527# Interestingly, we don't have to pre-filter teaish.makefile.in - we 528# can just @include it here. That skips its teaish-specific validation 529# though. Hmm. 530# 531# <TEAISH_MAKEFILE> 532Makefile: @TEAISH_MAKEFILE@ 533@include @TEAISH_MAKEFILE@ 534# </TEAISH_MAKEFILE> 535@endif 536