fe0aa56edd3b10fa4b16363f57934c1ea8c072a7
[ghc-hetmet.git] / ghc / runtime / Makefile
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.9 1997/08/25 21:32:14 sof Exp $
3
4 #  This is the Makefile for the runtime-system stuff.
5 #  This stuff is written in C (and cannot be written in Haskell).
6 #
7 #  Things are organised into exactly one level of subdirs.
8 #
9 #  At the moment, there are a few such subdirs:
10 #       c-as-asm        -- mini-interpreter & register hackery
11 #       gum             -- GUM-specific stuff
12 #       main            -- "main", associated startup stuff, & MISC things
13 #       prims           -- code for primitives that must be written in C
14 #       profiling       -- cost-centre profiling
15 #       storage         -- the storage manager(s)
16 #
17 #  We create two libraries.  One, libHSrts<tag>.a, is built separately
18 #  for each "way".  The other, libHSclib.a is built once: it is just
19 #  .lc files that end up the same no matter what, i.e. completely
20 #  ordinary C.
21
22 #  Other sorta independent, compile-once subdirs are:
23
24 #       gmp             -- GNU multi-precision library (for Integer)
25
26 #-----------------------------------------------------------------------------
27
28 TOP=..
29 DoingRTS=YES
30 include $(TOP)/mk/boilerplate.mk
31
32 #
33 # A general rule for the grand mk setup is that in a build tree, only
34 # directories that don't have any subdirs containing Makefiles are built
35 # all the different `ways' when doing `make all'. 
36 #
37 # The directory structure for the RTS is a bit at odds to the general
38 # scheme of things, with the GNU gmp library in gmp/ and a way-independent
39 # archive libHSclib.a beside all the way-archives for the RTS proper.
40 #
41 # So to avoid having to redo building the way-proof pieces each time
42 # the Makefile is invoked with a different setting of $(way), SUBDIRS
43 # is only set if $(way) isn't set. 
44 #
45
46 SUBDIRS = gmp
47
48 #-----------------------------------------------------------------------------
49 # knock the "clib" (completely ordinary C, compiled once)
50 # stuff over the head first...
51 #
52 # Write out the rule for libHSclib explicitly, as it is special
53 #  (not to be built n different ways)
54 #
55 SRCS_CLIB_LC  = $(wildcard hooks/*.lc) main/Mallocs.lc
56 LIBOBJS_clib  = $(SRCS_CLIB_LC:.lc=.o)
57
58 all :: libHSclib.a
59
60 libHSclib.a :: $(LIBOBJS_clib)
61         @$(RM) $@
62         $(AR) $(AR_OPTS) $@ $(LIBOBJS_clib)
63         $(RANLIB) $@
64
65 #
66 # Stuff to clean out, only on way `normal'
67 #
68 ifeq "$(way)" ""
69 MOSTLY_CLEAN_FILES += libHSclib.a $(LIBOBJS_clib)
70 CLEAN_FILES        += $(SRCS_CLIB_LC:.lc=.c)
71 endif
72
73 #
74 # Add libHSclib to the install library variable *only*
75 # if we're doing `make install' the `normal' way - don't want
76 # to install the same library for each different way.
77 #
78 ifeq "$(way)" ""
79 INSTALL_LIBS += libHSclib.a
80 endif
81
82 #------------------------------------------------------------------
83 #
84 # Run-time system parts that are `way' sensitive, you have to build
85 # a copy of libHSrts for each different ways.
86 #
87
88 SRCS_RTS_LH = $(wildcard storage/*.lh)
89
90 SRCS_RTS_LC = $(wildcard c-as-asm/*.lc) \
91         gum/GlobAddr.lc                 \
92         gum/HLComms.lc                  \
93         gum/Hash.lc                     \
94         gum/LLComms.lc                  \
95         gum/Pack.lc                     \
96         gum/ParInit.lc                  \
97         gum/RBH.lc                      \
98         gum/Sparks.lc                   \
99         gum/Unpack.lc                   \
100         main/GranSim.lc                 \
101         main/Itimer.lc                  \
102         main/Ticky.lc                   \
103         main/SMRep.lc                   \
104         main/Select.lc                  \
105         main/Signals.lc                 \
106         main/StgOverflow.lc             \
107         main/Threads.lc                 \
108         main/RtsFlags.lc                \
109         main/main.lc                    \
110         prims/PrimArith.lc              \
111         prims/PrimMisc.lc               \
112         profiling/CostCentre.lc         \
113         profiling/Hashing.lc            \
114         profiling/HeapProfile.lc        \
115         profiling/Indexing.lc           \
116         profiling/Timer.lc              \
117         storage/SM1s.lc                 \
118         storage/SM2s.lc                 \
119         storage/SMap.lc                 \
120         storage/SMcheck.lc              \
121         storage/SMcompacting.lc         \
122         storage/SMcopying.lc            \
123         storage/SMdu.lc                 \
124         storage/SMevac.lc               \
125         storage/SMextn.lc               \
126         storage/SMinit.lc               \
127         storage/SMmarking.lc            \
128         storage/SMscan.lc               \
129         storage/SMscav.lc               \
130         storage/SMstacks.lc             \
131         storage/SMstatic.lc             \
132         storage/SMstats.lc              \
133         storage/mprotect.lc
134
135 #
136 # LATER: Include Patrick's generational collector
137 # that's almost-but-not-quite there: storage/SMgen.lc
138 #
139
140 SRCS_RTS_LHC = $(wildcard main/*.lhc c-as-asm/*.lhc storage/*.lhc gum/*.lhc)
141
142 HEADER_FILES = $(SRCS_RTS_LH:.lh=.h)
143
144 C_SRCS = $(SRCS_RTS_LC:.lc=.c) $(SRCS_RTS_LHC:.lhc=.hc) $(SRCS_CLIB_LC:.lc=.c) $(HEADER_FILES)
145
146 # To avoid having to redo these each time.
147 .PRECIOUS : %.$(way_)hc
148
149 #
150 # Clean out header files when doing way `normal'
151 #
152 ifeq "$(way)" ""
153 CLEAN_FILES += $(H_FILES) $(C_SRCS)
154 endif
155
156 #-----------------------------------------------------------------------------
157 # creating and installing libHSrts.a (in its many flavors)
158 #
159 LIBRARY = libHSrts$(_way).a
160 LIBOBJS = $(patsubst %.lc,%.$(way_)o,$(SRCS_RTS_LC)) \
161           $(patsubst %.lhc,%.$(way_)o,$(SRCS_RTS_LHC))
162
163 SRC_HC_OPTS += -I$(GHC_INCLUDE_DIR) $(GCap) $(GC2s) $(GC1s) -O -optc-DIN_GHC_RTS=1 -I$(GHC_RUNTIME_DIR)/storage 
164
165 #
166 # Note: _have_ to drop the -optc prefix for the GC-type opts (e.g. -optc-DGCap), since
167 # -o<foo> is interpreted by mkdependC as meaning use <foo> as suffix.
168 #
169 # Include -D for all the different collectors to be sure we get at all deps.
170 #
171 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR) -DGCap -DGC1s -DGC2s
172
173 #-----------------------------------------------------------------------------
174 # file-specific options 
175 c-as-asm/PerformIO_HC_OPTS = -optc-DIN_GHC_RTS=1
176 gum/FetchMe_HC_OPTS        = -optc-DIN_GHC_RTS=1
177 main/StgStartup_HC_OPTS    = -optc-DIN_GHC_RTS=1
178 main/StgThreads_HC_OPTS    = -optc-DIN_GHC_RTS=1
179 main/StgUpdate_HC_OPTS     = -optc-DIN_GHC_RTS=1
180 storage/SMmark_HC_OPTS     = -optc-DIN_GHC_RTS=1 -optc-DMARK_REG_MAP
181
182 #-----------------------------------------------------------------------------
183 #
184 # Compiling the individual files
185 #
186 # Rules for building various types of objects from C files,
187 # override the default suffix rule here, as we want to use
188 # ../driver/ghc (a better C compiler :-) to compile the
189 # different RTS pieces
190 #
191 CC=$(HC) $(HC_OPTS) $($*_HC_OPTS)
192
193 #-----------------------------------------------------------------------------
194 # the TopClosure
195 #
196 # Hook it into the list of files to generate dependencies for
197 #
198 C_SRCS += main/TopClosure.c
199
200 #
201 # The TopClosure is not part of libHSrts, so we add an extra all::
202 # target to make sure it is built (TopClosure is way-proof):
203 #
204 ifeq "$(way)" ""
205 all :: main/TopClosure.o
206
207 CLEAN_FILES  += main/TopClosure.o
208 #
209 # The driver expects to find it in lib/
210 #
211 INSTALL_LIBS += main/TopClosure.o
212 endif
213
214 #-----------------------------------------------------------------------------
215 #
216 # Files to install
217 #
218 # Just libHSrts is installed uniformly across ways
219 #
220 INSTALL_LIBS += $(LIBRARY)
221
222
223 #-----------------------------------------------------------------------------
224 #
225 # Building the GUM SysMan
226 #
227
228 ifeq "$(way)" "mp"
229 all :: gum/SysMan
230
231 ifdef solaris2_TARGET_OS
232 __socket_libs = -lsocket -lnsl
233 else
234 __socket_libs =
235 endif
236
237 gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o
238         $(RM) $@
239         gcc -o $@ gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o -L$$PVM_ROOT/lib/$$PVM_ARCH -lpvm3 -lgpvm3 $(__socket_libs)
240
241 CLEAN_FILES  += gum/SysMan.mp_o gum/SysMan
242 INSTALL_LIBEXECS += gum/SysMan
243 endif
244
245 include $(TOP)/mk/target.mk