#===============================================================================
# $Id: tcl-macros,v 1.6 2006/07/20 17:12:15 me Exp $
#===============================================================================
# tclsh binary
%__tclsh %_bindir/tclsh

# tcl directory layout
%_tcllibdir %_libdir/tcl
%_tcldatadir %_datadir/tcl

# macros from rpm/platform.in
%_tcl_lib_path	""
%_tcl_req_method	normal
%_tcl_req_skip	""

%set_tcl_req_method()	%global _tcl_req_method %1

%add_tcl_req_skip()	%global _tcl_req_skip %_tcl_req_skip %*
%add_tcl_lib_path()	%global _tcl_lib_path %_tcl_lib_path %*

%_tclpkglibdir %{!?_tea_noarch:\\$(libdir)}%{?_tea_noarch:\\$(datadir)}/tcl

# helpers
%tea_patch(fvb:C:) \
%{-v:_verbose=1}%{!-v:set +x} \
set -a \
%{-f:_force=1} \
%{-b:_backup="%{-b*}"}%{!-b:_backup="..tea3"} \
%{-C:_mydir="`pwd`"; cd "%{-C*}"} \
if [ -n "$_force" -a -f aclocal.m4 ]; then \
sed -i '/^builtin(include,.\\+\\/tcl.m4)/d' aclocal.m4 \
fi \
if [ -f Makefile.in ]; then \
cat <<EOF |%__tclsh \
set fc [read [set f [open Makefile.in]] [file size Makefile.in]] \
close \\\$f \
if {[info exists env\(_backup\)] && ![string eq \\\$env\(_backup\) ""]} { \
puts -nonewline [set f [open Makefile.in\\\$env\(_backup\) w]] \\\$fc \
close \\\$f \
} \
regsub {(?x) \
    (\\\npkgdatadir\\\s*=\\\s*\\\\\\$\\\(datadir\\\)/)(\\\\\\$\\\(PKG_DIR\\\)) \
} \\\$fc {\\\1tcl/\\\2} fc \
regsub {(?x) \
    (\\\npkglibdir\\\s*=\\\s*)\\\\\\$\\\(libdir\\\)/(\\\\\\$\\\(PKG_DIR\\\)) \
} \\\$fc {\\\1%_tclpkglibdir/\\\2} fc \
puts -nonewline [set f [open Makefile.in w]] \\\$fc \
close \\\$f \
EOF\
fi \
if [ -n "$_verbose" -a -n "$_backup" ]; then \
gendiff . "$_backup" ||: \
fi \
%{-f:unset _force} \
%{-v:unset _verbose}%{!-v:set -x} \
%{-b:unset _backup} \
%{-C:cd "${_mydir}"; unset _mydir} \
set +a \
%nil

%teapatch(fvb:C:) \
%{warning %%teapatch is deprecated, use %%tea_patch instread (see https://www.altlinux.org/TCL_Policy)} \
%{-v:_verbose=1}%{!-v:set +x} \
set -a \
%{-f:_force=1} \
%{-b:_backup="%{-b*}"}%{!-b:_backup="..tea3"} \
%{-C:_mydir="`pwd`"; cd "%{-C*}"} \
if [ -n "$_force" -a -f aclocal.m4 ]; then \
sed -i '/^builtin(include,.\\+\\/tcl.m4)/d' aclocal.m4 \
fi \
if [ -f Makefile.in ]; then \
cat <<EOF |%__tclsh \
set fc [read [set f [open Makefile.in]] [file size Makefile.in]] \
close \\\$f \
if {[info exists env\(_backup\)] && ![string eq \\\$env\(_backup\) ""]} { \
puts -nonewline [set f [open Makefile.in\\\$env\(_backup\) w]] \\\$fc \
close \\\$f \
} \
regsub {(?x) \
    (\\\npkgdatadir\\\s*=\\\s*\\\\\\$\\\(datadir\\\)/)(\\\\\\$\\\(PKG_DIR\\\)) \
} \\\$fc {\\\1tcl/\\\2} fc \
regsub {(?x) \
    (\\\npkglibdir\\\s*=\\\s*\\\\\\$\\\(libdir\\\)/)\\\\\\$\\\(PKG_DIR\\\) \
} \\\$fc {\\\1tcl} fc \
regsub {(?x) \
    (\\\[file\\\s+join\\\s+\\\\\\$\\\\\\$dir)\\\s+(\\\\\\$\\\(\\\S+_LIB_FILE\\\)) \
} \\\$fc {\\\1 .. \\\2} fc \
regsub {(?x) \
    	(?: \
     (\\\ninstall-lib-binaries:.* \
			\\\n\\\s+@mkdir\\\s+-p\\\s+\\\\\\$\\\(DESTDIR\\\)\\\\\\$\\\(pkglibdir\\\)){1,1} \
     (.+\\\n\\\s+@list='\\\\\\$\\\(\\\S+_SOURCES\\\)';.+){1,1}? \
     (\\\\\\$\\\(pkglibdir\\\)) \
     (.+){1,1}? \
     (\\\\\\$\\\(pkglibdir\\\)) \
     (.+done){1,1}? \
     ){1,1}? \
} \\\$fc {\\\1/\\\$(PACKAGE_NAME)\\\$(PACKAGE_VERSION) \\\$(DESTDIR)\\\$(pkgdatadir)\\\2\\\$(pkgdatadir)\\\4\\\$(pkgdatadir)\\\6} fc \
regsub -all {(?x) \
	(?: (\\\n.+pkgIndex\.tcl\\\s+\\\\\\$\\\(DESTDIR\\\)\\\\\\$\\\(pkglibdir\\\))){1,1}? \
} \\\$fc {\\\1/\\\$(PACKAGE_NAME)\\\$(PACKAGE_VERSION)/} fc \
puts -nonewline [set f [open Makefile.in w]] \\\$fc \
close \\\$f \
EOF\
fi \
if [ -n "$_verbose" -a -n "$_backup" ]; then \
gendiff . "$_backup" ||: \
fi \
%{-f:unset _force} \
%{-v:unset _verbose}%{!-v:set -x} \
%{-b:unset _backup} \
%{-C:cd "${_mydir}"; unset _mydir} \
set +a \
%nil

%tea_makeinstall(n:) \
%{-n:_name="%{-n*}"}%{!-n:%{?teaname:_name="%teaname"}%{!?teaname:%{error:teaname is not set and -n wasn't given}}} \
%makeinstall libdir=%buildroot%_tcllibdir pkglibdir=%buildroot%_tcldatadir/$_name %* \
%nil

%tea_makeindex(vdlf:L:C:) \
%{-v:_verbose="-verbose"} \
%{-d:_direct="-direct"} \
%{-l:_lazy="-lazy"} \
%{-f:_files='../%{-f*}'}%{!-f:_files='../*.so'} \
%{-L:_load="-load %{-L*}"} \
%{-C:_dir="%{-C*}"}%{!-C:%{?teaname:_dir="%buildroot%_tcllibdir/%teaname"}%{!?teaname:%{error:teaname is not set and -C wasn't given}}} \
if ! test -d $_dir; then %__mkdir_p $_dir; fi \
echo pkg_mkIndex $_verbose $_direct $_lazy $_load -- $_dir '*.tcl' $_files %* |%__tclsh \
%{-v:unset _verbose} \
%{-d:unset _direct} \
%{-l:unset _lazy} \
%{-f:unset _files} \
%{-L:unset _load} \
unset _dir \
%nil

#===============================================================================
#local variables:
#mode: rpm-spec
#fill-column: 80
#tab-width: 2
#end:
