From 01502ce6653263f18ea33f16ec8c655dd48608f7 Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@allmydata.com>
Date: Wed, 4 Apr 2007 11:18:38 -0700
Subject: [PATCH] port the makefile to Windows and update the README

---
 Makefile => GNUmakefile | 31 ++++++++++++++++++++++---------
 README                  | 16 ++++++++++++----
 2 files changed, 34 insertions(+), 13 deletions(-)
 rename Makefile => GNUmakefile (78%)

diff --git a/Makefile b/GNUmakefile
similarity index 78%
rename from Makefile
rename to GNUmakefile
index b1d97b19..b1e25267 100644
--- a/Makefile
+++ b/GNUmakefile
@@ -1,26 +1,40 @@
-
 default: build
 
 BASE=$(shell pwd)
 PYTHON=python
-
-INSTDIR=$(BASE)/instdir/lib/python$(shell $(PYTHON) -c 'import sys;print sys.version_info[0]').$(shell $(PYTHON) -c 'import sys;print sys.version_info[1]')/site-packages
+INSTDIR=$(BASE)/instdir
+
+UNAME=$(shell uname)
+ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
+EXTRA_SETUP_ARGS=build -c mingw32
+PATHDIR := $(shell cygpath -m $(INSTDIR))
+INSTDIR := $(shell cygpath -w $(INSTDIR))
+TRIAL=$(PYTHON) `cygpath -m \`type -p trial\` `
+ifneq ($(PYTHONPATH),)
+PYTHONPATH := $(shell cygpath -m $(PYTHONPATH))
+endif
+else
+EXTRA_SETUP_ARGS=
+PATHDIR := $(INSTDIR)
+TRIAL=trial
+endif
 
 show-instdir:
 	@echo $(INSTDIR)
 
+PATHSEP=$(shell python -c 'import os; print os.pathsep')
 ifneq ($(PYTHONPATH),)
-PP=PYTHONPATH=${PYTHONPATH}:$(INSTDIR)
+PP=PYTHONPATH=$(PYTHONPATH)$(PATHSEP)$(PATHDIR)
 else
-PP=PYTHONPATH=$(INSTDIR)
+PP=PYTHONPATH=$(PATHDIR)
 endif
 
 .PHONY: build
 build: build-pyfec build-Crypto
-	$(PYTHON) setup.py install --prefix=$(BASE)/instdir
+	$(PYTHON) setup.py $(EXTRA_SETUP_ARGS) install --install-lib="$(INSTDIR)" --install-scripts="$(INSTDIR)/scripts"
 
 build-pyfec:
-	cd src/pyfec && $(PYTHON) ./setup.py install --prefix=$(BASE)/instdir
+	cd src/pyfec && $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --install-lib="$(INSTDIR)" --install-scripts="$(INSTDIR)/scripts"
 
 test-pyfec:
 	$(PP) $(PYTHON) src/pyfec/fec/test/test_pyfec.py
@@ -30,7 +44,7 @@ clean-pyfec:
 
 
 build-Crypto:
-	cd src/Crypto && $(PYTHON) ./setup.py install --prefix=$(BASE)/instdir
+	cd src/Crypto && $(PYTHON) ./setup.py $(EXTRA_SETUP_ARGS) install --install-lib="$(INSTDIR)" --install-scripts="$(INSTDIR)/scripts"
 
 clean-Crypto:
 	cd src/Crypto && python ./setup.py clean
@@ -50,7 +64,6 @@ run-client3:
 	cd client-basedir3 && PYTHONPATH=.. twistd -noy ../client.tac
 
 
-TRIAL=trial
 TEST=allmydata
 REPORTER=
 
diff --git a/README b/README
index 2c5d4eac..48624ab3 100644
--- a/README
+++ b/README
@@ -31,10 +31,16 @@ DEPENDENCIES:
  PyOpenSSL (0.6 or later)
   http://pyopenssl.sourceforge.net
 
+ a C compiler (if building on Windows, cygwin gcc with mingw32 support)
+  http://gcc.gnu.org/
+  http://www.cygwin.com/
+ GNU make
+
 BUILDING:
 
- Just type 'make'. If the desired version of 'python' is not already on your
- $PATH, then type 'make PYTHON=/path/to/your/preferred/python'.
+ Just type 'make'. This works on Windows too, provided that you have the 
+ dependencies mentioned above.  If the desired version of 'python' is not 
+ already on your PATH, then type 'make PYTHON=/path/to/your/preferred/python'.
 
  'make test' runs the unit test suite.
 
@@ -43,8 +49,10 @@ BUILDING:
 
 RUNNING:
 
- The installed package creates an 'allmydata-tahoe' executable, usually in
- /usr/bin . This tool is used to create, start, and stop nodes.
+ If you installed one of the debian packages constructed by "make deb-*" then 
+ it creates an 'allmydata-tahoe' executable, usually in /usr/bin . If you 
+ didn't install a package you can find allmydata-tahoe in instdir/scripts.  
+ This tool is used to create, start, and stop nodes.  
 
  Somewhere in your mesh there must be a central 'queen' node. This is
  constructed by running 'allmydata-tahoe create-queen --basedir WHERE'. Once
-- 
2.45.2