[project @ 2000-04-13 11:56:35 by simonpj]
[ghc-hetmet.git] / ghc / lib / std / Makefile
1 #################################################################################
2 #
3 #                           ghc/lib/std/Makefile
4 #
5 #               Makefile for building the GHC Prelude libraries umpteen ways
6 #
7 #       
8 #################################################################################
9
10 TOP = ../..
11 include $(TOP)/mk/boilerplate.mk
12
13 WAYS=$(GhcLibWays)
14
15 ifeq "$(way)" ""
16 SUBDIRS = cbits
17 else
18 SUBDIRS=
19 endif
20
21 #-----------------------------------------------------------------------------
22 #       Setting the standard variables
23 #
24
25 HC         = $(GHC_INPLACE)
26 MKDEPENDHS = $(GHC_INPLACE)
27
28 PACKAGE = std
29 LIBRARY = libHS$(PACKAGE)$(_way).a
30
31 LIBOBJS = $(HS_OBJS)
32 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
33 LIBOBJS = $(filter-out PrelHugs.$(way_)o,$(HS_OBJS))
34 endif
35
36 #-----------------------------------------------------------------------------
37 #       Setting the GHC compile options
38
39 SRC_HC_OPTS += -recomp -cpp -fglasgow-exts -fvia-C -Rghc-timing $(GhcLibHcOpts) -package-name $(PACKAGE)
40 ifneq "$(way)" "dll"
41 SRC_HC_OPTS += -static
42 endif
43
44 ifdef USE_REPORT_PRELUDE
45 SRC_HC_OPTS += -DUSE_REPORT_PRELUDE=1
46 endif
47
48 #
49 # Object and interface files have suffixes tagged with their ways
50 #
51 ifneq "$(way)" ""
52 SRC_HC_OPTS += -hisuf $(way_)hi
53 endif
54
55 # Far too much heap is needed to compile PrelNumExtra with -O at the
56 # moment, but there you go..
57 PrelNumExtra_HC_OPTS     += -H24m -K2m
58
59 PrelPack_HC_OPTS         += -K4m
60 PrelBase_HC_OPTS         += -H12m
61 PrelRead_HC_OPTS         += -H20m
62 PrelTup_HC_OPTS          += -H12m -K2m
63 PrelNum_HC_OPTS          += -H12m -K4m
64 PrelArr_HC_OPTS          += -H8m
65 PrelHandle_HC_OPTS       += -H20m
66 Time_HC_OPTS             += -H24m -K2m
67 Complex_HC_OPTS          += -H10m
68 IO_HC_OPTS               += -H12m
69 List_HC_OPTS             += -H8m
70 Directory_HC_OPTS        += -H8m
71
72 #-----------------------------------------------------------------------------
73 #       Dependency generation
74
75 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
76
77 #-----------------------------------------------------------------------------
78 #       Rules
79
80 PrelGHC.$(way_)hi       : PrelGHC.hi-boot
81         cp $< $@
82
83 boot :: PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
84
85 DLL_NAME = HSprel.dll
86 DLL_DESCRIPTION="GHC-compiled Haskell Prelude"
87 DLL_IMPLIB_NAME = libHSstd_imp.a
88 SRC_BLD_DLL_OPTS += --export-all --output-def=HSprel.def DllVersionInfo.o
89 SRC_BLD_DLL_OPTS += -lwinmm -lHSrts_imp -lHSstd_cbits_imp -lgmp -L. -L../../rts/gmp -L../../rts -Lcbits
90
91 ifeq "$(way)" "dll"
92 HS_SRCS := $(filter-out PrelMain.lhs PrelHugs.lhs, $(HS_SRCS))
93 endif
94
95 # PrelMain.dll_o isn't to be included in the final .a, 
96 # but it needs to be generated
97 ifeq "$(way)" "dll"
98 all :: PrelMain.dll_o DllVersionInfo.o
99
100 endif
101
102 CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
103
104 #
105 # Building PrelMain.dll_o is, unfortunately, somewhat tricky
106 # with the current DLL setup. PrelMain.dll_o should refer to
107 # all its imports bar Main.main_closure as residing in DLLs.
108 # But, since the .hi's of PrelBase et al. is in the same
109 # directory as PrelMain, the compiler will assume that they
110 # reside in the same DLL as PrelMain & generate code accordingly.
111
112 # So, we copy out PrelMain.lhs to ".." and build it there &
113 # copy the gen'ed object file back in again.
114
115 ifeq "$(way)" "dll"
116 SplitObjs = NO
117 PrelMain.dll_o : PrelMain.lhs
118         $(RM) ../PrelMain.lhs
119         $(CP) PrelMain.lhs ../
120         $(MAKE) -C .. PrelMain.dll_o way=dll HC=std/$(GHC_INPLACE) HC_OPTS="$(filter-out -fcompiling-prelude, $(HC_OPTS))"
121         $(MV) ../PrelMain.dll_o .
122         $(RM) ../PrelMain.lhs ../PrelMain.dll_hi
123 endif
124
125
126 #
127 # If we're building the unregisterised way, it may well be for Hugs.
128 # In that case, remember to bind the cbits objects into a single file
129 # which hugs can load as an auxiliary object file when loading the Prelude.
130 #
131 ifeq "$(way)" "u"
132 all :: libHSstd_cbits.u_o
133 CLEAN_FILES += libHSstd_cbits.u_o
134 libHSstd_cbits.u_o:
135         $(RM) libHSstd_cbits.u_o
136         ld -r -o libHSstd_cbits.u_o cbits/*.o
137 endif
138
139 #-----------------------------------------------------------------------------
140 #       Installation; need to install .hi files as well as libraries
141 #
142 # The interface files are put inside the $(libdir), since they
143 # might (potentially) be platform specific..
144 #
145 # override is used here because for binary distributions, datadir is
146 # set on the command line. sigh.
147 #
148 override datadir:=$(libdir)/imports/std
149
150 #
151 # Files to install from here
152
153 INSTALL_LIBS  += $(LIBRARY)
154 ifeq "$(EnableWin32DLLs)" "YES"
155 INSTALL_PROGS += $(DLL_NAME)
156 INSTALL_LIBS  += $(patsubst %.a, %_imp.a, $(LIBRARY)) PrelMain.dll_o
157 INSTALL_DATAS += dLL_ifs.hi
158 endif
159 INSTALL_DATAS += $(HS_IFACES) PrelGHC.$(way_)hi
160
161 include $(TOP)/mk/target.mk