[project @ 1999-04-27 09:37:04 by simonm]
[ghc-hetmet.git] / ghc / rts / Makefile
1 #-----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.8 1999/04/27 09:37:04 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 #  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 DLLWRAP = dllwrap
60
61 ifeq "$(way)" "mp"
62 SRC_HC_OPTS += -I$$PVM_ROOT/include
63 endif
64
65 C_SRCS = $(SRCS_RTS_C) $(SRCS_RTS_HC) # $(SRCS_RTS_S)???
66
67 SRC_MKDEPENDC_OPTS += -I. -I../includes
68
69 #-----------------------------------------------------------------------------
70 #
71 # Compiling the individual files
72 #
73 # Rules for building various types of objects from C files,
74 # override the default suffix rule here, as we want to use
75 # ../driver/ghc (a better C compiler :-) to compile the
76 # different RTS pieces
77 #
78 CC=$(HC) $(HC_OPTS) $($*_HC_OPTS)
79
80 # prevent this value from leaking into the GMP makefile
81 unexport CC
82
83 # -----------------------------------------------------------------------------
84 #
85 #  Building DLLs is only supported on mingw32 at the moment.
86
87 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
88 dll ::
89         $(CP) -f libHSrts.a libHSrts_dll.a
90         ar d libHSrts_dll.a Main.o
91         $(DLLWRAP) -mno-cygwin --target=i386-mingw32 --export-all --output-lib libHSrts_imp.a --def HSrts.def -o HSrts.dll libHSrts_dll.a -lwinmm -lHS -lgmp -L. -Lgmp
92 endif
93 # -----------------------------------------------------------------------------
94 # Compile GMP only if we don't have it already
95 #
96 # We use GMP's own configuration stuff, because it's all rather hairy
97 # and not worth re-implementing in our Makefile framework.
98
99 ifneq "$(HaveLibGmp)" "YES"
100 boot ::
101         cd gmp && ./configure
102
103 all :: gmp/libgmp.a
104
105 install :: gmp/libgmp.a
106
107 clean ::
108         $(MAKE) -C gmp MAKEFLAGS= clean
109
110 ifeq "$(way)" ""
111 INSTALL_LIBS += gmp/libgmp.a
112 endif
113
114 gmp/libgmp.a ::
115         $(MAKE) -C gmp MAKEFLAGS=
116 endif
117
118 #-----------------------------------------------------------------------------
119 #
120 # Building the GUM SysMan
121 #
122
123 ifeq "$(way)" "mp"
124 all :: gum/SysMan
125
126 ifdef solaris2_TARGET_OS
127 __socket_libs = -lsocket -lnsl
128 else
129 __socket_libs =
130 endif
131
132 gum/SysMan : gum/SysMan.mp_o gum/LLComms.mp_o 
133         $(RM) $@
134         gcc -o $@ gum/SysMan.mp_o gum/LLComms.mp_o -L$$PVM_ROOT/lib/$$PVM_ARCH -lgpvm3 -lpvm3 $(__socket_libs)
135
136 CLEAN_FILES  += gum/SysMan.mp_o gum/SysMan
137 INSTALL_LIBEXECS += gum/SysMan
138 endif
139
140 #-----------------------------------------------------------------------------
141 #
142 # Files to install
143 #
144 # Just libHSrts is installed uniformly across ways
145 #
146 INSTALL_LIBS += $(LIBRARY)
147
148 include $(TOP)/mk/target.mk
149