Fix build issues on mingw

At least in the mingw I'm using, there's no `cc`, but rather `gcc`, so default to `gcc` to avoid having to type `CC=gcc` all the time. Also append to CFLAGS instead of overriding them just in case some extra ones are supplied from the command line.

Finally, the real build issue was `DEVICE_TYPE` not being defined early enough, so define it a bit earlier to get it to build.