summaryrefslogtreecommitdiffstats
path: root/winrc.m4
blob: 8148ebe01861d06fb7913798c0d4a216931c9a0b (plain)
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
# This was taken from Tk's configure.in and tcl.m4.
AC_DEFUN([TREECTRL_PROG_RC], [

#    AC_MSG_CHECKING([for windows resource compiler])
    RC_DEPARG='"$<"'
    if test "${GCC}" = "yes" ; then
	AC_CHECK_PROG(RC, windres, windres)
	if test "${RC}" = "" ; then
	    AC_MSG_ERROR([Required resource tool 'windres' not found on PATH.])
	fi
	RC_OUT=-o
	RC_TYPE=
	RC_INCLUDE=--include
	RC_DEFINE=--define
	RES=res.o

	# Check for a bug in gcc's windres that causes the
	# compile to fail when a Windows native path is
	# passed into windres. The mingw toolchain requires
	# Windows native paths while Cygwin should work
	# with both. Avoid the bug by passing a POSIX
	# path when using the Cygwin toolchain.

	if test "$ac_cv_cygwin" != "yes" -a "$CYGPATH" != "echo" ; then
	    conftest=/tmp/conftest.rc
	    echo "STRINGTABLE BEGIN" > $conftest
	    echo "101 \"name\"" >> $conftest
	    echo "END" >> $conftest

	    AC_MSG_CHECKING([for Windows native path bug in windres])
	    cyg_conftest=`$CYGPATH $conftest`
	    if AC_TRY_COMMAND($RC -o conftest.res.o $cyg_conftest) ; then
		AC_MSG_RESULT([no])
		RC_DEPARG='"$(shell $(CYGPATH) $<)"'
	    else
		AC_MSG_RESULT([yes])
	    fi
	    conftest=
	    cyg_conftest=
	fi

    else
	if test "$do64bit" != "no" ; then
	    RC="\"${MSSDK}/bin/rc.exe\""
	elif test "$doWince" != "no" ; then
	    RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
	else
	    RC="rc"
	fi
	RC_OUT=-fo
	RC_TYPE=-r
	RC_INCLUDE=-i
	RC_DEFINE=-d
	RES=res
    fi

    AC_SUBST(RC)
    AC_SUBST(RC_OUT)
    AC_SUBST(RC_TYPE)
    AC_SUBST(RC_INCLUDE)
    AC_SUBST(RC_DEFINE)
    AC_SUBST(RC_DEPARG)
    AC_SUBST(RES)
])

# This is basically TEA_ADD_SOURCES but sets the object file extension to
# $RES instead of $OBJ.
AC_DEFUN([TREECTRL_ADD_RC], [
    vars="$@"
    for i in $vars; do
	case $i in
	    [\$]*)
		# allow $-var names
		PKG_SOURCES="$PKG_SOURCES $i"
		PKG_OBJECTS="$PKG_OBJECTS $i"
		;;
	    *)
		# check for existence - allows for generic/win/unix VPATH
		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
		    ; then
		    AC_MSG_ERROR([could not find source file '$i'])
		fi
		PKG_SOURCES="$PKG_SOURCES $i"
		# this assumes it is in a VPATH dir
		i=`basename $i`
		# handle user calling this before or after TEA_SETUP_COMPILER
		if test x"${RES}" != x ; then
		    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.${RES}"
		else
		    j="`echo $i | sed -e 's/\.[[^.]]*$//'`.\${RES}"
		fi
		PKG_OBJECTS="$PKG_OBJECTS $j"
		;;
	esac
    done
    AC_SUBST(PKG_SOURCES)
    AC_SUBST(PKG_OBJECTS)
])