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