I have a project comprised of tasks. Each task has three subdirectories: input, code, and output. In the code directory resides a Makefile with the recipes needed to make the output from the code and inputs. Each Makefile uses Unix commands.
Many tasks are connected: the output from one is the input to the other. These connections are done with Unix-style symlinks (ln -s
in the Makefile).
I'd like to be able to ship this project to any OS (Windows, Mac, Linux) and have it run. The symlinks work well on Mac and Linux, but not Windows. I know that Windows 10 has its own symlink syntax (mklink
).
I can think of a few potential solutions, but I'm not sure if they're feasible let alone how to implement them. One would be to have the Makefile detect the OS and construct the symlink accordingly. Another would be to have Windows users replicate the project (e.g., git clone) into a Unix-like file system (WSL2 ideally, or a VM) and run the Makefiles there. The second is worse than the first, in my experience, because editing the files then becomes a pain relative to using one's native file system. I run Windows on my laptop, so ease of editing is high on my list.
To summarize, I think there are three ordered questions here:
- Can a makefile detect the OS and make the correct symlinks / can it make OS-agnostic symlinks?
- If not, is there a way to do this all in the Linux file system of WSL2? One would need to be able to edit files with Emacs or Atom and run Windows executables (otherwise I'd have to go put Stata, R, Matlab and whatever else in my WSL2 Ubuntu distro). I'm not a huge fan of VSCode, so I'd prefer to stay away from it, but I know Windows has made strides in integrating that with WSL2.
- If none of this works, would something like CMake help, or should I just switch to Linux and hang Windows users out to dry?