1 # Copyright (C) 2001-2014 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
20 # Written by DJ Delorie <dj@redhat.com>
22 if {![istarget "i*86-*-*"] && ![istarget "x86_64-*-mingw*"] && ![istarget "x86_64-*-cygwin"] } {
23 verbose "Not a Cygwin/Mingw target" 1
27 if {![info exists WINDRES]} then {
28 verbose "WINDRES not defined" 1
32 if {[which $WINDRES] == 0} then {
33 verbose "$WINDRES not found" 1
37 set wr "$WINDRES --include-dir $srcdir/$subdir"
39 if [file exists "$srcdir/../../winsup/w32api/include"] {
40 set wr "$wr --include-dir $srcdir/../../winsup/w32api/include"
43 send_log "\nWarning: Assuming windres can find the win32 headers\n\n"
46 set res_list [lsort [glob -nocomplain $srcdir/$subdir/*.rc]]
48 proc oneline { file } {
50 if { [gets $file line] == -1 } {
53 if [regexp "^ \[0-9a-z\]\[0-9a-z\]* " $line] {
59 foreach res $res_list {
60 set sroot [file rootname $res]
61 set broot [file tail $sroot]
66 while { [gets $rc line] != -1 } {
67 if ![regexp "^(//|/\*|#)" $line] {
70 if [regexp "\[xp\]fail *(\[^ \]*)" $line junk sys] {
74 if [regexp "cpparg *(\[^ \]*)" $line junk cppopt] {
75 set cpp_opts "--preprocessor-arg \"$cppopt\""
80 verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
81 catch "exec $wr $cpp_opts -J rc -O res $res tmpdir/$broot.res" err
83 if ![string match "" $err] then {
86 if [string match "*windows.h: No such file*" $err] then {
87 unsupported "windres/$broot (parse)"
89 fail "windres/$broot (parse)"
93 pass "windres/$broot (parse)"
96 while { [gets $rc line] != -1 } {
97 if ![regexp "^(//|/\*|#)" $line] {
100 if [regexp "parse-only" $line] {
101 file delete "tmpdir/$broot.res"
105 if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] {
114 verbose "$OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" 1
115 catch "exec $OBJDUMP -b binary -s tmpdir/$broot.res > tmpdir/$broot.dump" err
117 if ![string match "" $err] then {
120 fail "windres/$broot (compare)"
124 set pat [open "$sroot.rsd"]
125 set out [open "tmpdir/$broot.dump"]
128 while { ![string match $patline ""] } {
129 set patline [oneline $pat]
130 set outline [oneline $out]
132 if ![string match $patline $outline] {
133 send_log "< $patline\n"
134 send_log "> $outline\n"
135 fail "windres/$broot (compare)"
141 pass "windres/$broot (compare)"
142 file delete "tmpdir/$broot.res"
143 file delete "tmpdir/$broot.dump"
149 if {[which $OBJDUMP] == 0} then {
150 unsupported "objdump -p"
154 verbose "$wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" 1
155 catch "exec $wr $cpp_opts -J rc $srcdir/$subdir/version.rc tmpdir/version.o" err
157 if ![string match "" $err] then {
160 if [string match "*windows.h: No such file*" $err] then {
161 unsupported "objdump -p (no header files found)"
163 fail "objdump -p (build)"
168 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -p tmpdir/version.o"]
170 # FIXME: We should extend this regexp to check for more information.
171 set want ".*The .rsrc Resource Directory section.*Type Table:.*Entry: ID:.*Name Table:.*Entry: ID:.*Language Table:.*Entry: ID:.*"
173 if ![regexp $want $got] then {
179 # file delete "tmpdir/version.o"