Makefile 7.52 KB
Newer Older
1
#-----------------------------------------------------------------------------
2
#
3 4 5
#  This is the Makefile for the runtime-system stuff.
#  This stuff is written in C (and cannot be written in Haskell).
#
6 7 8 9 10
#  .c  files are vanilla C,
#  .hc files are "Haskellized-C", compiled using the C compiler and
#      (possibly) the assembly-mangler.  The GHC driver script
#      knows how to compile this stuff.
#
11 12 13 14
#  Other sorta independent, compile-once subdirs are:
#	gmp		-- GNU multi-precision library (for Integer)

#-----------------------------------------------------------------------------
15
# Preamble
16 17 18

TOP=..

19 20 21 22
# Set UseGhcForCc: this causes the fptools build system to use a different
# set of suffix rules for compiling C code, using $(HC) rather than $(CC)
# and prepending "-optc" to $(CC_OPTS).  NB. must be done before including
# boilerplate.mk below.
sof's avatar
sof committed
23
UseGhcForCc = $(shell if (test "x$(BootingFromHc)" = "xYES"); then echo NO; else echo YES; fi)
24

25 26
include $(TOP)/mk/boilerplate.mk

27 28
HC=$(GHC_INPLACE)

29 30
WAYS=$(GhcLibWays)

31 32 33
PACKAGE = rts

# Tells the build system not to add various Haskellish options to $(SRC_HC_OPTS)
sof's avatar
sof committed
34
NON_HS_PACKAGE = YES
35

36 37
# grab sources from these subdirectories
ALL_DIRS = hooks parallel
38

sof's avatar
sof committed
39 40
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
ALL_DIRS += win32
sof's avatar
sof committed
41
EXCLUDED_SRCS += Itimer.c Select.c Signals.c
sof's avatar
sof committed
42 43
endif

44
ifneq "$(DLLized)" "YES"
45
EXCLUDED_SRCS += RtsDllMain.c
sof's avatar
sof committed
46
else
47
EXCLUDED_SRCS += Main.c
sof's avatar
sof committed
48 49
endif

50 51 52 53
EXCLUDED_SRCS += parallel/SysMan.c

# The build system doesn't give us these
HC_SRCS = $(filter %.hc, $(SRCS))
54
HC_OBJS = $(patsubst %.hc,%.$(way_)o, $(HC_SRCS))
55

56 57
CLEAN_FILES += $(HC_OBJS)

58
# Override the default $(LIBOBJS) (defaults to $(HS_OBJS))
59 60 61
LIBOBJS = $(C_OBJS) $(HC_OBJS)

SplitObjs=NO
62

63 64 65
#-----------------------------------------------------------------------------
# Flags for compiling RTS .c and .hc files

66 67 68
# gcc provides lots of useful warnings if you ask it.
# This is a pretty good list to start with - use a # to comment out
# any you don't like.
69 70 71 72 73 74 75 76 77
WARNING_OPTS += -Wall 
WARNING_OPTS += -W
WARNING_OPTS += -Wstrict-prototypes 
WARNING_OPTS += -Wmissing-prototypes 
WARNING_OPTS += -Wmissing-declarations
WARNING_OPTS += -Winline
WARNING_OPTS += -Waggregate-return
#WARNING_OPTS += -Wpointer-arith
WARNING_OPTS += -Wbad-function-cast
78
#WARNING_OPTS += -Wcast-align
79 80 81 82 83 84 85
#WARNING_OPTS += -Wnested-externs
#WARNING_OPTS += -Wshadow
#WARNING_OPTS += -Wcast-qual
#WARNING_OPTS += -Wno-unused 
#WARNING_OPTS += -Wredundant-decls 
#WARNING_OPTS += -Wconversion

sof's avatar
sof committed
86 87 88
STANDARD_OPTS += -I../includes -I. -Iparallel
# COMPILING_RTS is only used when building Win32 DLL support.
STANDARD_OPTS += -DCOMPILING_RTS
sof's avatar
sof committed
89

sof's avatar
sof committed
90 91 92 93
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
STANDARD_OPTS += -Iwin32
endif

