Add a skeleton libraries directory
[ghc-hetmet.git] / libraries / Makefile
1 # -----------------------------------------------------------------------------
2
3 TOP=.
4 include $(TOP)/mk/boilerplate.mk
5
6 # -----------------------------------------------------------------------------
7
8 SUBDIRS = base haskell98 template-haskell
9
10 ifeq "$(GhcLibsWithUnix)" "YES"
11 SUBDIRS += unix
12 endif
13
14 SUBDIRS += Cabal
15 SUBDIRS += $(wildcard parsec)
16
17 # Set GhcBootLibs=YES from the command line to work with just the libraries
18 # needed to bootstrap GHC.
19 ifneq "$(GhcBootLibs)" "YES"
20 SUBDIRS += $(wildcard haskell-src)
21 SUBDIRS += $(wildcard network)
22 SUBDIRS += $(wildcard QuickCheck)
23 SUBDIRS += $(wildcard HUnit)
24 SUBDIRS += $(wildcard mtl)
25 SUBDIRS += $(wildcard fgl)
26 SUBDIRS += $(wildcard X11)
27 ifeq "$(Windows)" "YES"
28 SUBDIRS += $(wildcard Win32)
29 endif
30 SUBDIRS += $(wildcard HGL)
31 SUBDIRS += $(wildcard OpenGL)
32 SUBDIRS += $(wildcard GLUT)
33 SUBDIRS += $(wildcard OpenAL)
34 SUBDIRS += $(wildcard ALUT)
35 SUBDIRS += $(wildcard stm)
36 ifeq "$(GhcLibsWithObjectIO)" "YES"
37 SUBDIRS += $(wildcard ObjectIO)
38 endif
39 endif
40
41 ifeq "$(GhcLibsWithReadline)" "YES"
42 SUBDIRS += $(wildcard readline)
43 endif
44
45 # -----------------------------------------------------------------------------
46
47 DIST_CLEAN_FILES += config.cache config.status
48
49 include $(TOP)/mk/target.mk
50
51 # -----------------------------------------------------------------------------
52 # Generating the combined contents/index pages for the library docs
53
54 ifneq "$(NO_HADDOCK_DOCS)" "YES"
55
56 HTML_DIR = html
57
58 # ATTENTION, incomprehensible shell stuff ahead: Automagically create the
59 # prologue for the combined index via a header, the package prologues (in
60 # alphabetical order of the packages) and a footer. Not very nice, but much
61 # better than redundancy or a strong coupling with the packages.
62 libraries.txt: libraries-header.txt libraries-footer.txt $(foreach f,package.conf.in prologue.txt,$(addsuffix /$(f),$(SUBDIRS)))
63         $(RM) $@
64         ( cat libraries-header.txt ; echo ; \
65         for i in `for j in $(SUBDIRS) ; do echo $$j ; done | $(SORT) -f` ; do \
66            if test -f $$i/$$i.haddock; then \
67               echo "[@$$i@]"; \
68               grep -v '^ *$$' $$i/prologue.txt; \
69               echo; \
70            fi; \
71         done ; \
72         cat libraries-footer.txt ; echo ) > $@
73
74 CLEAN_FILES += libraries.txt
75
76 $(HTML_DIR)/index.html : libraries.txt
77         @$(INSTALL_DIR) $(HTML_DIR)
78         $(HADDOCK) --gen-index --gen-contents -o $(HTML_DIR) \
79                 $(HADDOCK_OPTS) \
80                 -t "Haskell Hierarchical Libraries" \
81                 -p libraries.txt \
82                 $(foreach pkg, $(filter-out haskell98,$(SUBDIRS)), \
83                    $(foreach p, $(wildcard $(pkg)/$(pkg).haddock), \
84                       --read-interface=$(pkg),$(pkg)/$(pkg).haddock))
85
86 html :: $(HTML_DIR)/index.html
87
88 libraries.HxS : libraries.txt
89         @$(INSTALL_DIR) $(HTML_DIR)
90         $(HADDOCK) --gen-index --gen-contents -o $(HTML_DIR) \
91                 $(HADDOCK_OPTS) \
92                 -t "Haskell Hierarchical Libraries" \
93                 -p libraries.txt \
94                 -k libraries \
95                 --html-help=mshelp2 \
96                 $(foreach pkg, $(filter-out haskell98,$(SUBDIRS)), \
97                    $(foreach p, $(wildcard $(pkg)/$(pkg).haddock), \
98                       --read-interface=$(pkg),$(pkg)/$(pkg).haddock))
99         ( cd $(HTML_DIR) && if Hxcomp -p libraries.HxC -o ../$@ ; then false ; else true ; fi ) || true
100
101 libraries.chm : libraries.txt
102         @$(INSTALL_DIR) $(HTML_DIR)
103         $(HADDOCK) --gen-index --gen-contents -o $(HTML_DIR) \
104                 $(HADDOCK_OPTS) \
105                 -t "Haskell Hierarchical Libraries" \
106                 -p libraries.txt \
107                 -k libraries \
108                 --html-help=mshelp \
109                 $(foreach pkg, $(filter-out haskell98,$(SUBDIRS)), \
110                    $(foreach p, $(wildcard $(pkg)/$(pkg).haddock), \
111                       --read-interface=$(pkg),$(pkg)/$(pkg).haddock))
112         ( cd $(HTML_DIR) && if hhc libraries.hhp ; then false ; else true ; fi && mv libraries.chm .. ) || true
113
114 HxS :: libraries.HxS
115 chm :: libraries.chm
116
117 install-docs :: $(HTML_DIR)/index.html
118         $(INSTALL_DIR) $(datadir)/html/libraries; \
119         for i in $(HTML_DIR)/*; do \
120                 if test -f $$i; then \
121                   echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries; \
122                   $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries; \
123                 fi; \
124         done
125         @for i in $(filter html chm HxS,$(XMLDocWays)); do \
126                 if [ $$i != "html" ]; then \
127                         $(INSTALL_DIR) $(datadir)/doc; \
128                         echo $(INSTALL_DATA) $(INSTALL_OPTS) libraries`echo .$$i | sed s/\.html-no-chunks/.html/` $(datadir)/doc; \
129                         $(INSTALL_DATA) $(INSTALL_OPTS) libraries`echo .$$i | sed s/\.html-no-chunks/.html/` $(datadir)/doc; \
130                 fi; \
131                 if [ $$i = "html-no-chunks" ]; then \
132                         echo $(CP) $(FPTOOLS_CSS_ABS) $(datadir); \
133                         $(CP) $(FPTOOLS_CSS_ABS) $(datadir); \
134                 fi \
135         done
136 endif # NO_HADDOCK_DOCS