# Conjure makefile -- Owes everything to Don Stewart include config.mk # # All directories to look for sources # ALL_DIRS= . \ BEncode \ Conjure \ Control \ Control/Concurrent \ Control/Concurrent/STM \ Control/Concurrent/STM/TChan \ Data \ Data/List \ FS EXCLUDED_SRCS= quickCheck.hs \ BEncode/BEncodeQC.hs \ Conjure/InterestTableQC.hs \ Data/List/ShuffleQC.hs \ Conjure/WireProtocolQC.hs EXTRA_SRCS= # # Construct a list of buildable sources, based on $ALL_DIRS, and their objects # ALL_SRCS=$(filter-out $(EXCLUDED_SRCS) $(EXTRA_SRCS), \ $(wildcard $(patsubst ./%, %, \ $(patsubst %,%/*.hs, $(ALL_DIRS)) \ $(patsubst %,%/*.lhs, $(ALL_DIRS)) ))) $(EXTRA_SRCS) # # way management # # If $(way) is set then we define $(way_) and $(_way) from it in the # obvious fashion. ifeq "$(way)" "p" way_ := $(way)_ _way := _$(way) endif # building the profiled way ifeq "$(way)" "p" PROF_OPTS = -prof -auto-all LD_OPTS += $(PROF_OPTS) HC_OPTS += $(PROF_OPTS) HC_OPTS += -hisuf $(way_)hi -hcsuf $(way_)hc -osuf $(way_)o # and statically link all the modules. endif # building with optimization on ifeq "$(way)" "opt" HC_OPTS += -O endif # # Just a list of the client dependencies. Use ghci to trace the dependency # tree from Main.hs. # ALL_OBJS= $(addsuffix .$(way_)o,$(basename $(ALL_SRCS))) # # Now, get down to business # all: conjure # # Dependency generation # depend: $(ALL_SRCS) @echo -n "Rebuilding dependencies ... " @$(GHC) -cpp $(HC_OPTS) $(PKG_OPTS) $(LD_OPTS) -M -optdep-f \ -optdepdepend $(ALL_SRCS) || rm depend @echo "done." conjure: $(ALL_OBJS) @if test "x$(way)" = "xp" ; then \ for i in *.p_o ; do \ ln -f -s $$i $(echo $$i | sed 's/p_//') ; \ done ; \ fi $(GHC) $(HC_OPTS) $(PKG_OPTS) $(LD_OPTS) -v0 $(ALL_OBJS) -o $@ strip $@ # # Main rules, with support for 'way' management, from Yi. # %.$(way_)hi : %.$(way_)o @: %.$(way_)o: %.hs $(GHC) $(HC_OPTS) $(PKG_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi %.$(way_)o : %.lhs $(GHC) $(HC_OPTS) $(PKG_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi ifneq "$(GLASGOW_HASKELL)" "602" %.$(way_)o-boot : %.hs-boot $(GHC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi-boot %.$(way_)hi-boot : %.$(way_)o-boot @: endif %.raw-hs : %.hs @$(GHC) $(HC_OPTS) $(PKG_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@ %.raw-hs : %.lhs @$(GHC) $(HC_OPTS) $(PKG_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@ # # Building the haddocks (only if we have haddock) # .PHONY: docs ifneq "$(HADDOCK)" "" docs: .doc-stamp # break cyclic imports HS_PPS= $(addsuffix .raw-hs, \ $(filter-out $(basename $(NO_DOCS)), \ $(basename $(ALL_SRCS)))) DOCDIR=apidocs .doc-stamp: $(HS_PPS) @rm -rf $(DOCDIR) @-mkdir $(DOCDIR) $(HADDOCK) $(HADDOCK_OPTS) -o $(DOCDIR) $(HS_PPS) -k conjure @touch .doc-stamp @rm -f $(HS_PPS) CLEANS+= $(HS_PPS) $(DOCDIR) .doc-stamp else # else no haddock, html is empty. docs : endif # # clean rules # clean: rm -f *.o */*.o */*/*.o *.p_o */*.p_o */*/*.p_o rm -f *.hi */*.hi */*/*.hi *.p_hi */*.p_hi */*/*.p_hi rm -f *~ */*~ rm -f conjure conjure.prof depend depend.bak rm -rf $(CLEANS) distclean: clean rm -f config.mk config.h config.log config.status configure rm -rf autom4te.cache countsize: wc -l $(ALL_SRCS) -include depend # DO NOT DELETE: Beginning of Haskell dependencies ./Config.o : ./Config.hs ./Util.o : ./Util.hs ./Conjure/Version.o : ./Conjure/Version.hs ./Control/Concurrent/HoldTimer.o : ./Control/Concurrent/HoldTimer.hs ./MiniHTTP.o : ./MiniHTTP.hs ./Data/List/Shuffle.o : ./Data/List/Shuffle.hs ./Control/Concurrent/STM/TChan/Atomic.o : ./Control/Concurrent/STM/TChan/Atomic.hs ./Data/LRU.o : ./Data/LRU.hs ./FS/HandlePool.o : ./FS/HandlePool.hs ./FS/HandlePool.o : ./Data/LRU.hi ./BEncode/BEncode.o : ./BEncode/BEncode.hs ./BEncode/BEncodePP.o : ./BEncode/BEncodePP.hs ./BEncode/BEncodePP.o : ./BEncode/BEncode.hi ./BEncode/BType.o : ./BEncode/BType.hs ./BEncode/BType.o : ./BEncode/BEncode.hi ./Conjure/TorrentType.o : ./Conjure/TorrentType.hs ./Conjure/TorrentType.o : ./BEncode/BType.hi ./Conjure/TorrentType.o : ./BEncode/BEncode.hi ./SHA1.o : ./SHA1.hs ./Conjure/Torrent.o : ./Conjure/Torrent.hs ./Conjure/Torrent.o : ./SHA1.hi ./Conjure/Torrent.o : ./Conjure/TorrentType.hi ./Conjure/Torrent.o : ./BEncode/BType.hi ./Conjure/Torrent.o : ./BEncode/BEncodePP.hi ./Conjure/Torrent.o : ./BEncode/BEncode.hi ./FS/Piece.o : ./FS/Piece.hs ./FS/Piece.o : ./SHA1.hi ./FS/Piece.o : ./Conjure/Torrent.hi ./FS/Block.o : ./FS/Block.hs ./FS/Block.o : ./FS/Piece.hi ./Conjure/WireProtocol.o : ./Conjure/WireProtocol.hs ./Conjure/WireProtocol.o : ./FS/Piece.hi ./Conjure/WorkTable.o : ./Conjure/WorkTable.hs ./Conjure/WorkTable.o : ./Conjure/Torrent.hi ./Conjure/WorkTable.o : ./FS/Piece.hi ./Conjure/WorkTable.o : ./FS/Block.hi ./Utils.o : ./Utils.hs ./Conjure/OptionParser.o : ./Conjure/OptionParser.hs ./Conjure/Logger.o : ./Conjure/Logger.hs ./Conjure/Logger.o : ./Conjure/OptionParser.hi ./FS/Storage.o : ./FS/Storage.hs ./FS/Storage.o : ./Utils.hi ./FS/Storage.o : ./Conjure/Torrent.hi ./FS/Storage.o : ./Conjure/Logger.hi ./FS/Storage.o : ./FS/Piece.hi ./FS/Storage.o : ./FS/HandlePool.hi ./FS/BlockManager.o : ./FS/BlockManager.hs ./FS/BlockManager.o : ./FS/Block.hi ./FS/BlockManager.o : ./FS/Piece.hi ./FS/BlockManager.o : ./FS/Storage.hi ./FS/FSThread.o : ./FS/FSThread.hs ./FS/FSThread.o : ./FS/Storage.hi ./FS/FSThread.o : ./FS/Block.hi ./FS/FSThread.o : ./FS/Piece.hi ./FS/FSThread.o : ./Conjure/Torrent.hi ./FS/FSThread.o : ./FS/BlockManager.hi ./FS/FSThread.o : ./Control/Concurrent/STM/TChan/Atomic.hi ./Conjure/NaivePiecePicker.o : ./Conjure/NaivePiecePicker.hs ./Conjure/NaivePiecePicker.o : ./Data/List/Shuffle.hi ./Conjure/NaivePiecePicker.o : ./Conjure/Logger.hi ./Conjure/NaivePiecePicker.o : ./Control/Concurrent/STM/TChan/Atomic.hi ./Conjure/NaivePiecePicker.o : ./FS/Piece.hi ./Conjure/NaivePiecePicker.o : ./FS/Block.hi ./Conjure/NaivePiecePicker.o : ./Conjure/Torrent.hi ./Conjure/NaivePiecePicker.o : ./Conjure/WorkTable.hi ./TrackerClient.o : ./TrackerClient.hs ./TrackerClient.o : ./Conjure/Logger.hi ./TrackerClient.o : ./MiniHTTP.hi ./TrackerClient.o : ./Conjure/Torrent.hi ./TrackerClient.o : ./BEncode/BEncode.hi ./Conjure/PeerThread.o : ./Conjure/PeerThread.hs ./Conjure/PeerThread.o : ./Util.hi ./Conjure/PeerThread.o : ./Conjure/NaivePiecePicker.hi ./Conjure/PeerThread.o : ./Conjure/Torrent.hi ./Conjure/PeerThread.o : ./TrackerClient.hi ./Conjure/PeerThread.o : ./Control/Concurrent/STM/TChan/Atomic.hi ./Conjure/PeerThread.o : ./FS/Piece.hi ./Conjure/PeerThread.o : ./Conjure/Logger.hi ./Conjure/PeerThread.o : ./Conjure/WireProtocol.hi Conjure.o : Conjure.hs Conjure.o : ./Conjure/Logger.hi Conjure.o : ./FS/FSThread.hi Conjure.o : ./Conjure/NaivePiecePicker.hi Conjure.o : ./TrackerClient.hi Conjure.o : ./Conjure/WireProtocol.hi Conjure.o : ./Control/Concurrent/STM/TChan/Atomic.hi Conjure.o : ./Control/Concurrent/HoldTimer.hi Conjure.o : ./Data/List/Shuffle.hi Conjure.o : ./FS/Storage.hi Conjure.o : ./Conjure/Version.hi Conjure.o : ./Conjure/Torrent.hi Conjure.o : ./Conjure/PeerThread.hi Conjure.o : ./Conjure/OptionParser.hi Conjure.o : ./Config.hi # DO NOT DELETE: End of Haskell dependencies