1 #################################################################################
5 # Makefile for building the GHC Prelude libraries umpteen ways
8 #################################################################################
11 include $(TOP)/mk/boilerplate.mk
21 #-----------------------------------------------------------------------------
22 # Setting the standard variables
26 MKDEPENDHS = $(GHC_INPLACE)
29 LIBRARY = libHS$(PACKAGE)$(_way).a
32 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
33 LIBOBJS = $(filter-out PrelHugs.$(way_)o,$(HS_OBJS))
36 #-----------------------------------------------------------------------------
37 # Setting the GHC compile options
39 SRC_HC_OPTS += -recomp -cpp -fglasgow-exts -fvia-C -Rghc-timing $(GhcLibHcOpts) -package-name $(PACKAGE)
41 SRC_HC_OPTS += -static
44 ifdef USE_REPORT_PRELUDE
45 SRC_HC_OPTS += -DUSE_REPORT_PRELUDE=1
49 # Object and interface files have suffixes tagged with their ways
52 SRC_HC_OPTS += -hisuf $(way_)hi
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
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
70 Directory_HC_OPTS += -H8m
72 #-----------------------------------------------------------------------------
73 # Dependency generation
75 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
77 #-----------------------------------------------------------------------------
80 PrelGHC.$(way_)hi : PrelGHC.hi-boot
83 boot :: PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
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
92 HS_SRCS := $(filter-out PrelMain.lhs PrelHugs.lhs, $(HS_SRCS))
95 # PrelMain.dll_o isn't to be included in the final .a,
96 # but it needs to be generated
98 all :: PrelMain.dll_o DllVersionInfo.o
102 CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
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.
112 # So, we copy out PrelMain.lhs to ".." and build it there &
113 # copy the gen'ed object file back in again.
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
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.
132 all :: libHSstd_cbits.u_o
133 CLEAN_FILES += libHSstd_cbits.u_o
135 $(RM) libHSstd_cbits.u_o
136 ld -r -o libHSstd_cbits.u_o cbits/*.o
139 #-----------------------------------------------------------------------------
140 # Installation; need to install .hi files as well as libraries
142 # The interface files are put inside the $(libdir), since they
143 # might (potentially) be platform specific..
145 # override is used here because for binary distributions, datadir is
146 # set on the command line. sigh.
148 override datadir:=$(libdir)/imports/std
151 # Files to install from here
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
159 INSTALL_DATAS += $(HS_IFACES) PrelGHC.$(way_)hi
161 include $(TOP)/mk/target.mk