title: Makefile only working with relative paths on MSYS2 (WIndows)
body: <p>I have a set of programs that compile fine on Ubuntu and I'm working on a setup to compile on Windows as well. I'm using MSYS2.</p>
  
  <p>There is a main Makefile which looks like this:</p>
  
  <pre><code>#### Project main directory
  
  DIR_MAIN=$(shell pwd)
  
  #### Compile all
  
  all:
      @$(MAKE) -C src/Misc DIR_MAIN=$(DIR_MAIN)
      @$(MAKE) -C src/CF_states DIR_MAIN=$(DIR_MAIN)
  </code></pre>
  
  <p>etcetera. In <code>src/</code> there are folders each who contain a specific Makefile for that project. They have the following structure:</p>
  
  <pre><code>#### Directories and flags
  
  ifndef $(DIR_MAIN)
    DIR_MAIN=../..
  endif
  
  DIR_EXE=$(DIR_MAIN)/Programs
  DIR_SRC=$(DIR_MAIN)/src/Misc
  DIR_SFMT_SRC=$(DIR_MAIN)/src/sfmt
  DIR_BLD=$(DIR_MAIN)/build/Misc
  COMP=g++
  
  COMPILE_FLAGS= -std=c++11 -O3 -lstdc++ -msse2
  LINK_FLAGS= -O3 -fopenmp -lgsl -lgslcblas -lm -lhdf5_cpp -lhdf5
  
  
  #### Compile all
  
  all: setup $(DIR_BLD)/input.o $(DIR_BLD)/misc_sphere.o $(DIR_BLD)/misc.o 
  
  setup:
      @mkdir -p $(DIR_BLD)
      @mkdir -p $(DIR_EXE)
  
  #### Misc source
  
  $(DIR_BLD)/input.o: $(DIR_SRC)/input.cpp $(DIR_SRC)/input.h $(DIR_SRC)/misc_sphere.h
      ${COMP} -c input.cpp ${COMPILE_FLAGS} -o $@
  
  $(DIR_BLD)/misc_sphere.o: $(DIR_SRC)/misc_sphere.cpp $(DIR_SRC)/misc_sphere.h $(DIR_SRC)/misc.h
      ${COMP} -c misc_sphere.cpp ${COMPILE_FLAGS} -o $@
  
  $(DIR_BLD)/misc.o: $(DIR_SRC)/misc.cpp $(DIR_SRC)/misc.h
      ${COMP} -c misc.cpp ${COMPILE_FLAGS} -o $@
  </code></pre>
  
  <p>In this way the specific Makefiles can be run from their folder in <code>src/</code>, using relative paths, or from the main Makefile, using absolute paths.</p>
  
  <p>This works on Ubuntu but on MSYS2 only the relative paths work, i.e. running each of the specific Makefiles from their folders. When I run the main Makefile using </p>
  
  <pre><code>mingw32-make.exe
  </code></pre>
  
  <p>I get the error</p>
  
  <pre><code>$ mingw32-make.exe
  mingw32-make[1]: Entering directory 'C:/msys64/home/Jorgen/fqhe_mc_sphere/src/Misc'
  mingw32-make[1]: *** No rule to make target '/home/Jorgen/fqhe_mc_sphere/src/Misc/input.cpp', needed by '/home/Jorgen/fqhe_mc_sphere/build/Misc/input.o'.  Stop.
  mingw32-make[1]: Leaving directory 'C:/msys64/home/Jorgen/fqhe_mc_sphere/src/Misc'
  Makefile:8: recipe for target 'all' failed
  mingw32-make: *** [all] Error 2
  </code></pre>
  
  <p>even though the file <code>/home/Jorgen/fqhe_mc_sphere/src/Misc/input.cpp</code> is there, as I can check using <code>ls</code>. Any idea why?</p>
  
  <p>EDIT: </p>
  
  <p>Changing the first target to relative paths except for the result, i.e.</p>
  
  <pre><code>$(DIR_BLD)/input.o: input.cpp input.h misc_sphere.h
      ${COMP} -c input.cpp ${COMPILE_FLAGS} -o $@
  </code></pre>
  
  <p>I get a similar error for the output object file:</p>
  
  <pre><code>Fatal error: can't create /home/Jorgen/fqhe_mc_sphere/build/Misc/input.o: No such file or directory
  </code></pre>
  
  <p>Although the folder <code>/home/Jorgen/fqhe_mc_sphere/build/Misc/</code> does exist.</p>
  
  <p>I tried running MSYS2 as administrator which didn't help.</p>