From 9c96d86502c521cf78228f816e33ac456fb2ee59 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Wed, 30 Mar 2011 01:32:05 -0400
Subject: [PATCH] nasty hack to build when hS3 is not available

So, it would be nicer to just use Cabal and take advantage
of its conditional compilation support. But, Cabal seems to
lack good support for a package with an internal library that is used by
multiple executables. It wants to build everything twice or more.
That's too slow for me.

Anyway, fairly soon, I expect to upgrade hS3 to a requirment, and I
can just revert this.
---
 Makefile                    | 13 ++++++++++---
 Remote/{S3.hs => S3real.hs} |  0
 Remote/S3stub.hs            | 13 +++++++++++++
 debian/changelog            |  2 ++
 doc/install.mdwn            |  8 ++++----
 5 files changed, 29 insertions(+), 7 deletions(-)
 rename Remote/{S3.hs => S3real.hs} (100%)
 create mode 100644 Remote/S3stub.hs

diff --git a/Makefile b/Makefile
index 8e16645034..6a1531a3c8 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,14 @@ SysConfig.hs: configure.hs TestConfig.hs
 	hsc2hs $<
 	perl -i -pe 's/^{-# INCLUDE.*//' $@
 
-$(bins): SysConfig.hs Touch.hs StatFS.hs
+Remote/S3.o:
+	@ln -sf S3real.hs Remote/S3.hs
+	@if ! $(GHCMAKE) Remote/S3.hs; then \
+		ln -sf S3stub.hs Remote/S3.hs; \
+		echo "** building without S3 support"; \
+	fi
+
+$(bins): SysConfig.hs Touch.hs StatFS.hs Remote/S3.o
 	$(GHCMAKE) $@
 
 git-annex.1: doc/git-annex.mdwn
@@ -62,8 +69,8 @@ docs: $(mans)
 		--exclude='news/.*'
 
 clean:
-	rm -rf build $(bins) $(mans) test configure \
-		StatFS.hs Touch.hs SysConfig.hs *.tix .hpc
+	rm -rf build $(bins) $(mans) test configure  *.tix .hpc \
+		StatFS.hs Touch.hs SysConfig.hs Remote/S3.hs
 	rm -rf doc/.ikiwiki html
 	find . \( -name \*.o -or -name \*.hi \) -exec rm {} \;
 
diff --git a/Remote/S3.hs b/Remote/S3real.hs
similarity index 100%
rename from Remote/S3.hs
rename to Remote/S3real.hs
diff --git a/Remote/S3stub.hs b/Remote/S3stub.hs
new file mode 100644
index 0000000000..0d6ec47de3
--- /dev/null
+++ b/Remote/S3stub.hs
@@ -0,0 +1,13 @@
+-- stub for when hS3 is not available
+module Remote.S3 (remote) where
+
+import RemoteClass
+import Types
+
+remote :: RemoteType Annex
+remote = RemoteType {
+	typename = "S3",
+	enumerate = return [],
+	generate = error "S3 not enabled",
+	setup = error "S3 not enabled"
+}
diff --git a/debian/changelog b/debian/changelog
index faf2833a84..b03bc1d1b5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ git-annex (0.20110329) UNRELEASED; urgency=low
 
   * Amazon S3 is now supported as a special type of remote.
     Warning: Encrypting data before sending it to S3 is not yet supported.
+  * Note that Amazon S3 support is not built in by default on Debian yet,
+    as hS3 is not packaged.
   * fsck: Ensure that files and directories in .git/annex/objects
     have proper permissions.
 
diff --git a/doc/install.mdwn b/doc/install.mdwn
index 7b2c536c9d..70ab8e30b6 100644
--- a/doc/install.mdwn
+++ b/doc/install.mdwn
@@ -13,17 +13,17 @@ To build and use git-annex, you will need:
 * MissingH: <http://github.com/jgoerzen/missingh/wiki>
 * pcre-light: <http://hackage.haskell.org/package/pcre-light>
 * utf8-string: <http://hackage.haskell.org/package/utf8-string>
-* hS3: <http://hackage.haskell.org/package/hS3>
+* hS3 <http://hackage.haskell.org/package/hS3> (optional, but recommended)
 * `uuid`: <http://www.ossp.org/pkg/lib/uuid/>
   (or uuidgen from util-linux)
 * `xargs`: <http://savannah.gnu.org/projects/findutils/>
 * `rsync`: <http://rsync.samba.org/>
 * `curl` : <http://http://curl.haxx.se/> (optional, but recommended)
 * `sha1sum`: <ftp://ftp.gnu.org/gnu/coreutils/> (optional, but recommended)
-* Then just [[download]] git-annex and run: `make; make install`
+* [Ikiwiki](http://ikiwiki.info) is needed to build the documentation,
+  but that will be skipped if it is not installed.
 
-([Ikiwiki](http://ikiwiki.info) is needed to build the documentation,
-but that will be skipped if it is not installed.)
+Then just [[download]] git-annex and run: `make; make install`
 
 Additionally, to run the test suite (via `make test`), you will need:
 
-- 
GitLab