git-annex/Makefile

229 lines
7.5 KiB
Makefile
Raw Normal View History

CFLAGS=-Wall
2012-08-07 16:24:12 +00:00
GIT_ANNEX_TMP_BUILD_DIR?=tmp
BASEFLAGS=-Wall -outputdir $(GIT_ANNEX_TMP_BUILD_DIR) -IUtility
2012-09-07 18:54:00 +00:00
# If you get build failures due to missing haskell libraries,
# you can turn off some of these features.
#
# If you're using an old version of yesod, enable -DWITH_OLD_YESOD
# Or with an old version of the uri library, enable -DWITH_OLD_URI
FEATURES?=$(GIT_ANNEX_LOCAL_FEATURES) -DWITH_ASSISTANT -DWITH_S3 -DWITH_WEBDAV -DWITH_WEBAPP -DWITH_PAIRING -DWITH_XMPP -DWITH_DNS
2012-06-18 16:25:20 +00:00
bins=git-annex
mans=git-annex.1 git-annex-shell.1
sources=Build/SysConfig.hs Utility/Touch.hs Utility/Mounts.hs
2012-06-18 16:25:20 +00:00
all=$(bins) $(mans) docs
2012-06-18 16:25:20 +00:00
OS:=$(shell uname | sed 's/[-_].*//')
ifeq ($(OS),Linux)
OPTFLAGS?=-DWITH_INOTIFY -DWITH_DBUS
clibs=Utility/libdiskfree.o Utility/libmounts.o
THREADFLAGS=$(shell if test -e `ghc --print-libdir`/libHSrts_thr.a; then printf -- -threaded; fi)
2012-06-18 16:25:20 +00:00
else
ifeq ($(OS),SunOS)
# Solaris is not supported by the assistant or watch command.
FEATURES:=$(shell echo $(FEATURES) | sed -e 's/-DWITH_ASSISTANT//' -e 's/-DWITH_WEBAPP//')
else
# BSD system
THREADFLAGS=-threaded
2012-10-15 00:32:27 +00:00
OPTFLAGS?=-DWITH_KQUEUE
clibs=Utility/libdiskfree.o Utility/libmounts.o Utility/libkqueue.o
ifeq ($(OS),Darwin)
# Ensure OSX compiler builds for 32 bit when using 32 bit ghc
GHCARCH:=$(shell ghc -e 'print System.Info.arch')
ifeq ($(GHCARCH),i386)
CFLAGS=-Wall -m32
endif
endif
endif
endif
ALLFLAGS = $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) $(THREADFLAGS)
2010-12-11 21:29:50 +00:00
PREFIX=/usr
GHCFLAGS=-O2 $(ALLFLAGS)
2011-11-10 01:36:11 +00:00
2011-04-05 18:00:51 +00:00
ifdef PROFILE
GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(ALLFLAGS)
2011-04-05 18:00:51 +00:00
endif
2011-11-10 01:36:11 +00:00
GHCMAKE=ghc $(GHCFLAGS) --make
2010-10-19 18:39:40 +00:00
2011-11-10 07:10:17 +00:00
# Am I typing :make in vim? Do a fast build.
2011-11-10 01:36:11 +00:00
ifdef VIM
2011-11-10 07:10:17 +00:00
all=fast
2011-11-10 01:36:11 +00:00
endif
build: $(all)
touch build-stamp
sources: $(sources)
2011-11-10 07:10:17 +00:00
# Disables optimisation. Not for production use.
fast: GHCFLAGS=$(ALLFLAGS)
2011-11-10 07:10:17 +00:00
fast: $(bins)
Build/SysConfig.hs: configure.hs Build/TestConfig.hs Build/Configure.hs
2010-12-11 21:29:50 +00:00
$(GHCMAKE) configure
./configure
2011-03-22 19:39:36 +00:00
%.hs: %.hsc
hsc2hs $<
git-annex: $(sources) $(clibs)
2012-08-07 17:12:16 +00:00
install -d $(GIT_ANNEX_TMP_BUILD_DIR)
$(GHCMAKE) $@ -o $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex $(clibs)
ln -sf $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex git-annex
2011-01-25 22:54:27 +00:00
git-annex.1: doc/git-annex.mdwn
2012-09-01 19:22:13 +00:00
./Build/mdwn2man git-annex 1 doc/git-annex.mdwn > git-annex.1
2011-01-25 22:54:27 +00:00
git-annex-shell.1: doc/git-annex-shell.mdwn
2012-09-01 19:22:13 +00:00
./Build/mdwn2man git-annex-shell 1 doc/git-annex-shell.mdwn > git-annex-shell.1
git-union-merge.1: doc/git-union-merge.mdwn
2012-09-01 19:22:13 +00:00
./Build/mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1
2010-10-10 04:18:16 +00:00
install-mans: $(mans)
install -d $(DESTDIR)$(PREFIX)/share/man/man1
install -m 0644 $(mans) $(DESTDIR)$(PREFIX)/share/man/man1
install-docs: docs install-mans
install -d $(DESTDIR)$(PREFIX)/share/doc/git-annex
if [ -d html ]; then \
rsync -a --delete html/ $(DESTDIR)$(PREFIX)/share/doc/git-annex/html/; \
fi
2010-10-16 20:41:24 +00:00
install: build-stamp install-docs
install -d $(DESTDIR)$(PREFIX)/bin
install $(bins) $(DESTDIR)$(PREFIX)/bin
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell
runghc Build/InstallDesktopFile.hs $(PREFIX)/bin/git-annex || true
test: $(sources) $(clibs)
2012-04-05 20:37:44 +00:00
@if ! $(GHCMAKE) -O0 test $(clibs); then \
echo "** failed to build the test suite" >&2; \
exit 1; \
elif ! ./test; then \
echo "** test suite failed!" >&2; \
exit 1; \
fi
2010-12-11 21:37:24 +00:00
2011-12-20 20:02:59 +00:00
testcoverage:
rm -f test.tix test
ghc $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test
./test
2011-01-07 01:39:26 +00:00
@echo ""
2011-01-05 01:07:58 +00:00
@hpc report test --exclude=Main --exclude=QC
@hpc markup test --exclude=Main --exclude=QC --destdir=.hpc >/dev/null
2011-12-20 20:07:34 +00:00
@echo "(See .hpc/ for test coverage details.)"
2010-10-19 18:39:40 +00:00
# If ikiwiki is available, build static html docs suitable for being
# shipped in the software package.
2010-10-19 18:37:19 +00:00
ifeq ($(shell which ikiwiki),)
IKIWIKI=@echo "** ikiwiki not found, skipping building docs" >&2; true
2010-10-19 18:37:19 +00:00
else
IKIWIKI=ikiwiki
endif
docs: $(mans)
2010-10-19 18:39:40 +00:00
$(IKIWIKI) doc html -v --wikiname git-annex --plugin=goodstuff \
2010-10-19 23:28:29 +00:00
--no-usedirs --disable-plugin=openid --plugin=sidebar \
2010-10-22 19:12:48 +00:00
--underlaydir=/dev/null --disable-plugin=shortcut \
--disable-plugin=smiley \
2011-03-28 16:09:47 +00:00
--plugin=comments --set comments_pagespec="*" \
--exclude='news/.*'
2010-10-10 04:18:16 +00:00
2010-10-19 19:59:40 +00:00
clean:
rm -rf $(GIT_ANNEX_TMP_BUILD_DIR) $(bins) $(mans) test configure *.tix .hpc $(sources) \
doc/.ikiwiki html dist $(clibs) build-stamp
2010-10-19 19:59:40 +00:00
Refactor generation of git-annex.cabal and incorporate man pages. The existing `sed | find | perl` hack in the Makefile was not including the man pages in the generated git-annex.cabal. I couldn't figure out why it didn't work; running the `find | perl` part of the command *did* list the man pages ... So, I set up a new hack. It produces a cleaner .cabal file and includes the man pages in the sdist. I changed git-annex.cabal and its generation as follows: - git-annex.cabal is now generated by a here document in git-annex.cabal.template.sh. The here document has inline file list insertion, whereas before the file lists were inserted with sed. - The 'Extra-Source-Files:' field now only includes the non-source files: the man pages, plain text documentation, and license. - The source dependencies are now listed in 'Other-Modules' sections in the 'Executable' and 'Test-Suite' sections. The list of dependencies is generated by `gen-other-modules.sh`. - The ./debian and ./doc are no longer included in the sdist package. These were not installed anywhere by `cabal install`. A user that wants them could clone the git repo. Running the tests with cabal is not yet working, i.e. cabal configure --enable-tests && cabal build && cabal test and cabal install --enable-tests fail to find Utility.Touch. However, I did not break this: it doesn't work for the git-annex package on Hackage either. Next step is to figure out how to deal with HSC in cabal ... or not bother, because `make test` works. I'm worried this is a cabal bug. To test building from sdist, I've been running cd ../.. ; cabal sdist ; cd dist ; tar xf git-annex-3.20120605.tar.gz && cd git-annex-3.20120605 && rm -fr /tmp/git-annex && cabal install --prefix=/tmp/git-annex && tree -A /tmp/git-annex in the dist directory. Using `cabal-dev install` is a better test, but is very slow.
2012-06-11 02:24:15 +00:00
sdist: clean $(mans)
2012-09-01 19:22:13 +00:00
./Build/make-sdist.sh
2011-07-02 18:53:55 +00:00
2012-01-13 19:08:28 +00:00
# Upload to hackage.
hackage: sdist
@cabal upload dist/*.tar.gz
THIRDPARTY_BINS=git curl lsof xargs rsync uuid wget gpg \
sha1sum sha224sum sha256sum sha384sum sha512sum cp
2012-09-24 23:40:21 +00:00
2012-09-28 22:21:39 +00:00
LINUXSTANDALONE_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/git-annex.linux
linuxstandalone:
2012-10-16 01:49:46 +00:00
GIT_ANNEX_LOCAL_FEATURES="$(GIT_ANNEX_LOCAL_FEATURES) -DWITH_OLD_SSH" $(MAKE) git-annex
2012-09-28 22:21:39 +00:00
rm -rf "$(LINUXSTANDALONE_DEST)"
cp -R standalone/linux "$(LINUXSTANDALONE_DEST)"
install -d "$(LINUXSTANDALONE_DEST)/bin"
cp git-annex "$(LINUXSTANDALONE_DEST)/bin/"
strip "$(LINUXSTANDALONE_DEST)/bin/git-annex"
ln -sf git-annex "$(LINUXSTANDALONE_DEST)/bin/git-annex-shell"
zcat standalone/licences.gz > $(LINUXSTANDALONE_DEST)/LICENSE
2012-09-28 22:21:39 +00:00
for bin in $(THIRDPARTY_BINS); do \
cp "$$(which "$$bin")" "$(LINUXSTANDALONE_DEST)/bin/"; \
2012-09-28 22:21:39 +00:00
done
install -d "$(LINUXSTANDALONE_DEST)/git-core"
(cd "$(shell git --exec-path)" && tar c .) | (cd "$(LINUXSTANDALONE_DEST)"/git-core && tar x)
touch "$(LINUXSTANDALONE_DEST)/libdirs.tmp"
for lib in $$(ldd "$(LINUXSTANDALONE_DEST)"/bin/* $$(find "$(LINUXSTANDALONE_DEST)"/git-core/ -type f) | grep -v -f standalone/linux/glibc-libs | grep -v "not a dynamic executable" | egrep '^ ' | sed 's/^\t//' | sed 's/.*=> //' | cut -d ' ' -f 1 | sort | uniq); do \
dir=$$(dirname "$$lib"); \
install -d "$(LINUXSTANDALONE_DEST)/$$dir"; \
echo "$$dir" >> "$(LINUXSTANDALONE_DEST)/libdirs.tmp"; \
cp "$$lib" "$(LINUXSTANDALONE_DEST)/$$dir"; \
if [ -L "$lib" ]; then \
link=$$(readlink -f "$$lib"); \
cp "$$link" "$(LINUXSTANDALONE_DEST)/$$(dirname "$$link")"; \
fi; \
done
sort "$(LINUXSTANDALONE_DEST)/libdirs.tmp" | uniq > "$(LINUXSTANDALONE_DEST)/libdirs"
rm -f "$(LINUXSTANDALONE_DEST)/libdirs.tmp"
2012-09-28 22:33:46 +00:00
cd $(GIT_ANNEX_TMP_BUILD_DIR) && tar czf git-annex-standalone-$(shell dpkg --print-architecture).tar.gz git-annex.linux
2012-09-28 22:29:36 +00:00
2012-09-28 22:21:39 +00:00
OSXAPP_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/git-annex.app
OSXAPP_BASE=$(OSXAPP_DEST)/Contents/MacOS
osxapp:
2012-10-16 01:49:46 +00:00
GIT_ANNEX_LOCAL_FEATURES="$(GIT_ANNEX_LOCAL_FEATURES) -DWITH_OLD_SSH" $(MAKE) git-annex
2012-09-25 14:12:25 +00:00
rm -rf "$(OSXAPP_DEST)"
install -d $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg
2012-10-01 17:38:19 +00:00
cp -R standalone/osx/git-annex.app "$(OSXAPP_DEST)"
2012-09-25 14:12:25 +00:00
2012-09-24 23:40:21 +00:00
install -d "$(OSXAPP_BASE)/bin"
cp git-annex "$(OSXAPP_BASE)/bin/"
strip "$(OSXAPP_BASE)/bin/git-annex"
ln -sf git-annex "$(OSXAPP_BASE)/bin/git-annex-shell"
gzcat standalone/licences.gz > $(OSXAPP_BASE)/LICENSE
cp $(OSXAPP_BASE)/LICENSE $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/LICENSE.txt
for bin in $(THIRDPARTY_BINS); do \
cp "$$(which "$$bin")" "$(OSXAPP_BASE)/bin/"; \
2012-09-24 23:40:21 +00:00
done
install -d "$(OSXAPP_BASE)/git-core"
(cd "$(shell git --exec-path)" && tar c .) | (cd "$(OSXAPP_BASE)"/git-core && tar x)
touch "$(OSXAPP_BASE)/libdirs.tmp"
2012-09-24 23:40:21 +00:00
for lib in $$(otool -L "$(OSXAPP_BASE)"/bin/* "$(OSXAPP_BASE)"/git-core/* | egrep '^ ' | cut -d ' ' -f 1 | sed 's/^ //' | sort | uniq); do \
dir=$$(dirname "$$lib"); \
install -d "$(OSXAPP_BASE)/$$dir"; \
echo "$$dir" >> "$(OSXAPP_BASE)/libdirs.tmp"; \
cp "$$lib" "$(OSXAPP_BASE)/$$dir"; \
2012-09-24 23:40:21 +00:00
done
sort "$(OSXAPP_BASE)/libdirs.tmp" | uniq > "$(OSXAPP_BASE)/libdirs"
rm -f "$(OSXAPP_BASE)/libdirs.tmp"
rm -f tmp/git-annex.dmg
hdiutil create -size 640m -format UDRW -srcfolder $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg \
-volname git-annex -o tmp/git-annex.dmg
rm -f tmp/git-annex.dmg.bz2
bzip2 tmp/git-annex.dmg
# used by ./ghci
getflags:
2012-11-06 19:57:01 +00:00
@echo $(ALLFLAGS) $(clibs)
.PHONY: $(bins) test install