[project @ 2001-01-15 17:05:46 by sewardj]
[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 CC       = $(GHC_INPLACE)
27
28 ifneq "$(DLLized)" "YES"
29 PACKAGE = -package-name std
30 else
31 # Hack by SPJ to delay if-then-else until the pattern rule when we have $*
32 PACKAGE = $(subst ~, ,$(word $(words dummy $(findstring $(notdir $*), PrelMain )), -package-name~std))
33 endif
34
35 HSLIB = std
36
37 # we don't want PrelMain in the GHCi library.
38 GHCI_LIBOBJS = $(filter-out PrelMain.$(way_)o,$(HS_OBJS))
39
40 HS_SRCS += $(patsubst %.hsc,%.hs,$(wildcard *.hsc))
41
42 #-----------------------------------------------------------------------------
43 #       Setting the GHC compile options
44
45 SRC_HC_OPTS += -recomp -cpp -fvia-C -fglasgow-exts $(GhcLibHcOpts) $(PACKAGE)
46 ifneq "$(DLLized)" "YES"
47 SRC_HC_OPTS += -static
48 endif
49
50 ifdef USE_REPORT_PRELUDE
51 SRC_HC_OPTS += -DUSE_REPORT_PRELUDE=1
52 endif
53
54 #
55 # Object and interface files have suffixes tagged with their ways
56 #
57 ifneq "$(way)" ""
58 SRC_HC_OPTS += -hisuf $(way_)hi
59 endif
60
61 #-----------------------------------------------------------------------------
62 #       Dependency generation
63
64 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
65
66 #-----------------------------------------------------------------------------
67 #       Rules
68
69 PrelPrimopWrappers.hs: ../../compiler/prelude/primops.txt
70         rm -f PrelPrimopWrappers.hs
71         ../../utils/genprimopcode/genprimopcode  --make-haskell-wrappers \
72                 < ../../compiler/prelude/primops.txt > PrelPrimopWrappers.hs
73
74 PrelGHC.$(way_)hi       : PrelGHC.hi-boot
75         cp $< $@
76
77 boot :: PrelPrimopWrappers.hs PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
78 all :: PrelPrimopWrappers.hs
79
80 DLL_DESCRIPTION="GHC-compiled Haskell Prelude"
81
82 ifeq "$(DLLized)" "YES"
83 HS_SRCS := $(filter-out PrelMain.lhs PrelHugs.lhs, $(HS_SRCS))
84 endif
85
86 # PrelMain.dll_o isn't to be included in the final .a, 
87 # but it needs to be generated
88 ifeq "$(DLLized)" "YES"
89 all :: PrelMain.dll_o
90 endif
91
92 CLEAN_FILES += PrelPrimopWrappers.hs PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
93
94 #
95 # If we're building the unregisterised way, it may well be for Hugs.
96 # In that case, remember to bind the cbits objects into a single file
97 # which hugs can load as an auxiliary object file when loading the Prelude.
98 #
99 ifeq "$(way)" "u"
100 all :: libHSstd_cbits.u_o
101 CLEAN_FILES += libHSstd_cbits.u_o
102 libHSstd_cbits.u_o:
103         $(RM) libHSstd_cbits.u_o
104         ld -r -o libHSstd_cbits.u_o cbits/*.o
105 endif
106
107 #-----------------------------------------------------------------------------
108 #       Installation; need to install .hi files as well as libraries
109 #
110 # The interface files are put inside the $(libdir), since they
111 # might (potentially) be platform specific..
112 #
113 # override is used here because for binary distributions, datadir is
114 # set on the command line. sigh.
115 #
116 override datadir:=$(libdir)/imports/std
117
118 #
119 # Files to install from here
120
121 ifeq "$(DLLized)" "YES"
122 INSTALL_LIBS  += PrelMain.dll_o
123 endif
124
125 INSTALL_DATAS += PrelGHC.$(way_)hi
126 ifeq "$(DLLized)" "YES"
127 INSTALL_DATAS := $(filter-out PrelHugs.$(way_)hi,$(INSTALL_DATAS))
128 endif
129
130 include $(TOP)/mk/target.mk