From dcc75fdc5b9b12b62e85c88ee9836e6f40f7c901 Mon Sep 17 00:00:00 2001
From: Simon Marlow <simonmar@microsoft.com>
Date: Mon, 6 Feb 2006 09:54:00 +0000
Subject: [PATCH] combine GNUmakefile and Makefile

---
 Makefile     | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++
 doc/Makefile |  17 +++++
 2 files changed, 214 insertions(+)

diff --git a/Makefile b/Makefile
index 05ab972b11..d223678272 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,199 @@
 TOP=..
+
+ifeq "$(findstring boilerplate.mk, $(wildcard $(TOP)/mk/*))" ""
+# ----------------------------------------------------------------------------
+# Standalone Makefile:
+
+CABALVERSION=1.1.4
+KIND=rc
+#KIND=latest
+GHCFLAGS= --make -Wall -fno-warn-unused-matches -cpp
+# later: -Wall
+PREF=/usr/local
+USER_FLAG =
+GHCPKGFLAGS = 
+#HCBASE=/tmp/ghc/bin/
+HCBASE=/usr/bin/
+HC=$(HCBASE)ghc
+HC_PKG=$(HCBASE)/ghc-pkg
+# Comment out this line if your system doesn't have System.Posix.
+ISPOSIX=-DHAVE_UNIX_PACKAGE
+
+ifdef user
+USER_FLAG = --user
+GHCPKGFLAGS = -f ~/.ghc-packages
+GHCFLAGS += -package-conf ~/.ghc-packages
+endif
+
+# the cabal tarball...
+CABALBALL=cabal.tar.gz
+
+all: moduleTest
+
+# build the library itself
+
+setup::
+	mkdir -p dist/tmp
+	$(HC) $(GHCFLAGS) -i. -odir dist/tmp -hidir dist/tmp Setup.lhs -o setup
+
+Setup-nhc:
+	hmake -nhc98 -package base -prelude Setup
+
+config: setup
+	./setup configure --ghc --prefix=$(PREF)
+
+build: build-stamp
+build-stamp: config
+	./setup build
+
+install: build-stamp
+	./setup install $(USER_FLAG)
+	cd cabal-install && mkdir -p dist/tmp && $(HC) $(GHCFLAGS) -i. -odir dist/tmp -hidir dist/tmp Setup.lhs -o setup && ./setup configure --ghc --prefix=$(PREF) && ./setup build && ./setup install
+
+hugsbootstrap:
+	rm -rf dist/tmp dist/hugs
+	mkdir -p dist/tmp
+	mkdir dist/hugs
+	cp -r Distribution dist/tmp
+	hugs-package dist/tmp dist/hugs
+	cp Setup.lhs Cabal.cabal dist/hugs
+
+hugsinstall: hugsbootstrap
+	cd dist/hugs && ./Setup.lhs configure --hugs
+	cd dist/hugs && ./Setup.lhs build
+	cd dist/hugs && ./Setup.lhs install
+
+haddock: setup
+	./setup configure
+	./setup haddock
+
+clean-doc:
+	cd doc && make clean
+
+doc: haddock
+	docbook2html doc/Cabal.xml --output doc/users-guide
+
+clean: clean-cabal clean-hunit clean-test clean-doc
+
+clean-cabal:
+	-rm -f Distribution/*.o Distribution/*.hi
+	-rm -f Distribution/Simple/*.o Distribution/Simple/*.hi
+	-rm -f Compat/*.o Compat/*.hi
+	-rm -f darcs* out.build *~ semantic.cache* x*.html
+	-rm -f library-infrastructure--darcs.tar.gz
+	-rm -rf setup *.o *.hi moduleTest dist installed-pkg-config
+	-rm -f build-stamp
+	-rm -rf dist/hugs
+
+clean-hunit:
+	-rm -f hunit-stamp hunitInstall-stamp
+	cd tests/HUnit-1.0 && make clean
+
+clean-test:
+	cd tests/A && make clean
+	cd tests/wash2hs && make clean
+
+remove: remove-cabal remove-hunit
+remove-cabal:
+	-$(HC_PKG) $(GHCPKGFLAGS) -r Cabal
+	-rm -rf $(PREF)/lib/Cabal-0.1
+remove-hunit:
+	-$(HC_PKG) $(GHCPKGFLAGS) -r HUnit
+	-rm -rf $(PREF)/lib/HUnit-1.0
+
+# dependencies (included):
+
+hunit: hunit-stamp
+hunit-stamp:
+	cd tests/HUnit-1.0 && make && ./setup configure --prefix=$(PREF) && ./setup build
+	touch $@
+
+hunitInstall: hunitInstall-stamp
+hunitInstall-stamp: hunit-stamp
+	cd tests/HUnit-1.0 && ./setup install $(USER_FLAG)
+	touch $@
+
+# testing...
+
+moduleTest:
+	mkdir -p dist/debug
+	$(HC) $(GHCFLAGS) $(ISPOSIX) -DDEBUG -odir dist/debug -hidir dist/debug -idist/debug/:src:tests/HUnit-1.0/src tests/ModuleTest.hs -o moduleTest 
+
+tests: moduleTest clean
+	cd tests/A && make clean
+	cd tests/HUnit-1.0 && make clean
+	cd tests/A && make
+	cd tests/HUnit-1.0 && make
+
+check:
+	rm -f moduleTest
+	make moduleTest
+	./moduleTest
+
+# distribution...
+
+pushall:
+	darcs push ijones@darcs.haskell.org:/home/darcs/cabal
+	darcs push ijones@darcs.haskell.org:/home/darcs/packages/Cabal
+
+pullall:
+	darcs pull ijones@darcs.haskell.org:/home/darcs/cabal
+	darcs pull ijones@darcs.haskell.org:/home/darcs/packages/Cabal
+
+
+pushdist: pushall dist
+	scp $(TMPDISTLOC)/cabal.tar.gz ijones@www.haskell.org:~/cabal/cabal-code.tgz
+#	PUSH ELSEWHERE: scp changelog ijones@www.haskell.org:~/cabal/release/changelog
+#	PUSH ELSEWHERE: scp releaseNotes ijones@www.haskell.org:~/cabal/release/notes
+#	rm -f /tmp/cabal-code.tgz
+
+deb: dist
+	cd $(TMPDISTLOC) && ln -s $(CABALBALL) haskell-cabal_$(CABALVERSION).orig.tar.gz
+	cd $(TMPDISTLOC) && tar -zxvf $(CABALBALL)
+	mv $(TMPDISTLOC)/cabal $(TMPDISTLOC)/haskell-cabal-$(CABALVERSION)
+	cd $(TMPDISTLOC)/haskell-cabal-$(CABALVERSION) && debuild
+
+$(CABALBALL):
+	darcs record
+	rm -rf /tmp/cabal* /tmp/Cabal*
+	rm -rf $(TMPDISTLOC)
+	darcs dist
+	mv Cabal.tar.gz $(CABALBALL)
+
+TMPDISTLOC=/tmp/cabaldist
+
+# after this command, there will be cabal.tar.gz in $(TMPDISTLOC),
+# which will have built docs, haddock, and source code.
+
+dist: haddock $(CABALBALL)
+	rm -rf $(TMPDISTLOC)
+	mkdir $(TMPDISTLOC)
+	mv $(CABALBALL) $(TMPDISTLOC)
+	cd $(TMPDISTLOC) && tar -zxvf $(CABALBALL) && mv Cabal cabal
+	#mkdir $(TMPDISTLOC)/cabal/doc
+	make doc
+	cp -r dist/doc/html $(TMPDISTLOC)/cabal/doc/API
+	cp -r doc/users-guide $(TMPDISTLOC)/cabal/doc/users-guide
+	cd ~/usr/doc/haskell/haskell-report/packages && docbook2html -o /tmp/pkg-spec-html pkg-spec.sgml && docbook2pdf pkg-spec.sgml -o /tmp
+	cp -r /tmp/pkg-spec{-html,.pdf} $(TMPDISTLOC)/cabal/doc
+
+	cd $(TMPDISTLOC) && tar -zcvf $(CABALBALL) cabal
+#	rm -f /tmp/Cabal.tar.gz
+#	rm -rf /tmp/cabal
+
+release: dist
+	mkdir $(TMPDISTLOC)/release
+	cp $(TMPDISTLOC)/cabal/releaseNotes $(TMPDISTLOC)/release
+	cp $(TMPDISTLOC)/cabal/changelog $(TMPDISTLOC)/release
+	cp -r $(TMPDISTLOC)/cabal/doc $(TMPDISTLOC)/release
+	cp $(TMPDISTLOC)/cabal.tar.gz  $(TMPDISTLOC)/release/cabal-$(CABALVERSION).tar.gz
+	scp -r $(TMPDISTLOC)/release ijones@www.haskell.org:~/cabal/release/cabal-$(CABALVERSION)
+	ssh ijones@www.haskell.org 'cd ~/cabal/release && rm -f $(KIND) && ln -s cabal-$(CABALVERSION) $(KIND)'
+
+else # boilerplate.mk exists
+# ----------------------------------------------------------------------------
+# GHC build tree Makefile:
+
 include $(TOP)/mk/boilerplate.mk
 
 SUBDIRS = doc
@@ -22,3 +217,5 @@ SRC_HADDOCK_OPTS += -t "Haskell Core Libraries (Cabal package)"
 SRC_HC_OPTS   += -cpp
 
 include $(TOP)/mk/target.mk
+
+endif
diff --git a/doc/Makefile b/doc/Makefile
index 1c1be5e829..c1a5d037ba 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,7 +1,24 @@
 TOP = ../..
+
+ifeq "$(findstring boilerplate.mk, $(wildcard $(TOP)/mk/*))" ""
+# ----------------------------------------------------------------------------
+# Standalone Makefile:
+
+all: Cabal.xml
+	docbook2pdf Cabal.xml
+
+clean:
+	rm -fr *~ API users-guide Cabal.pdf Cabal.dvi semantic.cache
+
+else # boilerplate.mk exists
+# ----------------------------------------------------------------------------
+# GHC build tree Makefile:
+
 include $(TOP)/mk/boilerplate.mk
 
 XML_DOC = Cabal
 INSTALL_XML_DOC = $(XML_DOC)
 
 include $(TOP)/mk/target.mk
+
+endif
-- 
GitLab