I'd be happier with quotes round $withval, to avoid complications if a value with spaces is ever given.
```
if test "x$withval" != x
then STATEDIR="$withval"
fi
```