dialog: use $CFLAGS and add support for static compilation