94 95 96 97
# HC_OPTS is included in both .c and .hc compilations, whereas CC_OPTS is
# only included in .c compilations.  HC_OPTS included the WAY_* opts, which
# must be included in both types of compilations.

98
SRC_CC_OPTS += $(WARNING_OPTS)
sof's avatar
sof committed
99
SRC_CC_OPTS += $(STANDARD_OPTS)
100

101 102
SRC_CC_OPTS += $(GhcRtsCcOpts)
SRC_HC_OPTS += $(GhcRtsHcOpts)
sof's avatar
sof committed
103

104
ifneq "$(DLLized)" "YES"
105
SRC_HC_OPTS += -static
sof's avatar
sof committed
106
endif
107
# SRC_HC_OPTS += -fPIC
108 109 110 111 112

ifeq "$(way)" "mp"
SRC_HC_OPTS += -I$$PVM_ROOT/include
endif

113 114 115
ifeq "$(BootingFromHc)" "YES"
# use the normal $(CC) when booting from .hc files
SRC_CC_OPTS += $(HC_OPTS)
sof's avatar
sof committed
116 117
endif

sof's avatar
sof committed
118 119 120 121 122
# Currently, you only get 'threads support' in the normal
# way.
ifeq "$(GhcRtsThreaded)" "YES"
ifeq "$(way)" ""
SRC_CC_OPTS += -DTHREADED_RTS
sof's avatar
sof committed
123
PACKAGE_CPP_OPTS += -DTHREADED_RTS
sof's avatar
sof committed
124 125 126
endif
endif

sof's avatar
sof committed
127
# If -DDEBUG is in effect, adjust package conf accordingly..
128 129 130 131 132 133
ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
PACKAGE_CPP_OPTS += -DDEBUG
endif

ifeq "$(HaveLibMingwEx)" "YES"
PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
sof's avatar
sof committed
134 135
endif

136 137 138 139 140 141
#-----------------------------------------------------------------------------
# Include the Front panel code?

# we need GTK+ for the front panel
ifneq "$(GTK_CONFIG)" ""
ifeq "$(GhcRtsWithFrontPanel)" "YES"
142
SRC_HC_OPTS 		+= `$(GTK_CONFIG) --cflags` -optc-DRTS_GTK_FRONTPANEL
143
VisCallbacks_CC_OPTS 	+= -Wno-unused
144 145 146 147 148 149
else # GhcRtsWithFrontPanel
EXCLUDED_SRCS		+= $(wildcard Vis*.c)
endif
else # GTK_CONFIG
EXCLUDED_SRCS		+= $(wildcard Vis*.c)
endif
150 151

#-----------------------------------------------------------------------------
152
# make depend setup
153

154
MKDEPENDC_SRCS     = $(C_SRCS) $(HC_SRCS)
155 156
SRC_MKDEPENDC_OPTS += -I. -I../includes

157 158 159 160 161 162 163 164 165 166 167 168 169 170
# -----------------------------------------------------------------------------
# The auto-generated apply code

AUTO_APPLY = AutoApply.hc

gen_apply : GenApply.hs
	$(GHC) -o $@ -I$(GHC_INCLUDE_DIR) GenApply.hs 

$(AUTO_APPLY): $(GHC_GENAPPLY)
	@$(RM) $@
	$(GHC_GENAPPLY) >$@

EXTRA_SRCS += $(AUTO_APPLY)

171 172
CLEAN_FILES += $(AUTO_APPLY)

sof's avatar
sof committed
173 174 175
# -----------------------------------------------------------------------------
#
#  Building DLLs is only supported on mingw32 at the moment.
176 177 178 179 180 181
#
ifeq "$(DLLized)" "YES"
SRC_BLD_DLL_OPTS += -lHS_imp_stub -lgmp_imp

# It's not included in the DLL, but we need to compile it up separately.
all :: Main.dll_o
sof's avatar
sof committed
182

sof's avatar
sof committed
183 184 185 186 187 188 189
# Need an import library containing the symbols the RTS uses from the Prelude.
# So, to avoid bootstrapping trouble, we build one containing just the syms
# we need. Weirdly named to avoid clashing later on when compiling the contents
# of ghc/lib/..
#
# Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
# below will need to be updated as well.
sof's avatar
sof committed
190

