Allow docs/Makefile to be portable

Currently docs/Makefile downloads Conda but only the Linux version.
This commit allows it to detect the operating system and download the
corresponding Conda installer.

Additionally, `make` uses the sh shell which does not support the `source`
command. This causes the commands that use `source` to fail on some
systems that do not have the sh shell linked to something else (say dash).

Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
diff --git a/docs/Makefile b/docs/Makefile
index 64f9ba2..378014c 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -5,11 +5,26 @@
 
 # You can set these variables from the command line.
 SPHINXOPTS      =
-SPHINXBUILD     = [ -e env/bin/activate ] && source env/bin/activate; sphinx-build
-SPHINXAUTOBUILD = [ -e env/bin/activate ] && source env/bin/activate; sphinx-autobuild
+SPHINXBUILD     = [ -e env/bin/activate ] && . env/bin/activate; sphinx-build
+SPHINXAUTOBUILD = [ -e env/bin/activate ] && . env/bin/activate; sphinx-autobuild
 SPHINXPROJ      = SymbiFlowV2X
 SOURCEDIR       = .
 BUILDDIR        = _build
+OSFLAG 				:=
+UNAME_S := $(shell uname -s)
+ifneq (, $(findstring Linux, $(UNAME_S)))
+	OSFLAG := Linux
+endif
+ifeq ($(UNAME_S), Darwin)
+	OSFLAG := MacOSX
+endif
+ifneq (, $(findstring Cygwin, $(UNAME_S)))
+	OSFLAG := Linux
+endif
+ifneq (, $(findstring MINGW, $(UNAME_S)))
+	OSFLAG := Linux
+endif
+
 
 # Put it first so that "make" without argument is like "make help".
 help:
@@ -21,18 +36,18 @@
 .PHONY: help livehtml Makefile
 
 
-env/Miniconda3-latest-Linux-x86_64.sh:
+env/Miniconda3:
 	mkdir env
-	wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O env/Miniconda3-latest-Linux-x86_64.sh
-	chmod a+x env/Miniconda3-latest-Linux-x86_64.sh
+	wget https://repo.anaconda.com/miniconda/Miniconda3-latest-$(OSFLAG)-x86_64.sh -O env/Miniconda3-latest-$(OSFLAG)-x86_64.sh
+	chmod a+x env/Miniconda3-latest-$(OSFLAG)-x86_64.sh
 
 env:
 	rm -rf env
-	make env/Miniconda3-latest-Linux-x86_64.sh
-	./env/Miniconda3-latest-Linux-x86_64.sh -p $(PWD)/env -b -f
-	source env/bin/activate; conda config --system --add envs_dirs $(PWD)/env/envs
-	source env/bin/activate; conda config --system --add pkgs_dirs $(PWD)/env/pkgs
-	source env/bin/activate; conda env update --name base --file ./environment.yml
+	make env/Miniconda3
+	./env/Miniconda3-latest-$(OSFLAG)-x86_64.sh -p $(PWD)/env -b -f
+	. env/bin/activate; conda config --system --add envs_dirs $(PWD)/env/envs
+	. env/bin/activate; conda config --system --add pkgs_dirs $(PWD)/env/pkgs
+	. env/bin/activate; conda env update --name base --file ./environment.yml
 
 .PHONY: env