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