In the (distant) past I used both what @hkvzjal and @Beliavsky suggested. Both work, but I don’t think they are needed anymore. /
works just fine in that other operating system that normally expects \
instead. I’m using MinGW-w64 though, and occasionally TDM_GCC - I’m not sure if that’s true for other compilers. So I don’t have to do anything special, the code is exactly the same as in Unix-like systems.
This, however, is not true for Makefiles. In some cases /
works as expected (for example, when you do the actual compiling with something like $(FC) $(SRC_DIR)/filename.f90 ...
. But in some other cases it won’t work. For example if you want to set directories in a Makefile, you have to use, e.g., EXE_DIR=..\bin
intstead of what you would do on Unix-like systems. This is why, while the code itself is the same, Makefiles are not.
What I do is to have a generic Makefile that detects the OS and sets stuff accordingly, then two Makefiles, one for GNU/Linux. BSD, etc and one for… that other operating system. The generic makefile will then include the actual Makefile in the end, depending on the OS detected. It works all the time.
For a generic Makefile, see this post.