Makefile 20.2 KB
Newer Older
1
# -----------------------------------------------------------------------------
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Main ghc/compiler Makefile

# Targets:
#
#	all	builds stage1 compiler
#
#	boot stage=N   generate build dirs and dependencies for stage N.
#		       NB. Must be done before 'make stageN'.
#		       NB. Cannot 'make boot stage=2' until stage1 has
#		           been built (similarly for stage3).
#
#	stage1  (or stage=1) builds stage1 compiler
#	stage2  (or stage=2) builds stage2 compiler
#	stage3  (or stage=3) builds stage3 compiler
#
17

18
TOP = ..
19
20

# Use GHC for compiling C bits (NB. must be before boilerplate include)
21
# NB. this requires BootingFromHc to be set on the make command line!
22
23
24
25
26
#
ifneq "$(BootingFromHc)" "YES"
UseGhcForCc = YES
endif

27
include $(TOP)/mk/boilerplate.mk
28

29
30
31
#-----------------------------------------------------------------------------
# Counting source code lines

32
33
34
35
USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
count :
	./count_lines $(USER_SRCS)

36
#-----------------------------------------------------------------------------
37
# Building ghc different ways (default is just `normal' sequential)
38

39
WAYS=$(GhcCompilerWays)
40

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -----------------------------------------------------------------------------
# Bootstrapping

# The stage1/stage2/stage3 business is quite delicate.  Here's how it works:
# 
#  - the variable $(stage) holds the current stage number.  To build a 
#    particular stage, you say 'make stage=N' where N is 1, 2, or 3.
#    N defaults to 1.
#
#  - for stage N, object files and .hi files are placed inside 
#    the directory stageN, in subdirectories as per the sources.
#
#  - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
#    the .hi-boot file must reside in the same place as the .hi file.
#
#  - we use explicit -o and -ohi options to direct the output from C & 
#    Haskell compilations.
#
#  - we generate a different .depend file for each build.  They need to be
#    different, because each stage might include different files: stage1
#    might not include GHCi, for example.  For each stage, a normal .depend
#    file is generated, and then post-processed to add the correct stageN/
#    prefix to each object and .hi filename.  The resulting .depend file
#    is named .depend-$(stage).  See the end of this Makefile for details.
#
#  - normal implicit rules don't work any more, because they're of the form
#
#        %.o : %.hs 
#
#    whereas we really need 
#
#	 stageN/%.o : %.hs
#
#    so suffix.mk now defines the appropriate suffix rules when
#    $(odir) is set to a non-empty value.  Here we set $(odir) to
#    stage1, stage2, or stage3.
#
#  There are other plausible designs that might work, but each has different
#  problems:
#
#  - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
#    anyway -odir puts all the objects in one directory (strips off the
#    subdirectory part), which eventually forces us to use VPATH to find
#    the sources.  I have a really bad feeling about VPATH.
#
#  - invoke make in the stageN subdirectory.  This probably requires VPATH
#    too.
#
#  - create a link tree.  The problem with requiring link trees is that 
#    Windows doesn't support symbolic links.

boot ::
	$(MKDIRHIER) stage$(stage)
	for i in $(ALL_DIRS); do \
	    $(MKDIRHIER) stage$(stage)/$$i; \
	done
97
98
99
100
101
102
103
104
105
106
107
# On Windows, we can't use symbolic links for the -hi-boot files
# because GHC itself is a Mingw program and does not understand
# symbolic links.  So we have to copy the files instead of link them.
# That means that if you modify a .hi-boot file in Windows, you
# have to to say 'make boot' again.
#
# PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
#     whereas 'cp foo baz' treats the two paths independently.
#     Hence the "../.." in the ln command line
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
	for i in */*hi-boot*; do \
sof's avatar
sof committed
108
	    cp -u -f $$i stage$(stage)/$$i; \
109
110
	done
else
111
	for i in */*hi-boot*; do \
112
	    $(LN_S) -f ../../$$i stage$(stage)/$$i || true ; \
113
	done
114
endif
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

ifeq "$(stage)" ""
stage=1
endif

