Setting up Windows environment variables for DJGPP (& other GCC based compilers)

DJGPP & other compilers, such as EMX require that you set needed variables with a UNIX style slash convention. Also it is a pain to hard code the entire path into a command shell. I know this works on Windows 10, although I’m not sure about earlier versions.

The %cd% variable contains the current directory, so it makes it easy to do something like this:

Which is great, but of course all the paths are MS-DOS style. There now is the ability to replace strings!

@set _tmpdir=%cd%\tmp
@set tmpdir=%_tmpdir:\=/%
@set _tmpdir=

So in this example I set a temporary variable to the MS-DOS style path, and then using the pattern :(match)=(replace) it will then replace \ with /, giving me the UNIX style path. I then just set _tmpdir to nothing, unsetting the variable. So this way I don’t have to hard code any paths, and I can flip the slashes as needed.

Another fun thing is you can do logic blocks.. A simple one if a file doesn’t exist then compile it: