[project @ 2002-11-13 12:21:08 by simonmar]
[ghc-hetmet.git] / ghc / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # Main ghc/compiler Makefile
3
4 # Targets:
5 #
6 #       all     builds stage1 compiler
7 #
8 #       boot stage=N   generate build dirs and dependencies for stage N.
9 #                      NB. Must be done before 'make stageN'.
10 #                      NB. Cannot 'make boot stage=2' until stage1 has
11 #                          been built (similarly for stage3).
12 #
13 #       stage1  (or stage=1) builds stage1 compiler
14 #       stage2  (or stage=2) builds stage2 compiler
15 #       stage3  (or stage=3) builds stage3 compiler
16 #
17
18 TOP = ..
19
20 # Use GHC for compiling C bits (NB. must be before boilerplate include)
21 #
22 ifneq "$(BootingFromHc)" "YES"
23 UseGhcForCc = YES
24 endif
25
26 include $(TOP)/mk/boilerplate.mk
27
28 #-----------------------------------------------------------------------------
29 # Counting source code lines
30
31 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
32 count :
33         ./count_lines $(USER_SRCS)
34
35 #-----------------------------------------------------------------------------
36 # Building ghc different ways (default is just `normal' sequential)
37
38 WAYS=$(GhcCompilerWays)
39
40 # -----------------------------------------------------------------------------
41 # Bootstrapping
42
43 # The stage1/stage2/stage3 business is quite delicate.  Here's how it works:
44
45 #  - the variable $(stage) holds the current stage number.  To build a 
46 #    particular stage, you say 'make stage=N' where N is 1, 2, or 3.
47 #    N defaults to 1.
48 #
49 #  - for stage N, object files and .hi files are placed inside 
50 #    the directory stageN, in subdirectories as per the sources.
51 #
52 #  - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
53 #    the .hi-boot file must reside in the same place as the .hi file.
54 #
55 #  - we use explicit -o and -ohi options to direct the output from C & 
56 #    Haskell compilations.
57 #
58 #  - we generate a different .depend file for each build.  They need to be
59 #    different, because each stage might include different files: stage1
60 #    might not include GHCi, for example.  For each stage, a normal .depend
61 #    file is generated, and then post-processed to add the correct stageN/
62 #    prefix to each object and .hi filename.  The resulting .depend file
63 #    is named .depend-$(stage).  See the end of this Makefile for details.
64 #
65 #  - normal implicit rules don't work any more, because they're of the form
66 #
67 #        %.o : %.hs 
68 #
69 #    whereas we really need 
70 #
71 #        stageN/%.o : %.hs
72 #
73 #    so suffix.mk now defines the appropriate suffix rules when
74 #    $(odir) is set to a non-empty value.  Here we set $(odir) to
75 #    stage1, stage2, or stage3.
76 #
77 #  There are other plausible designs that might work, but each has different
78 #  problems:
79 #
80 #  - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
81 #    anyway -odir puts all the objects in one directory (strips off the
82 #    subdirectory part), which eventually forces us to use VPATH to find
83 #    the sources.  I have a really bad feeling about VPATH.
84 #
85 #  - invoke make in the stageN subdirectory.  This probably requires VPATH
86 #    too.
87 #
88 #  - create a link tree.  The problem with requiring link trees is that 
89 #    Windows doesn't support symbolic links.
90
91 boot ::
92         $(MKDIRHIER) stage$(stage)
93         for i in $(ALL_DIRS); do \
94             $(MKDIRHIER) stage$(stage)/$$i; \
95         done
96         for i in */*hi-boot*; do \
97             $(LN_S) -f ../../$$i stage$(stage)/$$i; \
98         done
99
100 ifeq "$(stage)" ""
101 stage=1
102 endif
103
104 ifeq "$(stage)" "1"
105 HC=$(GHC)
106 endif
107
108 ifeq "$(stage)" "2"
109 HC=$(GHC_STAGE1)
110 endif
111
112 ifeq "$(stage)" "3"
113 HC=$(GHC_STAGE2)
114 endif
115
116 stage1 :
117         $(MAKE) stage=1
118
119 stage2 : 
120         $(MAKE) stage=2
121
122 stage3 : 
123         $(MAKE) stage=3
124
125 odir=stage$(stage)
126
127 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
128
129 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
130 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
131
132 CLEAN_FILES += $(odir)/*/*.hi
133
134 ifeq "$(stage)" "1"
135 mostlyclean clean distclean maintainer-clean ::
136         $(MAKE) $@ stage=2
137         $(MAKE) $@ stage=3
138 endif
139
140 # -----------------------------------------------------------------------------
141 #               Set HS_PROG
142
143 # Note: there have been reports of people running up against the ARG_MAX limit
144 # when linking ghc with all its constituent object files. The likely source of 
145 # the problem is that the environment is a bit too big, so a workaround could
146 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
147 # equivalent of `env' if it doesn't exist locally).
148 #
149 ifneq "$(way)" "dll"
150 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
151 HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
152 else
153 HS_PROG=$(odir)/ghc$(_way)
154 endif
155 else
156 HS_PROG=$(odir)/ghc-$(ProjectVersion)
157 endif
158
159 # -----------------------------------------------------------------------------
160 # Create compiler configuration
161 #
162 # The 'echo' commands simply spit the values of various make variables
163 # into Config.hs, whence they can be compiled and used by GHC itself
164
165 CONFIG_HS       = main/Config.hs
166 boot :: $(CONFIG_HS)
167
168 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
169         @$(RM) -f $(CONFIG_HS)
170         @echo -n "Creating $(CONFIG_HS) ... "
171         @echo "module Config where" >>$(CONFIG_HS)
172         @echo "cProjectName          = \"$(ProjectName)\"" >> $(CONFIG_HS)
173         @echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
174         @echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
175         @echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
176         @echo "cBooterVersion        = \"$(GhcVersion)\"" >> $(CONFIG_HS)
177         @echo "cHscIfaceFileVersion  = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
178         @echo "cHOSTPLATFORM         = \"$(HOSTPLATFORM)\"" >> $(CONFIG_HS)
179         @echo "cTARGETPLATFORM       = \"$(TARGETPLATFORM)\"" >> $(CONFIG_HS)
180         @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
181         @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
182         @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
183         @echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
184         @echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
185         @echo "cMKDLL                = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
186         @echo "cPROJECT_DIR          = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
187         @echo "cGHC_DRIVER_DIR_REL   = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
188         @echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
189         @echo "cGHC_TOUCHY_DIR_REL   = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
190         @echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
191         @echo "cGHC_UNLIT_DIR_REL    = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
192         @echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
193         @echo "cGHC_MANGLER_DIR_REL  = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
194         @echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
195         @echo "cGHC_SPLIT_DIR_REL    = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
196         @echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
197         @echo "cGHC_SYSMAN_DIR_REL   = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
198         @echo "cGHC_CP               = \"$(GHC_CP)\"" >> $(CONFIG_HS)
199         @echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
200 ifeq ($(GhcWithIlx),YES)
201         @echo "cILX2IL               = \"$(ILX2IL)\"" >> $(CONFIG_HS)
202         @echo "cILASM                = \"$(ILASM)\"" >> $(CONFIG_HS)
203 endif
204         @echo "cEnableWin32DLLs      = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
205         @echo "cCONTEXT_DIFF         = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
206         @echo "cHaveLibGmp           = \"$(HaveLibGmp)\"" >> $(CONFIG_HS)
207         @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
208         @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
209         @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
210         @echo done.
211
212 CLEAN_FILES += $(CONFIG_HS)
213
214 # -----------------------------------------------------------------------------
215 # Set SRCS etc.
216 #
217 # First figure out ALL_DIRS, the source sub-directories
218
219 ALL_DIRS = \
220   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
221   specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
222   profiling parser usageSP cprAnalysis compMan ndpFlatten
223
224 # Make sure we include Config.hs even if it doesn't exist yet...
225 ALL_SRCS += $(CONFIG_HS)
226
227 # HsGeneric.hs is not used just now
228 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
229
230 ifeq ($(GhcWithNativeCodeGen),YES)
231 ALL_DIRS += nativeGen
232 else
233 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
234 endif
235
236 ifeq ($(GhcWithIlx),YES)
237 ALL_DIRS += ilxGen
238 SRC_HC_OPTS += -DILX
239 endif
240
241 ifeq ($(GhcWithJavaGen),YES)
242 ALL_DIRS += javaGen
243 SRC_HC_OPTS += -DJAVA
244 endif
245
246 ifeq "$(BootingFromHc)" "YES"
247 # HC files are always from a self-booted compiler
248 bootstrapped = YES
249 compiling_with_4xx=NO
250 else
251 ifneq "$(findstring $(stage), 2 3)" ""
252 bootstrapped = YES
253 compiling_with_4xx = NO
254 else
255 bootstrapped = $(shell if (test $(GhcCanonVersion) -ge $(ProjectVersionInt) -a $(GhcPatchLevel) -ge $(ProjectPatchLevel)); then echo YES; else echo NO; fi)
256 compiling_with_4xx = $(shell if (test $(GhcCanonVersion) -lt 500); then echo YES; else echo NO; fi)
257 endif
258 endif
259
260 # Only include GHCi if we're bootstrapping with at least version 411
261 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
262 # Yes, include the interepreter, readline, and Template Haskell extensions
263 SRC_HC_OPTS += -DGHCI -package haskell-src
264 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
265 SRC_HC_OPTS += -package unix -package readline 
266 endif
267 ALL_DIRS += ghci
268 else
269 # No interpreter, so exclude Template Haskell modules
270 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
271 endif 
272
273 # There are some C files to include in HS_PROG, so add these to HS_OBJS
274 HS_OBJS  += $(C_OBJS)
275
276 # -----------------------------------------------
277 # mkdependC stuff
278 #
279 # Big Fudge to get around inherent problem that Makefile setup
280 # has got with 'mkdependC'.
281
282 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(GHC_INCLUDE_DIR)
283
284 # -----------------------------------------------------------------------------
285 #               Haskell compilations
286
287 SRC_HC_OPTS += \
288   -cpp -fglasgow-exts -Rghc-timing \
289   -I. -IcodeGen -InativeGen -Iparser
290
291 # Omitted:      -I$(GHC_INCLUDE_DIR)
292 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS, 
293 # to avoid the use of an explicit path in GHC source files
294 #       (include "../includes/config.h"
295 # But alas GHC 4.08 (and others for all I know) uses this very
296 # same include path when compiling the .hc files it generates.
297 # Disaster!  Then the hc file sees the GHC 5.02 (or whatever)
298 # include files.   For the moment we've reverted to using
299 # an explicit path in the .hs sources
300 #
301 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
302 # when generating dependencies. (=> it gets passed onto mkdependHS,
303 # which needs it).
304 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
305
306 # When bootstrapped, we don't make use of *any* packages
307 # (except possibly readline if GHCi is enabled, see above)
308 ifneq "$(bootstrapped)" "YES"
309 ifneq "$(mingw32_HOST_OS)" "1"
310 SRC_HC_OPTS += -package concurrent -package posix -package util
311 else
312 SRC_HC_OPTS += -package concurrent -package util
313 endif
314 endif
315
316 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
317 SRC_HC_OPTS += -recomp $(GhcHcOpts)
318 SRC_HC_OPTS += -H16M
319
320 ifeq "$(BootingFromHc)" "YES"
321 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
322 endif
323
324 #       Special flags for particular modules
325 #       The standard suffix rule for compiling a Haskell file
326 #       adds these flags to the command line
327
328 # not sure if this is required --SDM
329 main/Main_HC_OPTS               = -fvia-C
330
331 prelude/PrimOp_HC_OPTS          = -no-recomp -H80m
332
333 # because the NCG can't handle the 64-bit math in here
334 prelude/PrelRules_HC_OPTS       = -fvia-C
335
336 main/ParsePkgConf_HC_OPTS       += -fno-warn-incomplete-patterns
337 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
338 # primops on all platforms.
339 parser/Parser_HC_OPTS           += -Onot -fno-warn-incomplete-patterns -fvia-C
340
341 # The latest GHC version doesn't have a -K option yet, and it doesn't
342 # seem to be necessary anymore for the modules below.
343 ifeq "$(compiling_with_4xx)" "YES"
344 parser/Parser_HC_OPTS           += -K2m
345 endif
346
347 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
348 rename/RnMonad_HC_OPTS          =  -O2 -O2-for-C
349 endif
350
351 utils/StringBuffer_HC_OPTS      = -fvia-C -fno-prune-tydecls
352 utils/Digraph_HC_OPTS           = -fglasgow-exts 
353
354 ifeq "$(bootstrapped)" "YES"
355 utils/Binary_HC_OPTS            = -funbox-strict-fields
356 endif
357
358 # ByteCodeItbls uses primops that the NCG doesn't support yet.
359 ghci/ByteCodeItbls_HC_OPTS      = -fvia-C
360 ghci/ByteCodeLink_HC_OPTS       = -fvia-C -monly-3-regs
361
362 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
363 # DriverMkDepend), causing some of them to be commoned up.  We have a fix for
364 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
365 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
366 compMan/CompManager_HC_OPTS     = -fno-cse
367 ghci/InteractiveUI_HC_OPTS      = -fno-cse
368 main/CmdLineOpts_HC_OPTS        = -fno-cse
369 main/DriverFlags_HC_OPTS        = -fno-cse
370 main/DriverMkDepend_HC_OPTS     = -fno-cse
371 main/DriverPipeline_HC_OPTS     = -fno-cse
372 main/DriverState_HC_OPTS        = -fno-cse
373 main/DriverUtil_HC_OPTS         = -fno-cse
374 main/Finder_HC_OPTS             = -fno-cse
375 main/SysTools_HC_OPTS           = -fno-cse
376
377 # The #include is vital for the via-C route, else the C
378 # compiler doesn't realise that the stcall foreign imports are indeed
379 # stdcall, and doesn't generate the Foo@8 name for them
380 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
381 main/SysTools_HC_OPTS           += '-\#include <windows.h>' '-\#include <process.h>'
382 endif
383
384 # ghc_strlen percolates through so many modules that it is easier to get its
385 # prototype via a global option instead of a myriad of per-file OPTIONS
386 SRC_HC_OPTS += '-\#include "hschooks.h"'
387
388 # ----------------------------------------------------------------------------
389 #               Generate supporting stuff for prelude/PrimOp.lhs 
390 #               from prelude/primops.txt
391
392 GENPOC=$(TOP)/utils/genprimopcode/genprimopcode
393
394 PRIMOP_BITS=primop-data-decl.hs-incl \
395             primop-tag.hs-incl  \
396             primop-list.hs-incl  \
397             primop-has-side-effects.hs-incl  \
398             primop-out-of-line.hs-incl  \
399             primop-commutable.hs-incl  \
400             primop-needs-wrapper.hs-incl  \
401             primop-can-fail.hs-incl  \
402             primop-strictness.hs-incl  \
403             primop-usage.hs-incl  \
404             primop-primop-info.hs-incl
405
406 CLEAN_FILES += prelude/primops.txt
407 CLEAN_FILES += $(PRIMOP_BITS)
408
409 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR) -traditional
410 SRC_CPP_OPTS += ${GhcCppOpts}
411
412 ifneq "$(BootingFromHc)" "YES"
413 prelude/PrimOp.lhs prelude/PrimOp.o: $(PRIMOP_BITS)
414 endif
415
416 ifneq "$(BootingFromHc)" "YES"
417 depend :: $(PRIMOP_BITS)
418 endif
419
420 primop-data-decl.hs-incl: prelude/primops.txt
421         $(GENPOC) --data-decl          < $< > $@
422 primop-tag.hs-incl: prelude/primops.txt
423         $(GENPOC) --primop-tag         < $< > $@
424 primop-list.hs-incl: prelude/primops.txt
425         $(GENPOC) --primop-list        < $< > $@
426 primop-has-side-effects.hs-incl: prelude/primops.txt
427         $(GENPOC) --has-side-effects   < $< > $@
428 primop-out-of-line.hs-incl: prelude/primops.txt
429         $(GENPOC) --out-of-line        < $< > $@
430 primop-commutable.hs-incl: prelude/primops.txt
431         $(GENPOC) --commutable         < $< > $@
432 primop-needs-wrapper.hs-incl: prelude/primops.txt
433         $(GENPOC) --needs-wrapper      < $< > $@
434 primop-can-fail.hs-incl: prelude/primops.txt
435         $(GENPOC) --can-fail           < $< > $@
436 primop-strictness.hs-incl: prelude/primops.txt
437         $(GENPOC) --strictness         < $< > $@
438 primop-usage.hs-incl: prelude/primops.txt
439         $(GENPOC) --usage              < $< > $@
440 primop-primop-info.hs-incl: prelude/primops.txt
441         $(GENPOC) --primop-primop-info < $< > $@
442
443
444
445 # ----------------------------------------------------------------------------
446 #               Parsers/lexers
447
448 SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS  $(GHC_HAPPY_OPTS)
449
450 #-----------------------------------------------------------------------------
451 #               Linking
452
453 SRC_LD_OPTS += -no-link-chk 
454
455 # -----------------------------------------------------------------------------
456 # create ghc-inplace, a convenient way to run ghc from the build tree...
457
458 all :: $(odir)/ghc-inplace ghc-inplace
459
460 $(odir)/ghc-inplace : $(HS_PROG)
461         @$(RM) $@
462         echo '#!/bin/sh' >>$@
463         echo exec $(FPTOOLS_TOP_ABS)/ghc/compiler/$(HS_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
464         chmod 755 $@
465
466 ghc-inplace : stage1/ghc-inplace
467         $(LN_S) $< $@
468
469 CLEAN_FILES += $(odir)/ghc-inplace ghc-inplace
470
471 #-----------------------------------------------------------------------------
472 #               install
473
474 # We don't want ghc treated as an ordinary executable,
475 # but put it together with the libraries.
476 # Also don't want any interface files installed
477
478 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
479
480 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
481 INSTALL_LIBEXECS += $(HS_PROG)
482 else
483 INSTALL_PROGS += $(HS_PROG)
484 endif
485
486 # ----------------------------------------------------------------------------
487 # profiling.
488
489 # rename/Rename_HC_OPTS += -auto-all
490 # rename/RnEnv_HC_OPTS += -auto-all
491 # rename/RnHiFiles_HC_OPTS += -auto-all
492 # rename/RnIfaces_HC_OPTS += -auto-all
493 # rename/RnSource_HC_OPTS += -auto-all
494 # rename/RnBinds_HC_OPTS += -auto-all
495 # rename/RnExpr_HC_OPTS += -auto-all
496 # rename/RnHsSyn_HC_OPTS += -auto-all
497 # rename/RnNames_HC_OPTS += -auto-all
498 # rename/RnTypes_HC_OPTS += -auto-all
499
500 #-----------------------------------------------------------------------------
501 #               clean
502
503 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
504
505 #-----------------------------------------------------------------------------
506 #               Include target-rule boilerplate
507
508 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
509 MKDEPENDHS_SRCS =
510 MKDEPENDC_SRCS =
511
512 include $(TOP)/mk/target.mk
513
514 # -----------------------------------------------------------------------------
515 # Dependencies
516
517 MKDEPENDHS_HC_OPTS = $(shell echo $(HC_OPTS) | sed -e s@$(odir)/@@g)
518
519 MKDEPENDHS=$(HC)
520
521 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
522 depend :: $(HS_SRCS) $(C_SRCS)
523         $(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)
524         $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
525         $(PERL) -pe 's@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
526
527 -include .depend-$(stage)