[project @ 2002-06-08 13:11:27 by panne]
[ghc-base.git] / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.31 2002/06/08 13:11:27 panne Exp $
3
4 TOP=..
5 include $(TOP)/mk/boilerplate.mk
6
7 # -----------------------------------------------------------------------------
8
9 SUBDIRS = cbits include
10
11 ALL_DIRS = \
12         Control \
13         Control/Concurrent \
14         Control/Monad \
15         Control/Monad/ST \
16         Data \
17         Data/Array \
18         Database \
19         Debug \
20         Debug/QuickCheck \
21         FileFormat \
22         Foreign \
23         Foreign/C \
24         Foreign/Marshal \
25         GHC \
26         Hugs \
27         Language \
28         Network \
29         NHC \
30         System \
31         System/Console \
32         System/Mem \
33         System/IO \
34         Text \
35         Text/Html \
36         Text/PrettyPrint \
37         Text/ParserCombinators \
38         Text/ParserCombinators/Parsec \
39         Text/Regex \
40         Text/Show \
41         Text/Read
42
43 PACKAGE = base
44
45 SRC_HC_OPTS += -fglasgow-exts -cpp -Iinclude
46 SRC_HSC2HS_OPTS += -Iinclude
47
48 # Make sure we can get hold of regex.h
49 ifneq "$(HavePosixRegex)" "YES"
50 SRC_HC_OPTS     += -Icbits/regex
51 SRC_HSC2HS_OPTS += -Icbits/regex
52 endif
53
54 # -----------------------------------------------------------------------------
55 # Per-module flags
56
57 # ESSENTIAL, for getting reasonable performance from the I/O library:
58 SRC_HC_OPTS += -funbox-strict-fields
59
60 # -----------------------------------------------------------------------------
61 # PrimOpWrappers
62
63 GHC/PrimopWrappers.hs: $(GHC_COMPILER_DIR)/prelude/primops.txt
64         rm -f $@
65         $(GHC_GENPRIMOP) --make-haskell-wrappers < $< > $@
66
67 boot :: GHC/PrimopWrappers.hs
68
69 EXTRA_SRCS  += GHC/PrimopWrappers.hs
70 CLEAN_FILES += GHC/PrimopWrappers.hs
71
72 #-----------------------------------------------------------------------------
73 #       Building the library for GHCi
74 #
75 # The procedure differs from that in fptools/mk/target.mk in one way:
76 #  (*) on Win32 we must split it into two, because a single .o file can't
77 #      have more than 65536 relocations in it [due to a bug in the GNU
78 #      linker.]
79
80 OBJECT_FILEFORMAT=unknown
81 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
82 OBJECT_FILEFORMAT=PEi
83 endif
84 ifeq "$(TARGETPLATFORM)" "i386-unknown-cygwin32"
85 OBJECT_FILEFORMAT=PEi
86 endif
87
88 ifeq "$(OBJECT_FILEFORMAT)" "PEi"
89
90 # Turn off standard rule which creates HSbase.o from LIBOBJS.
91 DONT_WANT_STD_GHCI_LIB_RULE=YES
92
93 GHCI_LIBOBJS = $(HS_OBJS)
94
95 INSTALL_LIBS += HSbase1.o HSbase2.o HSbase3.o
96
97 endif # OBJECT_FILEFORMAT = PEi
98
99
100 # -----------------------------------------------------------------------------
101 # Doc building with Haddock
102
103 EXCLUDED_HADDOCK_SRCS = \
104         Data/Generics.hs \
105         GHC/PArr.hs
106
107 HS_PPS = $(addsuffix .raw-hs, $(basename $(filter-out $(EXCLUDED_HADDOCK_SRCS), $(HS_SRCS))))
108
109 HADDOCK = $(FPTOOLS_TOP)/haddock/src/haddock-inplace
110
111 # Urgh, hack needed to ensure that the value of HS_SRCS is computed in time for
112 # the docs rule below.
113 PRE_SRCS := $(ALL_SRCS)
114
115 .PHONY: docs
116 haddock-docs : $(HS_PPS)
117         $(HADDOCK) -t "Haskell Core Libraries" -h -s "." $(HS_PPS)
118
119 %.raw-hs : %.lhs
120         $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
121
122 %.raw-hs : %.hs
123         $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
124
125 # -----------------------------------------------------------------------------
126
127 include $(TOP)/mk/target.mk
128
129 ifeq "$(OBJECT_FILEFORMAT)" "PEi"
130 HSbase.o : $(GHCI_LIBOBJS)
131         $(LD) -r $(LD_X) -o HSbase1.o $(filter     GHC/%, $(GHCI_LIBOBJS))
132         $(LD) -r $(LD_X) -o HSbase2.o $(filter     Text/%, $(GHCI_LIBOBJS))
133         $(LD) -r $(LD_X) -o HSbase3.o $(filter-out GHC/% Text/%, $(GHCI_LIBOBJS))
134         @touch HSbase.o
135 endif # OBJECT_FILEFORMAT = PEi
136