191
$(DLL_PEN)/HSrts$(_way).dll :: libHS_imp_stub.a
sof's avatar
sof committed
192

sof's avatar
sof committed
193
libHS_imp_stub.a :
rrt's avatar
rrt committed
194
	dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSstd.dll
sof's avatar
sof committed
195

sof's avatar
sof committed
196
endif
sof's avatar
sof committed
197

198 199 200 201 202 203 204
# -----------------------------------------------------------------------------
# Compile GMP only if we don't have it already
#
# We use GMP's own configuration stuff, because it's all rather hairy
# and not worth re-implementing in our Makefile framework.

ifneq "$(HaveLibGmp)" "YES"
205
ifneq "$(HaveFrameworkHaskellSupport)" "YES"
rrt's avatar
rrt committed
206 207
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
boot ::
208 209
	cd gmp && ./configure --enable-shared=no \
		--host=`echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g'`
rrt's avatar
rrt committed
210
else
rrt's avatar
rrt committed
211 212
# Pass --target to configure of GMP, so that building for mingwin under
# cygwin works properly (when the host is not the same as the target)
213
boot ::
214
	cd gmp && CC=$(WhatGccIsCalled) ./configure --enable-shared=no --target=$(HOSTPLATFORM)
rrt's avatar
rrt committed
215
endif
216

217
# Slight cheatage here to pass host as target, but x-compilation isn't supported by ghc.
218

219 220
all :: gmp/libgmp.a

221
ifeq "$(DLLized)" "YES"
rrt's avatar
rrt committed
222
all :: $(DLL_PEN)/gmp.dll
rrt's avatar
rrt committed
223

rrt's avatar
rrt committed
224
$(DLL_PEN)/gmp.dll:
225
	$(MAKE) -C gmp gmp.dll
rrt's avatar
rrt committed
226
	$(MV) gmp/gmp.dll $(DLL_PEN)
rrt's avatar
rrt committed
227 228
endif

229 230
install :: gmp/libgmp.a

ken's avatar
ken committed
231
ifeq "$(way)" ""
232
clean distclean maintainer-clean ::
ken's avatar
ken committed
233
	-$(MAKE) -C gmp MAKEFLAGS= $@
234

235 236
INSTALL_LIBS += gmp/libgmp.a
endif
237
endif
238 239 240

gmp/libgmp.a ::
	$(MAKE) -C gmp MAKEFLAGS=
241
	@$(CP) gmp/.libs/libgmp.a gmp
sof's avatar
sof committed
242
	@$(RANLIB) gmp/libgmp.a
243 244
endif

245 246
CLEAN_FILES += gmp/libgmp.a

247 248 249 250 251 252
#-----------------------------------------------------------------------------
#
# Building the GUM SysMan
#

ifeq "$(way)" "mp"
253
all :: parallel/SysMan
254 255 256 257 258 259 260

ifdef solaris2_TARGET_OS
__socket_libs = -lsocket -lnsl
else
__socket_libs =
endif

261
parallel/SysMan : parallel/SysMan.mp_o parallel/LLComms.mp_o RtsUtils.mp_o RtsFlags.mp_o
262
	$(RM) $@
263
	gcc -o $@ parallel/SysMan.mp_o parallel/LLComms.mp_o -L$$PVM_ROOT/lib/$$PVM_ARCH -lgpvm3 -lpvm3 $(__socket_libs)
264

265 266
CLEAN_FILES  += parallel/SysMan.mp_o parallel/SysMan
INSTALL_LIBEXECS += parallel/SysMan
267 268 269 270 271 272 273 274 275
endif

#-----------------------------------------------------------------------------
#
# Files to install
#
# Just libHSrts is installed uniformly across ways
#
INSTALL_LIBS += $(LIBRARY)
276
ifeq "$(DLLized)" "YES"
sof's avatar
sof committed
277
INSTALL_PROGS += $(DLL_NAME) gmp/gmp.dll
278
INSTALL_LIBS += $(patsubst %.a,%_imp.a,$(LIBARY))
sof's avatar
sof committed
279
INSTALL_LIBS += gmp/libgmp_imp.a Main.dll_o
sof's avatar
sof committed
280
endif
281 282

include $(TOP)/mk/target.mk