1#
2# Include the TEA standard macro set
3#
4
5builtin(include,tclconfig/tcl.m4)
6
7#
8# Add here whatever m4 macros you want to define for your package
9#
10
11dnl Helper macros
12AC_DEFUN([TEAX_LAPPEND], [$1="[$]{$1} $2"])
13AC_DEFUN([TEAX_FOREACH], [for $1 in $2; do $3; done])
14AC_DEFUN([TEAX_IFEQ], [AS_IF([test "x$1" = "x$2"], [$3])])
15AC_DEFUN([TEAX_IFNEQ], [AS_IF([test "x$1" != "x$2"], [$3])])
16AC_DEFUN([TEAX_SWITCH], [case "$1" in TEAX_SWITCH_Cases(m4_shift($@)) esac])
17AC_DEFUN([TEAX_SWITCH_Cases], [m4_if([$#],0,,[$#],1,,[TEAX_SWITCH_OneCase($1,$2)TEAX_SWITCH_Cases(m4_shift(m4_shift($@)))])])
18AC_DEFUN([TEAX_SWITCH_OneCase],[ $1) $2;;])
19AC_DEFUN([CygPath],[`${CYGPATH} $1`])
20
21dnl Interesting macros
22AC_DEFUN([TEAX_SUBST_RESOURCE], [
23    AC_REQUIRE([TEA_CONFIG_CFLAGS])dnl
24    TEAX_IFEQ($TEA_PLATFORM, windows, [
25	AC_CHECK_PROGS(RC_, 'windres -o' 'rc -nologo -fo', none)
26	TEAX_SWITCH($RC_,
27	    windres*, [
28		rcdef_inc="--include "
29		rcdef_start="--define "
30		rcdef_q='\"'
31		AC_SUBST(RES_SUFFIX, [res.o])
32		TEAX_LAPPEND(PKG_OBJECTS, ${PACKAGE_NAME}.res.o)],
33	    rc*, [
34		rcdef_inc="-i "
35		rcdef_start="-d "
36		rcdef_q='"'
37		AC_SUBST(RES_SUFFIX, [res])
38		TEAX_LAPPEND(PKG_OBJECTS, ${PACKAGE_NAME}.res)],
39	    *, [
40		AC_MSG_WARN([could not find resource compiler])
41		RC_=: ])])
42    # This next line is because of the brokenness of TEA...
43    AC_SUBST(RC, $RC_)
44    TEAX_FOREACH(i, $1, [
45	TEAX_LAPPEND(RES_DEFS, ${rcdef_inc}\"CygPath($i)\")])
46    TEAX_FOREACH(i, $2, [
47	TEAX_LAPPEND(RES_DEFS, ${rcdef_start}$i='${rcdef_q}\$($i)${rcdef_q}')])
48    AC_SUBST(RES_DEFS)])
49AC_DEFUN([TEAX_ADD_PRIVATE_HEADERS], [
50    TEAX_FOREACH(i, $@, [
51	# check for existence, be strict because it should be present!
52	AS_IF([test ! -f "${srcdir}/$i"], [
53	    AC_MSG_ERROR([could not find header file '${srcdir}/$i'])])
54	TEAX_LAPPEND(PKG_PRIVATE_HEADERS, $i)])
55    AC_SUBST(PKG_PRIVATE_HEADERS)])
56
57AC_DEFUN([TEAX_SDX], [
58    AC_PATH_PROG(SDX, sdx, none)
59    TEAX_IFEQ($SDX, none, [
60	AC_PATH_PROG(SDX_KIT, sdx.kit, none)
61	TEAX_IFNEQ($SDX_KIT, none, [
62	    # We assume that sdx.kit is on the path, and that the default
63	    # tclsh is activetcl
64	    SDX="tclsh '${SDX_KIT}'"])])
65    TEAX_IFEQ($SDX, none, [
66	AC_MSG_WARN([cannot find sdx; building starkits will fail])
67	AC_MSG_NOTICE([building as a normal library still supported])])])
68dnl TODO: Adapt this for OSX Frameworks...
69dnl This next bit is a bit ugly, but it makes things for tclooConfig.sh...
70AC_DEFUN([TEAX_PATH_LINE], [
71    eval "$1=\"[]CygPath($2)\""
72    AC_SUBST($1)])
73AC_DEFUN([TEAX_INCLUDE_LINE], [
74    eval "$1=\"-I[]CygPath($2)\""
75    AC_SUBST($1)])
76AC_DEFUN([TEAX_LINK_LINE], [
77    AS_IF([test ${TCL_LIB_VERSIONS_OK} = nodots], [
78	eval "$1=\"-L[]CygPath($2) -l$3${TCL_TRIM_DOTS}\""
79    ], [
80	eval "$1=\"-L[]CygPath($2) -l$3${PACKAGE_VERSION}\""
81    ])
82    AC_SUBST($1)])
83
84dnl Local Variables:
85dnl mode: autoconf
86dnl End:
87