ifeq "$(stage)" "1"
HC=$(GHC)
endif

ifeq "$(stage)" "2"
HC=$(GHC_STAGE1)
endif

ifeq "$(stage)" "3"
HC=$(GHC_STAGE2)
endif

132
stage1 ::
133
134
	$(MAKE) stage=1

135
stage2 ::
136
137
	$(MAKE) stage=2

138
stage3 ::
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
	$(MAKE) stage=3

odir=stage$(stage)

SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))

HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))

CLEAN_FILES += $(odir)/*/*.hi

ifeq "$(stage)" "1"
mostlyclean clean distclean maintainer-clean ::
	$(MAKE) $@ stage=2
	$(MAKE) $@ stage=3
endif

156
# -----------------------------------------------------------------------------
157
#		Set HS_PROG
158

sof's avatar
sof committed
159
# Note: there have been reports of people running up against the ARG_MAX limit
160
# when linking ghc with all its constituent object files. The likely source of 
sof's avatar
sof committed
161
# the problem is that the environment is a bit too big, so a workaround could
rrt's avatar
rrt committed
162
# be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
sof's avatar
sof committed
163
164
# equivalent of `env' if it doesn't exist locally).
#
rrt's avatar
rrt committed
165
ifneq "$(way)" "dll"
sof's avatar
sof committed
166
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
167
HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
rrt's avatar
rrt committed
168
else
169
HS_PROG=$(odir)/ghc$(_way)
rrt's avatar
rrt committed
170
171
endif
else
172
HS_PROG=$(odir)/ghc-$(ProjectVersion)
rrt's avatar
rrt committed
173
endif
174

175
176
# -----------------------------------------------------------------------------
# Create compiler configuration
177
178
179
#
# The 'echo' commands simply spit the values of various make variables
# into Config.hs, whence they can be compiled and used by GHC itself
180

181
CONFIG_HS 	= main/Config.hs
182
183
184
185
boot :: $(CONFIG_HS)

$(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
	@$(RM) -f $(CONFIG_HS)
186
	@echo "Creating $(CONFIG_HS) ... "
187
188
189
190
	@echo "module Config where" >>$(CONFIG_HS)
	@echo "cProjectName          = \"$(ProjectName)\"" >> $(CONFIG_HS)
	@echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
	@echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
191
	@echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
192
	@echo "cBooterVersion        = \"$(GhcVersion)\"" >> $(CONFIG_HS)
193
194
195
196
	@echo "cHscIfaceFileVersion  = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
	@echo "cHOSTPLATFORM         = \"$(HOSTPLATFORM)\"" >> $(CONFIG_HS)
	@echo "cTARGETPLATFORM       = \"$(TARGETPLATFORM)\"" >> $(CONFIG_HS)
	@echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
197
	@echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
198
	@echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
199
	@echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
200
	@echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
201
	@echo "cMKDLL                = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
202
203
204
205
206
207
208
209
210
211
212
213
	@echo "cPROJECT_DIR          = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
	@echo "cGHC_DRIVER_DIR_REL   = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
	@echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
	@echo "cGHC_TOUCHY_DIR_REL   = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
	@echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
	@echo "cGHC_UNLIT_DIR_REL    = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
	@echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
	@echo "cGHC_MANGLER_DIR_REL  = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
	@echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
	@echo "cGHC_SPLIT_DIR_REL    = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
	@echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
	@echo "cGHC_SYSMAN_DIR_REL   = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
214
215
	@echo "cGHC_CP               = \"$(GHC_CP)\"" >> $(CONFIG_HS)
	@echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
rrt's avatar
rrt committed
216
217
218
219
ifeq ($(GhcWithIlx),YES)
	@echo "cILX2IL               = \"$(ILX2IL)\"" >> $(CONFIG_HS)
	@echo "cILASM                = \"$(ILASM)\"" >> $(CONFIG_HS)
endif
220
221
222
223
224
225
226
227
228
	@echo "cEnableWin32DLLs      = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
	@echo "cCONTEXT_DIFF         = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
	@echo "cHaveLibGmp           = \"$(HaveLibGmp)\"" >> $(CONFIG_HS)
	@echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
	@echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
	@echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
	@echo done.

CLEAN_FILES += $(CONFIG_HS)
229
230

# -----------------------------------------------------------------------------
231
# Set SRCS etc.
232
#
233
# First figure out ALL_DIRS, the source sub-directories
234

235
ALL_DIRS = \
236
237
  utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
  specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
238
  profiling parser cprAnalysis compMan ndpFlatten
239

240
241
242
# Make sure we include Config.hs even if it doesn't exist yet...
ALL_SRCS += $(CONFIG_HS)

243
244
245
# HsGeneric.hs is not used just now
EXCLUDED_SRCS += hsSyn/HsGeneric.hs

246
ifeq ($(GhcWithNativeCodeGen),YES)
247
ALL_DIRS += nativeGen
248
249
else
SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
rrt's avatar
rrt committed
250
251
endif

252
ifeq ($(GhcWithIlx),YES)
253
ALL_DIRS += ilxGen
254
255
SRC_HC_OPTS += -DILX
endif
256

257
ifeq ($(GhcWithJavaGen),YES)
258
ALL_DIRS += javaGen
259
260
261
SRC_HC_OPTS += -DJAVA
endif

262
263
ifeq "$(BootingFromHc)" "YES"
# HC files are always from a self-booted compiler
264
bootstrapped = YES
sof's avatar
sof committed
265
compiling_with_4xx=NO
266
else
267
268
269
270
ifneq "$(findstring $(stage), 2 3)" ""
bootstrapped = YES
compiling_with_4xx = NO
else
271
bootstrapped = $(shell if (test $(GhcCanonVersion) -ge $(ProjectVersionInt) -a $(GhcPatchLevel) -ge $(ProjectPatchLevel)); then echo YES; else echo NO; fi)
sof's avatar
sof committed
272
compiling_with_4xx = $(shell if (test $(GhcCanonVersion) -lt 500); then echo YES; else echo NO; fi)
273
endif
274
endif
275

276
# Only include GHCi if we're bootstrapping with at least version 411
277
278
ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
# Yes, include the interepreter, readline, and Template Haskell extensions
279
SRC_HC_OPTS += -DGHCI -package haskell-src
280
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
281
282
283
284
SRC_HC_OPTS += -package unix
ifeq "$(GhcLibsWithReadline)" "YES"
SRC_HC_OPTS += -package readline 
endif
285
endif
286
ALL_DIRS += ghci
287
288
289
290
else
# No interpreter, so exclude Template Haskell modules
EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
endif 
291

292
293
# There are some C files to include in HS_PROG, so add these to HS_OBJS
HS_OBJS	 += $(C_OBJS)
sof's avatar
sof committed
294

295
296
# -----------------------------------------------
# mkdependC stuff
sof's avatar
sof committed
297
298
299
300
#
# Big Fudge to get around inherent problem that Makefile setup
# has got with 'mkdependC'.
# 
301
302
303
304
305
SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)

# XXX not really correct, hschooks.c actually gets include files like
# RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
306

307
# -----------------------------------------------------------------------------
308
# 		Haskell compilations
309

310
SRC_HC_OPTS += \
311
  -cpp -fglasgow-exts -Rghc-timing \
312
  -I. -IcodeGen -InativeGen -Iparser
sof's avatar
sof committed
313

314
315
316
317
# Omitted: 	-I$(GHC_INCLUDE_DIR)
# We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS, 
# to avoid the use of an explicit path in GHC source files
#	(include "../includes/config.h"
318
319
320
321
322
# But alas GHC 4.08 (and others for all I know) uses this very
# same include path when compiling the .hc files it generates.
# Disaster!  Then the hc file sees the GHC 5.02 (or whatever)
# include files.   For the moment we've reverted to using
# an explicit path in the .hs sources
sof's avatar
sof committed
323
324
325
326
327
#
# For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
# when generating dependencies. (=> it gets passed onto mkdependHS,
# which needs it).
SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
328

329
330
331
# When bootstrapped, we don't make use of *any* packages
# (except possibly readline if GHCi is enabled, see above)
ifneq "$(bootstrapped)" "YES"
sof's avatar
sof committed
332
ifneq "$(mingw32_HOST_OS)" "1"
333
SRC_HC_OPTS += -package concurrent -package posix -package util
334
else
335
SRC_HC_OPTS += -package concurrent -package util
336
endif
337
endif
338

339
SRC_CC_OPTS += -Iparser -I. -O
340
SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
341
SRC_HC_OPTS += -H16M
342

343
344
345
346
ifeq "$(BootingFromHc)" "YES"
SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
endif

347
348
349
350
# 	Special flags for particular modules
#	The standard suffix rule for compiling a Haskell file
#	adds these flags to the command line

351
prelude/PrimOp_HC_OPTS 		= -no-recomp -H80m
352
353
354

# because the NCG can't handle the 64-bit math in here
prelude/PrelRules_HC_OPTS	= -fvia-C
355

356
main/ParsePkgConf_HC_OPTS	+= -fno-warn-incomplete-patterns
sof's avatar
sof committed
357
358
359
# Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
# primops on all platforms.
parser/Parser_HC_OPTS 		+= -Onot -fno-warn-incomplete-patterns -fvia-C
360
361
362

# The latest GHC version doesn't have a -K option yet, and it doesn't
# seem to be necessary anymore for the modules below.
sof's avatar
sof committed
363
ifeq "$(compiling_with_4xx)" "YES"
364
365
parser/Parser_HC_OPTS 		+= -K2m
endif
366

sof's avatar
sof committed
367
ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
368
rename/RnMonad_HC_OPTS 		=  -O2 -O2-for-C
sof's avatar
sof committed
369
endif
370

sof's avatar
sof committed
371
utils/StringBuffer_HC_OPTS	= -fvia-C -fno-prune-tydecls
372
utils/Digraph_HC_OPTS		= -fglasgow-exts 
sof's avatar
sof committed
373

374
375
376
377
ifeq "$(bootstrapped)" "YES"
utils/Binary_HC_OPTS		= -funbox-strict-fields
endif

378
379
380
381
382
# 4.08.2's NCG can't cope with Binary
ifeq "$(compiling_with_4xx)" "YES"
utils/Binary_HC_OPTS		+= -fvia-C
endif

383
# ByteCodeItbls uses primops that the NCG doesn't support yet.
384
385
386
387
388
389
390
391
ghci/ByteCodeItbls_HC_OPTS	+= -fvia-C
ghci/ByteCodeLink_HC_OPTS	+= -fvia-C -monly-3-regs

# BinIface and Binary take ages to both compile and run if you don's use -O
main/BinIface_HC_OPTS		+= -O
utils/Binary_HC_OPTS		+= -O
utils/FastMutInt_HC_OPTS	+= -O

392

393
394
395
396
397
398
399
400
401
402
# CSE interacts badly with top-level IORefs (reportedly in DriverState and
# DriverMkDepend), causing some of them to be commoned up.  We have a fix for
# this in 5.00+, but earlier versions of the compiler will need CSE turned off.
# To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
compMan/CompManager_HC_OPTS	= -fno-cse
ghci/InteractiveUI_HC_OPTS	= -fno-cse
main/CmdLineOpts_HC_OPTS	= -fno-cse
main/DriverFlags_HC_OPTS	= -fno-cse
main/DriverMkDepend_HC_OPTS	= -fno-cse
main/DriverPipeline_HC_OPTS	= -fno-cse
403
main/DriverState_HC_OPTS	= -fno-cse
404
405
main/DriverUtil_HC_OPTS		= -fno-cse
main/Finder_HC_OPTS		= -fno-cse
406
main/SysTools_HC_OPTS		= -fno-cse
407

408
409
410
# The #include is vital for the via-C route, else the C
# compiler doesn't realise that the stcall foreign imports are indeed
# stdcall, and doesn't generate the Foo@8 name for them
sof's avatar
sof committed
411
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
sof's avatar
sof committed
412
main/SysTools_HC_OPTS		+= '-\#include <windows.h>' '-\#include <process.h>'
413
414
endif

415
416
417
# Required due to use of Concurrent.myThreadId
utils/Panic_HC_OPTS += -fvia-C

418
419
420
421
# ghc_strlen percolates through so many modules that it is easier to get its
# prototype via a global option instead of a myriad of per-file OPTIONS
SRC_HC_OPTS += '-\#include "hschooks.h"'

422
423
424
425
426
427
# ----------------------------------------------------------------------------
#		Generate supporting stuff for prelude/PrimOp.lhs 
#		from prelude/primops.txt

GENPOC=$(TOP)/utils/genprimopcode/genprimopcode

428
429
430
431
432
433
434
435
436
437
438
PRIMOP_BITS=primop-data-decl.hs-incl \
            primop-tag.hs-incl  \
            primop-list.hs-incl  \
            primop-has-side-effects.hs-incl  \
            primop-out-of-line.hs-incl  \
            primop-commutable.hs-incl  \
            primop-needs-wrapper.hs-incl  \
            primop-can-fail.hs-incl  \
            primop-strictness.hs-incl  \
            primop-primop-info.hs-incl

439
440
441
CLEAN_FILES += prelude/primops.txt
CLEAN_FILES += $(PRIMOP_BITS)

apt's avatar
apt committed
442
443
SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR) -traditional
SRC_CPP_OPTS += ${GhcCppOpts}
sof's avatar
sof committed
444

445
ifneq "$(BootingFromHc)" "YES"
sof's avatar
sof committed
446
prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
447
endif
448

449
ifneq "$(BootingFromHc)" "YES"
450
depend :: $(PRIMOP_BITS)
451
endif
452

ken's avatar
ken committed
453
primop-data-decl.hs-incl: prelude/primops.txt
454
	$(GENPOC) --data-decl          < $< > $@
ken's avatar
ken committed
455
primop-tag.hs-incl: prelude/primops.txt
456
	$(GENPOC) --primop-tag         < $< > $@
ken's avatar
ken committed
457
primop-list.hs-incl: prelude/primops.txt
458
	$(GENPOC) --primop-list        < $< > $@
ken's avatar
ken committed
459
primop-has-side-effects.hs-incl: prelude/primops.txt
460
	$(GENPOC) --has-side-effects   < $< > $@
ken's avatar
ken committed
461
primop-out-of-line.hs-incl: prelude/primops.txt
462
	$(GENPOC) --out-of-line        < $< > $@
ken's avatar
ken committed
463
primop-commutable.hs-incl: prelude/primops.txt
464
	$(GENPOC) --commutable         < $< > $@
ken's avatar
ken committed
465
primop-needs-wrapper.hs-incl: prelude/primops.txt
466
	$(GENPOC) --needs-wrapper      < $< > $@
ken's avatar
ken committed
467
primop-can-fail.hs-incl: prelude/primops.txt
468
	$(GENPOC) --can-fail           < $< > $@
ken's avatar
ken committed
469
primop-strictness.hs-incl: prelude/primops.txt
470
	$(GENPOC) --strictness         < $< > $@
ken's avatar
ken committed
471
primop-primop-info.hs-incl: prelude/primops.txt
472
	$(GENPOC) --primop-primop-info < $< > $@
473

474
475
476
477
478
# Usages aren't used any more; but the generator 
# can still generate them if we want them back
primop-usage.hs-incl: prelude/primops.txt
	$(GENPOC) --usage              < $< > $@

479

480

481
# ----------------------------------------------------------------------------
sof's avatar
sof committed
482
#		Parsers/lexers
483

484
SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS  $(GHC_HAPPY_OPTS)
485
486
487
488

#-----------------------------------------------------------------------------
# 		Linking

489
SRC_LD_OPTS += -no-link-chk 
490

491
492
493
# -----------------------------------------------------------------------------
# create ghc-inplace, a convenient way to run ghc from the build tree...

494
all :: $(odir)/ghc-inplace ghc-inplace
495

496
$(odir)/ghc-inplace : $(HS_PROG)
497
498
	@$(RM) $@
	echo '#!/bin/sh' >>$@
sof's avatar
sof committed
499
	echo exec $(FPTOOLS_TOP_ABS)/ghc/compiler/$(HS_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
500
501
	chmod 755 $@

502
ghc-inplace : stage1/ghc-inplace
503
	$(LN_S) -f $< $@
504
505

CLEAN_FILES += $(odir)/ghc-inplace ghc-inplace
506

507
508
509
#-----------------------------------------------------------------------------
# 		install

510
# We don't want ghc treated as an ordinary executable,
511
# but put it together with the libraries.
rrt's avatar
rrt committed
512
# Also don't want any interface files installed
513

514
515
DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)

sof's avatar
sof committed
516
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
517
INSTALL_LIBEXECS += $(HS_PROG)
rrt's avatar
rrt committed
518
519
520
else
INSTALL_PROGS += $(HS_PROG)
endif
521

522
523
524
# ----------------------------------------------------------------------------
# profiling.

525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
rename/RnBinds_HC_OPTS += -auto-all
rename/RnEnv_HC_OPTS += -auto-all
rename/RnExpr_HC_OPTS += -auto-all
rename/RnHiFiles_HC_OPTS += -auto-all
rename/RnHsSyn_HC_OPTS += -auto-all
rename/Rename_HC_OPTS += -auto-all
rename/RnIfaces_HC_OPTS += -auto-all
rename/RnNames_HC_OPTS += -auto-all
rename/RnSource_HC_OPTS += -auto-all
rename/RnTypes_HC_OPTS += -auto-all

typecheck/Inst_HC_OPTS += -auto-all
typecheck/TcBinds_HC_OPTS += -auto-all
typecheck/TcClassDcl_HC_OPTS += -auto-all
typecheck/TcDefaults_HC_OPTS += -auto-all
typecheck/TcDeriv_HC_OPTS += -auto-all
typecheck/TcEnv_HC_OPTS += -auto-all
typecheck/TcExpr_HC_OPTS += -auto-all
typecheck/TcForeign_HC_OPTS += -auto-all
typecheck/TcGenDeriv_HC_OPTS += -auto-all
typecheck/TcHsSyn_HC_OPTS += -auto-all
typecheck/TcIfaceSig_HC_OPTS += -auto-all
typecheck/TcInstDcls_HC_OPTS += -auto-all
typecheck/TcMatches_HC_OPTS += -auto-all
typecheck/TcMonoType_HC_OPTS += -auto-all
typecheck/TcMType_HC_OPTS += -auto-all
typecheck/TcPat_HC_OPTS += -auto-all
typecheck/TcRnDriver_HC_OPTS += -auto-all
#typecheck/TcRnMonad_HC_OPTS += -auto-all
#typecheck/TcRnTypes_HC_OPTS += -auto-all
typecheck/TcRules_HC_OPTS += -auto-all
typecheck/TcSimplify_HC_OPTS += -auto-all
typecheck/TcSplice_HC_OPTS += -auto-all
typecheck/TcTyClsDecls_HC_OPTS += -auto-all
typecheck/TcTyDecls_HC_OPTS += -auto-all
typecheck/TcType_HC_OPTS += -auto-all
typecheck/TcUnify_HC_OPTS += -auto-all

absCSyn/PprAbsC_HC_OPTS += -auto-all
564

565
566
567
#-----------------------------------------------------------------------------
# 		clean

568
MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
569
570
571
572

#-----------------------------------------------------------------------------
# 		Include target-rule boilerplate

573
574
575
576
# Don't use the default MKDEPENDHS stuff... we'll do our own, below
MKDEPENDHS_SRCS =
MKDEPENDC_SRCS =

577
include $(TOP)/mk/target.mk
578
579
580
581

# -----------------------------------------------------------------------------
# Dependencies

582
MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
583
584
585
586

MKDEPENDHS=$(HC)

# Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
587
depend :: $(HS_SRCS) $(C_SRCS)
588
589
	$(MKDEPENDHS) -M -optdep-f -optdep.depend-BASE $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) $(HS_SRCS)
	$(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
590
591
	$(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
# The binmode stuff tells perl not to add stupid ^M's to the output
592
593

-include .depend-$(stage)