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