~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to doc/haddock/Makefile

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Making the haddock documentation
2
 
# Author: Ulf Norell
3
 
 
4
 
## Includes ###############################################################
5
 
 
6
 
TOP = ../..
7
 
 
8
 
include $(TOP)/mk/config.mk
9
 
include $(TOP)/mk/paths.mk
10
 
 
11
 
## Variables ##############################################################
12
 
 
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
17
 
 
18
 
# Haskell files
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))
25
 
 
26
 
# The prologue. Contains an introduction to the documentation
27
 
prologue                = prologue
28
 
 
29
 
## Phony targets ##########################################################
30
 
 
31
 
.PHONY : default clean veryclean debug check_version
32
 
 
33
 
## Default target #########################################################
34
 
 
35
 
ifeq ($(HAVE_HADDOCK),Yes)
36
 
 
37
 
default : index.html
38
 
 
39
 
else
40
 
 
41
 
default :
42
 
        @echo You need haddock to build this documentation.
43
 
        @$(FALSE)
44
 
 
45
 
endif
46
 
 
47
 
## Base file ##############################################################
48
 
 
49
 
ifeq ($(HAVE_WGET),Yes)
50
 
 
51
 
%.haddock :
52
 
        wget $(call haddockFile,$*)
53
 
 
54
 
else
55
 
 
56
 
%.haddock :
57
 
        @echo $(call haddockFile,$*) have to be downloaded manually since wget could not be found.
58
 
        @$(FALSE)
59
 
 
60
 
endif
61
 
 
62
 
## Preprocessing Haskell files ############################################
63
 
 
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
68
 
# #ifndef __HADDOCK__
69
 
# It might also be necessary to define a dummy version of types imported
70
 
# from boot files as follows:
71
 
 
72
 
# #ifndef __HADDOCK__
73
 
# import Foo (X)
74
 
# #endif
75
 
# ...
76
 
# #ifdef __HADDOCK__
77
 
# -- | Trick to make haddock accept circular module dependencies. See 'Foo.X'.
78
 
# data X
79
 
# #endif
80
 
 
81
 
# There is no need to do this for functions since they cannot appear in
82
 
# types, and thus not in haddock documentation.
83
 
 
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 $@ $<
88
 
 
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 $@ $<
93
 
 
94
 
src :
95
 
        $(MKDIR) -p src
96
 
 
97
 
$(FULL_OUT_DIR)/$(parser).hs : $(FULL_SRC_DIR)/$(parser).y
98
 
        @$(MAKE) -C $(FULL_SRC_DIR) $@
99
 
 
100
 
$(FULL_OUT_DIR)/$(lexer).hs : $(FULL_SRC_DIR)/$(lexer).x
101
 
        @$(MAKE) -C $(FULL_SRC_DIR) $@
102
 
 
103
 
## Building the haddock documentation #####################################
104
 
 
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
110
 
else
111
 
base_interface_version = 0.6
112
 
endif
113
 
 
114
 
ifeq ($(HADDOCK_VERSION),$(base_interface_version))
115
 
check_version :
116
 
else
117
 
check_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."
122
 
endif
123
 
 
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) \
131
 
                        $(dst_hs_files)
132
 
 
133
 
## Clean ##################################################################
134
 
 
135
 
clean :
136
 
        rm -rf $(wildcard *.html) src haddock.css haskell_icon.gif
137
 
 
138
 
veryclean : clean
139
 
        rm -f base.haddock
140
 
 
141
 
## Debugging the Makefile #################################################
142
 
 
143
 
debug :
144
 
        @echo The Haskell sources are
145
 
        @echo "  $(src_hs_files)"
146
 
        @echo The preprocessed files are
147
 
        @echo "  $(dst_hs_files)"
148