PZ help :configure: error: cannot find output from flex; giving up

While installing amanda server,i got the following error

## checking lex output file root... configure: error: cannot find output from flex; giving up.

when i execute
# which lex
i got /usr/ccs/bin/lex
setting the pathg does not work too
After this i tried intalling flex in my /opt directory
using the following file flex-2.5.33.tar.gz from sunfreeware.com
but i get the same error as above (##) when i run the configure script
to install flex.
Dear people plz help me resolve this problem

Best Regards