1
# Making the haddock documentation
4
## Includes ###############################################################
8
include $(TOP)/mk/config.mk
9
include $(TOP)/mk/paths.mk
11
## Variables ##############################################################
13
# Haddock interface for the base package
14
haddockURL = http://www.haskell.org/ghc/docs/$(GHC_VERSION)/html/libraries
15
haddockArg = $(haddockURL)/$(1),$(1).haddock
16
haddockFile = $(haddockURL)/$(1)/$(1).haddock
19
lexer = Syntax/Parser/Lexer
20
parser = Syntax/Parser/Parser
21
gen_hs_files = $(FULL_OUT_DIR)/$(lexer).hs $(FULL_OUT_DIR)/$(parser).hs
22
src_hs_files = $(shell $(FIND) $(FULL_SRC_DIR) -name '*.hs' -o -name '*.lhs')
23
dst_hs_files = $(patsubst $(FULL_SRC_DIR)/%,src/%,$(src_hs_files)) \
24
$(patsubst $(FULL_OUT_DIR)/%,src/%,$(gen_hs_files))
26
# The prologue. Contains an introduction to the documentation
29
## Phony targets ##########################################################
31
.PHONY : default clean veryclean debug check_version
33
## Default target #########################################################
35
ifeq ($(HAVE_HADDOCK),Yes)
42
@echo You need haddock to build this documentation.
47
## Base file ##############################################################
49
ifeq ($(HAVE_WGET),Yes)
52
wget $(call haddockFile,$*)
57
@echo $(call haddockFile,$*) have to be downloaded manually since wget could not be found.
62
## Preprocessing Haskell files ############################################
64
# Haddock cannot handle circular module dependencies or C preprocessor
65
# directives in Haskell code, so we have to let ghc preprocess the source
66
# files before giving them to haddock. To handle circular module
67
# dependencies surround the boot file imports with an
69
# It might also be necessary to define a dummy version of types imported
70
# from boot files as follows:
77
# -- | Trick to make haddock accept circular module dependencies. See 'Foo.X'.
81
# There is no need to do this for functions since they cannot appear in
82
# types, and thus not in haddock documentation.
84
src/% : $(FULL_SRC_DIR)/% src
85
@echo Preprocessing $* for haddock
86
@$(MKDIR) -p $(dir $@)
87
@$(GHC) -E -optP-P -optP-I$(FULL_SRC_DIR) -D__HADDOCK__ -o $@ $<
89
src/% : $(FULL_OUT_DIR)/% src
90
@echo Preprocessing $* for haddock
91
@$(MKDIR) -p $(dir $@)
92
@$(GHC) -E -optP-P -optP-I$(FULL_SRC_DIR) -D__HADDOCK__ -o $@ $<
97
$(FULL_OUT_DIR)/$(parser).hs : $(FULL_SRC_DIR)/$(parser).y
98
@$(MAKE) -C $(FULL_SRC_DIR) $@
100
$(FULL_OUT_DIR)/$(lexer).hs : $(FULL_SRC_DIR)/$(lexer).x
101
@$(MAKE) -C $(FULL_SRC_DIR) $@
103
## Building the haddock documentation #####################################
105
# It would be nice to check which version of haddock the ghc library
106
# documentation is built with, but I don't know how (in an easy way).
107
# For now it's hard-wired.
108
ifeq ($(HAVE_GHC_6_4),Yes)
109
base_interface_version = 0.7
111
base_interface_version = 0.6
114
ifeq ($(HADDOCK_VERSION),$(base_interface_version))
118
@echo "Warning: The ghc library documentation was probably"
119
@echo " built using version $(base_interface_version) of haddock, but you"
120
@echo " are using version $(HADDOCK_VERSION). Haddock might not be"
121
@echo " able to link to library definitions."
124
index.html : $(prologue) $(dst_hs_files) base.haddock mtl.haddock check_version
125
$(HADDOCK) --odir=. --html \
126
--prologue=$(prologue) \
127
--title="Agda II Documentation" \
128
--ignore-all-exports \
129
--read-interface=$(call haddockArg,base) \
130
--read-interface=$(call haddockArg,mtl) \
133
## Clean ##################################################################
136
rm -rf $(wildcard *.html) src haddock.css haskell_icon.gif
141
## Debugging the Makefile #################################################
144
@echo The Haskell sources are
145
@echo " $(src_hs_files)"
146
@echo The preprocessed files are
147
@echo " $(dst_hs_files)"