1 #-----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.4 1997/03/14 05:11:52 sof Exp $
4 # This is the Makefile for the runtime-system stuff.
5 # This stuff is written in C (and cannot be written in Haskell).
7 # Things are organised into exactly one level of subdirs.
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)
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
22 # Other sorta independent, compile-once subdirs are:
24 # gmp -- GNU multi-precision library (for Integer)
26 #-----------------------------------------------------------------------------
30 include $(TOP)/mk/boilerplate.mk
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'.
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.
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.
48 #-----------------------------------------------------------------------------
49 # knock the "clib" (completely ordinary C, compiled once)
50 # stuff over the head first...
52 # Write out the rule for libHSclib explicitly, as it is special
53 # (not to be built n different ways)
55 SRCS_CLIB_LC = $(wildcard hooks/*.lc) main/Mallocs.lc
56 LIBOBJS_clib = $(SRCS_CLIB_LC:.lc=.o)
60 libHSclib.a :: $(LIBOBJS_clib)
62 $(AR) $(AR_OPTS) $@ $(LIBOBJS_clib)
66 # Stuff to clean out, only on way `normal'
69 MOSTLY_CLEAN_FILES += libHSclib.a $(LIBOBJS_clib)
70 CLEAN_FILES += $(SRCS_CLIB_LC:.lc=.c)
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.
79 INSTALL_LIBS += libHSclib.a
82 #------------------------------------------------------------------
84 # Run-time system parts that are `way' sensitive, you have to build
85 # a copy of libHSrts for each different ways.
88 SRCS_RTS_LH = $(wildcard storage/*.lh)
90 SRCS_RTS_LC = $(wildcard c-as-asm/*.lc) \
106 main/StgOverflow.lc \
112 profiling/CostCentre.lc \
113 profiling/Hashing.lc \
114 profiling/HeapProfile.lc \
115 profiling/Indexing.lc \
121 storage/SMcompacting.lc \
122 storage/SMcopying.lc \
127 storage/SMmarking.lc \
130 storage/SMstacks.lc \
131 storage/SMstatic.lc \
136 # LATER: Include Patrick's generational collector
137 # that's almost-but-not-quite there: storage/SMgen.lc
140 SRCS_RTS_LHC = $(wildcard main/*.lhc c-as-asm/*.lhc storage/*.lhc gum/*.lhc)
142 HEADER_FILES = $(SRCS_RTS_LH:.lh=.h)
143 C_SRCS = $(SRCS_RTS_LC:.lc=.c) $(SRCS_RTS_LHC:.lhc=.hc) $(SRCS_CLIB_LC:.lc=.c) $(HEADER_FILES)
146 # Clean out header files when doing way `normal'
149 CLEAN_FILES += $(H_FILES) $(C_SRCS)
152 #-----------------------------------------------------------------------------
153 # creating and installing libHSrts.a (in its many flavors)
155 LIBRARY = libHSrts$(_way).a
156 LIBOBJS = $(patsubst %.lc,%.$(way_)o,$(SRCS_RTS_LC)) \
157 $(patsubst %.lhc,%.$(way_)o,$(SRCS_RTS_LHC))
162 SRC_HC_OPTS += -I$(GHC_INCLUDE_DIR) -O -optc-DIN_GHC_RTS=1 -I$(GHC_RUNTIME_DIR)/storage
164 SRC_MKDEPENDC_OPTS += $(GCap) $(GC2s) $(GC1s)
166 #-----------------------------------------------------------------------------
167 # file-specific options
168 c-as-asm/PerformIO_HC_OPTS = -optc-DIN_GHC_RTS=1
169 gum/FetchMe_HC_OPTS = -optc-DIN_GHC_RTS=1
170 main/StgStartup_HC_OPTS = -optc-DIN_GHC_RTS=1
171 main/StgThreads_HC_OPTS = -optc-DIN_GHC_RTS=1
172 main/StgUpdate_HC_OPTS = -optc-DIN_GHC_RTS=1
173 storage/SMmark_HC_OPTS = -optc-DIN_GHC_RTS=1 -optc-DMARK_REG_MAP
175 #-----------------------------------------------------------------------------
177 # Compiling the individual files
179 # Rules for building various types of objects from C files,
180 # override the default suffix rule here, as we want to use
181 # ../driver/ghc (a better C compiler :-) to compile the
182 # different RTS pieces
184 CC=$(HC) $(HC_OPTS) $($*_HC_OPTS)
186 #-----------------------------------------------------------------------------
189 # Hook it into the list of files to generate dependencies for
191 C_SRCS += main/TopClosure.c
194 # The TopClosure is not part of libHSrts, so we add an extra all::
195 # target to make sure it is built (TopClosure is way-proof):
198 all :: main/TopClosure.o
200 CLEAN_FILES += main/TopClosure.o
202 # The driver expects to find it in lib/
204 INSTALL_LIBS += main/TopClosure.o
210 #-----------------------------------------------------------------------------
214 # Just libHSrts is installed uniformly across ways
216 INSTALL_LIBS += $(LIBRARY)
219 #-----------------------------------------------------------------------------
221 # Building the GUM SysMan
227 ifdef solaris2_TARGET_OS
228 __socket_libs = -lsocket -lnsl
233 gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o main/Mallocs.o hooks/OutOfVM.o
235 $(HC) $(HC_OPTS) -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)
237 CLEAN_FILES += gum/SysMan.mp_o gum/SysMan
238 INSTALL_LIBS += gum/SysMan
241 include $(TOP)/mk/target.mk