Quite nice work so far! Unfortunately there is kinda big show stopper if you would want to compile with debug information (-g). Actually you really need to add /MDd to the DEBUGFLAGS in the msvc90compp.bat and in the msvc90opts.bat. In case these flags are missing your Matlab may completely crash. Once the files are changed, you need to re-run 'mex -setup'.