[project @ 2000-03-23 15:53:22 by rrt]
[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 LIBRARY = libHS$(_way).a
29 LIBOBJS = $(HS_OBJS)
30 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
31 LIBOBJS = $(filter-out PrelHugs.o,$(HS_OBJS))
32 endif
33
34 #-----------------------------------------------------------------------------
35 #       Setting the GHC compile options
36
37 SRC_HC_OPTS += -recomp -cpp -fglasgow-exts -fvia-C -Rghc-timing $(GhcLibHcOpts) -fcompiling-prelude
38 ifneq "$(way)" "dll"
39 SRC_HC_OPTS += -static
40 endif
41
42 ifdef USE_REPORT_PRELUDE
43 SRC_HC_OPTS += -DUSE_REPORT_PRELUDE=1
44 endif
45
46 #
47 # Object and interface files have suffixes tagged with their ways
48 #
49 ifneq "$(way)" ""
50 SRC_HC_OPTS += -hisuf $(way_)hi
51 endif
52
53 # per-module flags
54 PrelArrExtra_HC_OPTS     += -monly-2-regs
55
56 # Far too much heap is needed to compile PrelNumExtra with -O at the
57 # moment, but there you go..
58 PrelNumExtra_HC_OPTS     += -H24m -K2m
59
60 PrelPack_HC_OPTS         += -K4m
61 PrelBase_HC_OPTS         += -H12m
62 PrelRead_HC_OPTS         += -H20m
63 PrelTup_HC_OPTS          += -H12m -K2m
64 PrelNum_HC_OPTS          += -H12m -K4m
65 PrelArr_HC_OPTS          += -H8m
66 PrelHandle_HC_OPTS       += -H20m
67 Time_HC_OPTS             += -H24m -K2m
68 Complex_HC_OPTS          += -H10m
69 IO_HC_OPTS               += -H12m
70 List_HC_OPTS             += -H8m
71 Directory_HC_OPTS        += -H8m
72
73 #-----------------------------------------------------------------------------
74 #       Dependency generation
75
76 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
77
78 #-----------------------------------------------------------------------------
79 #       Rules
80
81 PrelGHC.$(way_)hi       : PrelGHC.hi-boot
82         cp $< $@
83
84 boot :: PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
85
86 DLL_NAME = HSprel.dll
87 DLL_DESCRIPTION="GHC-compiled Haskell Prelude"
88 DLL_IMPLIB_NAME = libHS_imp.a
89 SRC_BLD_DLL_OPTS += --export-all --output-def=HSprel.def DllVersionInfo.o
90 SRC_BLD_DLL_OPTS += -lwinmm -lHSrts_imp -lHS_cbits_imp -lgmp -L. -L../../rts/gmp -L../../rts -Lcbits
91
92 ifeq "$(way)" "dll"
93 HS_SRCS := $(filter-out PrelMain.lhs PrelHugs.lhs, $(HS_SRCS))
94 endif
95
96 # PrelMain.dll_o isn't to be included in the final .a, 
97 # but it needs to be generated
98 ifeq "$(way)" "dll"
99 all :: PrelMain.dll_o DllVersionInfo.o
100
101 endif
102
103 CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
104
105 #
106 # Building PrelMain.dll_o is, unfortunately, somewhat tricky
107 # with the current DLL setup. PrelMain.dll_o should refer to
108 # all its imports bar Main.main_closure as residing in DLLs.
109 # But, since the .hi's of PrelBase et al. is in the same
110 # directory as PrelMain, the compiler will assume that they
111 # reside in the same DLL as PrelMain & generate code accordingly.
112
113 # So, we copy out PrelMain.lhs to ".." and build it there &
114 # copy the gen'ed object file back in again.
115 #
116 # Note the patsubst hack (see fptools/mk/target.mk and search for
117 # odir for details)
118
119 ifeq "$(way)" "dll"
120 GhcLibHcOpts = -O
121 PrelMain.dll_o : PrelMain.lhs
122         $(RM) ../PrelMain.lhs
123         $(CP) PrelMain.lhs ../
124         $(MAKE) -C .. PrelMain.dll_o way=dll HC=std/$(GHC_INPLACE) HC_OPTS="$(filter-out -fcompiling-prelude, $(patsubst -odir,,$(HC_OPTS)))"
125         $(MV) ../PrelMain.dll_o .
126         $(RM) ../PrelMain.lhs ../PrelMain.dll_hi
127 endif
128
129 #-----------------------------------------------------------------------------
130 #       Installation; need to install .hi files as well as libraries
131 #
132 # The interface files are put inside the $(libdir), since they
133 # might (potentially) be platform specific..
134 #
135 # override is used here because for binary distributions, datadir is
136 # set on the command line. sigh.
137 #
138 override datadir:=$(libdir)/imports/std
139
140 #
141 # Files to install from here
142
143 INSTALL_LIBS  += $(LIBRARY)
144 ifeq "$(EnableWin32DLLs)" "YES"
145 INSTALL_PROGS += $(DLL_NAME)
146 INSTALL_LIBS  += $(patsubst %.a, %_imp.a, $(LIBRARY)) PrelMain.dll_o
147 INSTALL_DATAS += dLL_ifs.hi
148 endif
149 INSTALL_DATAS += $(HS_IFACES) PrelGHC.$(way_)hi
150
151 include $(TOP)/mk/target.mk