Makefile 4.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#################################################################################
#
#			    ghc/lib/std/Makefile
#
#		Makefile for building the GHC Prelude libraries umpteen ways
#
#	
#################################################################################

TOP = ../..
include $(TOP)/mk/boilerplate.mk

WAYS=$(GhcLibWays)

ifeq "$(way)" ""
SUBDIRS = cbits
else
SUBDIRS=
endif

#-----------------------------------------------------------------------------
# 	Setting the standard variables
#

25
26
27
HC 	   = $(GHC_INPLACE)
MKDEPENDHS = $(GHC_INPLACE)

28
29
30
31
32
33
LIBRARY = libHS$(_way).a
LIBOBJS = $(HS_OBJS)

#-----------------------------------------------------------------------------
# 	Setting the GHC compile options

sof's avatar
sof committed
34
35
36
37
SRC_HC_OPTS += -recomp -cpp -fglasgow-exts -fvia-C -Rghc-timing $(GhcLibHcOpts) -fcompiling-prelude
ifneq "$(way)" "dll"
SRC_HC_OPTS += -static
endif
38

39
40
41
42
ifdef USE_REPORT_PRELUDE
SRC_HC_OPTS += -DUSE_REPORT_PRELUDE=1
endif

43
44
45
46
47
48
49
50
#
# Object and interface files have suffixes tagged with their ways
#
ifneq "$(way)" ""
SRC_HC_OPTS += -hisuf $(way_)hi
endif

# 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
60
PrelRead_HC_OPTS         += -H20m
PrelTup_HC_OPTS          += -H12m -K2m
61
PrelNum_HC_OPTS		 += -H12m -K4m
62
PrelArr_HC_OPTS          += -H8m
63
64
PrelHandle_HC_OPTS       += -H20m
Time_HC_OPTS             += -H24m -K2m
65
66
Complex_HC_OPTS          += -H10m
IO_HC_OPTS	         += -H12m
67
68
List_HC_OPTS             += -H8m
Directory_HC_OPTS        += -H8m
69
70
71
72
73
74
75
76
77
78
79
80
81
82

#-----------------------------------------------------------------------------
# 	Dependency generation

SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)

#-----------------------------------------------------------------------------
# 	Rules

PrelGHC.$(way_)hi	: PrelGHC.hi-boot
	cp $< $@

boot :: PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)

sof's avatar
sof committed
83
DLL_NAME = HSprel.dll
sof's avatar
sof committed
84
DLL_DESCRIPTION="GHC-compiled Haskell Prelude"
sof's avatar
sof committed
85
DLL_IMPLIB_NAME = libHS_imp.a
sof's avatar
sof committed
86
SRC_BLD_DLL_OPTS += --export-all --output-def=HSprel.def DllVersionInfo.o
rrt's avatar
rrt committed
87
SRC_BLD_DLL_OPTS += -lwinmm -lHSrts_imp -lHS_cbits_imp -lgmp -L. -L../../rts/gmp -L../../rts -Lcbits
sof's avatar
sof committed
88
89
90
91
92

ifeq "$(way)" "dll"
HS_SRCS := $(filter-out PrelMain.lhs, $(HS_SRCS))
endif

sof's avatar
sof committed
93
94
# PrelMain.dll_o isn't to be included in the final .a, 
# but it needs to be generated
sof's avatar
sof committed
95
ifeq "$(way)" "dll"
sof's avatar
sof committed
96
97
all :: PrelMain.dll_o DllVersionInfo.o

sof's avatar
sof committed
98
99
endif

100
101
CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)

sof's avatar
sof committed
102
103
104
105
106
107
108
109
110
111
#
# Building PrelMain.dll_o is, unfortunately, somewhat tricky
# with the current DLL setup. PrelMain.dll_o should refer to
# all its imports bar Main.main_closure as residing in DLLs.
# But, since the .hi's of PrelBase et al. is in the same
# directory as PrelMain, the compiler will assume that they
# reside in the same DLL as PrelMain & generate code accordingly.
# 
# So, we copy out PrelMain.lhs to ".." and build it there &
# copy the gen'ed object file back in again.
rrt's avatar
rrt committed
112
113
114
#
# Note the patsubst hack (see fptools/mk/target.mk and search for
# odir for details)
sof's avatar
sof committed
115
116
117
118
119
# 
ifeq "$(way)" "dll"
PrelMain.dll_o : PrelMain.lhs
	$(RM) ../PrelMain.lhs
	$(CP) PrelMain.lhs ../
rrt's avatar
rrt committed
120
	$(MAKE) -C .. PrelMain.dll_o way=dll HC=std/$(GHC_INPLACE) HC_OPTS="$(filter-out -fcompiling-prelude, $(patsubst -odir,,$(HC_OPTS)))"
sof's avatar
sof committed
121
122
123
	$(MV) ../PrelMain.dll_o .
	$(RM) ../PrelMain.lhs ../PrelMain.dll_hi
endif
sof's avatar
sof committed
124

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#-----------------------------------------------------------------------------
# 	Installation; need to install .hi files as well as libraries
#
# The interface files are put inside the $(libdir), since they
# might (potentially) be platform specific..
#
# override is used here because for binary distributions, datadir is
# set on the command line. sigh.
#
override datadir:=$(libdir)/imports/std

#
# Files to install from here
# 
INSTALL_LIBS  += $(LIBRARY)
sof's avatar
sof committed
140
141
ifeq "$(EnableWin32DLLs)" "YES"
INSTALL_PROGS += $(DLL_NAME)
sof's avatar
sof committed
142
INSTALL_LIBS  += $(patsubst %.a, %_imp.a, $(LIBRARY)) PrelMain.dll_o
sof's avatar
sof committed
143
144
INSTALL_DATAS += dLL_ifs.hi
endif
145
INSTALL_DATAS += $(HS_IFACES) PrelGHC.$(way_)hi
146
147

include $(TOP)/mk/target.mk