Subject: configure and cpp problem (Was: bug: missing include files in B20.1)
From: Teun Burgers <[email-masked]>
To: [email-masked]
Date: Mon, 22 Feb 1999 16:52:09 +0100

There is a problem that the configure script for
perl 5002.02 can not find stdarg.h for cygnus B20.1.
This turns out to be caused by the location of stdarg.h in
combination with bugs in the configure script and non-unixy
output of the C preprocessor gcc -E. This mesage contains
a fix for the configure script that solves the problem.

stdarg.h (and varargs.h, float.h, stddef.h) are
in the H-i586-cygwin32/lib/gcc-lib/egcs-2.91.57/include directory,
but not in the H-i586-cygwin32/i586-cygwin32/include directory from
the B20 full.exe distribution where most include files reside.

The configure script (relevant part in fhdr.old) creates
a script findhdr that looks for the header file. findhr first
simply tests for existance (test -f) of the .h file in
H-i586-cygwin32/i586-cygwin32/include and if not found there
it uses the C preprocessor gcc -E -.

Because stdarg.h is not found in the first step it must be found
in the second step. This second step goes wrong for two reasons:

1) the shell scripts tests whether the expanded include file
   name by gcc -E matches */stdarg.h. This test fails because
   gcc returns a DOS filename with \ e.g.
   d:\\cygnus\\cygwin-b20  etc, so it does not match.

   There are two solutions:
   - change the matching condition in findhdr from
     */stdarg.h  to  *[/\\]stdarg.h
   - make gcc -E - return a unixy file name

2) Even with this test fixed it still goes wrong.
   This seems to be a bug in the configure script.
   The configure scripts sets variable name in a while
   loop that is the end of a pipe. Because the while is
   in a pipe, it runs in a subshell and variable settings
   are local to that subshell.

The fhdr.new file fixes both problems.

Thanks to Mumit for his suggestions

references:

http://sourceware.cygnus.com/ml/cygwin/1999-02/msg00616.html
http://sourceware.cygnus.com/ml/cygwin/1999-02/msg00512.html
http://www.cygnus.com/ml/gnu-win32/1998-Nov/0399.html

-- 
Drs A.R. Burgers        Netherlands Energy Research Foundation ECN
Phone: +31-224-564703   Renewable Energy, PV Cells & Modules
Fax  : +31-224-563214   P.O. Box 1
email: [email-masked]   1755 ZG Petten, The Netherlands

#!/bin/bash

startsh='#!/bin/sh.exe'
usrinc='//d/cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/include'
awk='//d/cygnus/cygwin-b20/H-i586-cygwin32/bin/awk.exe'
cat='//d/cygnus/cygwin-b20/H-i586-cygwin32/bin/cat.exe'
rm='//d/cygnus/cygwin-b20/H-i586-cygwin32/bin/rm.exe'
tr='//d/cygnus/cygwin-b20/H-i586-cygwin32/bin/tr.exe'
grep='//d/cygnus/cygwin-b20/H-i586-cygwin32/bin/grep.exe'

fieldn='3'
cppstdin='gcc2 -E'
cppminus='-'
cppflags=''

$cat >findhdr <<EOF
$startsh
wanted=\$1
if test -f $usrinc/\$wanted; then
	echo "$usrinc/\$wanted"
	exit 0
fi
awkprg='{ print \$$fieldn }'
echo "#include <\$wanted>" > foo\$\$.c
$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
$grep "^[ 	]*#.*\$wanted" | \
while read cline; do
	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
	case "\$name" in
	*[/\\\\]\$wanted) echo "\$name";exit 1;;
	*) exit 2;;
	esac;
done;
#
#status=0: grep returned 0 lines, case statement not executed
#status=1: headerfile found
#status=2: while loop executed, no headerfile found
#
status=\$?
$rm -f foo\$\$.c;
if test \$status -eq 1; then
	exit 0;
fi
exit 1;
EOF
chmod +x findhdr

#!/bin/sh
$cat >findhdr <<EOF
$startsh
wanted=\$1
name=''
if test -f $usrinc/\$wanted; then
	echo "$usrinc/\$wanted"
	exit 0
fi
awkprg='{ print \$$fieldn }'
echo "#include <\$wanted>" > foo\$\$.c
$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
$grep "^[ 	]*#.*\$wanted" | \
while read cline; do
	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
	case "\$name" in
	*/\$wanted) echo "\$name"; exit 0;;
	*) name='';;
	esac;
done;
$rm -f foo\$\$.c;
case "\$name" in
'') exit 1;;
esac
EOF
chmod +x findhdr

--
Want to unsubscribe from this list?
Send a message to [email-masked]