[project @ 1999-05-10 08:23:55 by sof]
[ghc-hetmet.git] / ghc / rts / Makefile
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.10 1999/05/10 08:23:55 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 #  We create two libraries.  One, libHSrts<tag>.a, is built separately
8 #  for each "way".  The other, libHSclib.a is built once: it is just
9 #  .lc files that end up the same no matter what, i.e. completely
10 #  ordinary C.
11
12 #  Other sorta independent, compile-once subdirs are:
13
14 #       gmp             -- GNU multi-precision library (for Integer)
15
16 #-----------------------------------------------------------------------------
17
18 TOP=..
19 DoingRTS=YES
20 include $(TOP)/mk/boilerplate.mk
21
22 WAYS=$(GhcLibWays)
23
24 SRCS_RTS_C  = $(wildcard *.c) $(wildcard hooks/*.c) $(filter-out gum/SysMan.c,$(wildcard gum/*.c))
25 SRCS_RTS_S  = $(wildcard *.S)
26 SRCS_RTS_HC = $(wildcard *.hc)
27
28 #-----------------------------------------------------------------------------
29 # creating and installing libHSrts.a (in its many flavors)
30 #
31 LIBRARY = libHSrts$(_way).a
32 LIBOBJS = $(patsubst %.c,%.$(way_)o,$(SRCS_RTS_C)) \
33           $(patsubst %.hc,%.$(way_)o,$(SRCS_RTS_HC)) \
34           $(patsubst %.S,%.$(way_)o,$(SRCS_RTS_S))
35
36 # gcc provides lots of useful warnings if you ask it.
37 # This is a pretty good list to start with - use a # to comment out
38 # any you don't like.
39 WARNING_OPTS += -optc-Wall 
40 WARNING_OPTS += -optc-W
41 WARNING_OPTS += -optc-Wstrict-prototypes 
42 WARNING_OPTS += -optc-Wmissing-prototypes 
43 WARNING_OPTS += -optc-Wmissing-declarations
44 WARNING_OPTS += -optc-Winline
45 WARNING_OPTS += -optc-Waggregate-return
46 WARNING_OPTS += -optc-Wpointer-arith
47 WARNING_OPTS += -optc-Wbad-function-cast
48 #WARNING_OPTS += -optc-Wcast-align
49 #WARNING_OPTS += -optc-Wnested-externs
50 #WARNING_OPTS += -optc-Wshadow
51 #WARNING_OPTS += -optc-Wcast-qual
52 #WARNING_OPTS += -optc-Wno-unused 
53 #WARNING_OPTS += -optc-Wredundant-decls 
54 #WARNING_OPTS += -optc-Wconversion
55
56 SRC_HC_OPTS += -I../includes -I. -Igum $(WARNING_OPTS) $(GhcRtsHcOpts) -optc-DCOMPILING_RTS
57 SRC_CC_OPTS = $(GhcRtsCcOpts)
58
59 ifneq "$(way)" "dll"
60 SRC_HC_OPTS += -static
61 endif
62
63 ifeq "$(way)" "mp"
64 SRC_HC_OPTS += -I$$PVM_ROOT/include
65 endif
66
67 C_SRCS = $(SRCS_RTS_C) $(SRCS_RTS_HC) # $(SRCS_RTS_S)???
68
69 SRC_MKDEPENDC_OPTS += -I. -I../includes
70
71 #-----------------------------------------------------------------------------
72 #
73 # Compiling the individual files
74 #
75 # Rules for building various types of objects from C files,
76 # override the default suffix rule here, as we want to use
77 # ../driver/ghc (a better C compiler :-) to compile the
78 # different RTS pieces
79 #
80 CC=$(HC) $(HC_OPTS) $($*_HC_OPTS)
81
82 # prevent this value from leaking into the GMP makefile
83 unexport CC
84
85 # -----------------------------------------------------------------------------
86 #
87 #  Building DLLs is only supported on mingw32 at the moment.
88
89 ifeq "$(way)" "dll"
90 DLL_NAME          = HSrts.dll
91 SRC_BLD_DLL_OPTS += --def HSrts.def -lwinmm -lHS_imp_stub -lgmp -L. -Lgmp
92
93 #
94 # Need an import library containing the symbols the RTS uses from the Prelude.
95 # So, to avoid bootstrapping trouble, we build one containing just the syms
96 # we need. Weirdly named to avoid clashing later on when compiling the contents
97 # of ghc/lib/..
98 #
99 # Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
100 # below will need to be updated as well.
101
102 $(DLL_NAME) :: libHS_imp_stub.a
103
104 libHS_imp_stub.a :
105         dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSprel.dll
106
107 # It's not included in the DLL, but we need to compile it up separately.
108 all :: Main.dll_o
109
110 endif
111
112 # -----------------------------------------------------------------------------
113 # Compile GMP only if we don't have it already
114 #
115 # We use GMP's own configuration stuff, because it's all rather hairy
116 # and not worth re-implementing in our Makefile framework.
117
118 ifneq "$(HaveLibGmp)" "YES"
119 boot ::
120         cd gmp && ./configure
121
122 all :: gmp/libgmp.a
123
124 install :: gmp/libgmp.a
125
126 clean ::
127         $(MAKE) -C gmp MAKEFLAGS= clean
128
129 ifeq "$(way)" ""
130 INSTALL_LIBS += gmp/libgmp.a
131 endif
132
133 gmp/libgmp.a ::
134         $(MAKE) -C gmp MAKEFLAGS=
135 endif
136
137 #-----------------------------------------------------------------------------
138 #
139 # Building the GUM SysMan
140 #
141
142 ifeq "$(way)" "mp"
143 all :: gum/SysMan
144
145 ifdef solaris2_TARGET_OS
146 __socket_libs = -lsocket -lnsl
147 else
148 __socket_libs =
149 endif
150
151 gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o 
152         $(RM) $@
153         gcc -o $@ gum/SysMan.mp_o gum/LLComms.mp_o -L$$PVM_ROOT/lib/$$PVM_ARCH -lgpvm3 -lpvm3 $(__socket_libs)
154
155 CLEAN_FILES  += gum/SysMan.mp_o gum/SysMan
156 INSTALL_LIBEXECS += gum/SysMan
157 endif
158
159 #-----------------------------------------------------------------------------
160 #
161 # Files to install
162 #
163 # Just libHSrts is installed uniformly across ways
164 #
165 INSTALL_LIBS += $(LIBRARY)
166
167 include $(TOP)/mk/target.mk
168