summaryrefslogtreecommitdiff
path: root/ghc/compiler/Jmakefile
blob: aecfcbd1b03eae198ca01125e380f68ee2a3b21e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
/* preliminaries */

/* (only subdir is the test suite) */

#if IncludeTestDirsInBuild == YES
# define IHaveSubdirs

# define __ghc_compiler_tests_dir tests
#else
# define __ghc_compiler_tests_dir /* nothing */
#endif
SUBDIRS = __ghc_compiler_tests_dir
#undef __ghc_compiler_tests_dir

#define NoAllTargetForSubdirs
#define NoDocsTargetForSubdirs
#define NoInstallDocsTargetForSubdirs
#define NoDependTargetForSubdirs
#define NoInstallTargetForSubdirs
#define NoTagTargetForSubdirs

/* Suffix rules: we do not use them much at all in GHC.
   We need some magic stuff (from suffixes-GEN.ljm) for
   the parser files.
*/
SuffixRules_flexish()
SuffixRule_c_o()
LitSuffixRule(.lprl,.prl) /* for makeSymbolList.prl */

/* assume ALL source is in subdirectories one level below
   they don't have Jmakefiles; this Jmakefile controls everything
*/

SUBDIR_LIST = \ /* here they are, colon separated (for mkdependHS) */
utils:basicTypes:types:hsSyn:prelude:envs:rename:typecheck:deSugar:coreSyn:specialise:simplCore:stranal:stgSyn:simplStg:codeGen:nativeGen:absCSyn:main:reader:profiling:deforest:parser

#ifdef MainIncludeDir
MAIN_INCLUDE_DIR=MainIncludeDir
#else
MAIN_INCLUDE_DIR=$(TOP_PWD)/$(CURRENT_DIR)/$(GHC_INCLUDES)
#endif

/* helps to find GhcConstants.h in codeGen/CgCompInfo.lhs */
#ifdef CompInfoDir
COMPINFO_DIR=CompInfoDir
#else
COMPINFO_DIR=$(TOP_PWD)/$(CURRENT_DIR)/codeGen
#endif
/* nativeGen, elsewhere */
#ifdef NativeGenDir
NATIVEGEN_DIR=NativeGenDir
#else
NATIVEGEN_DIR=$(TOP_PWD)/$(CURRENT_DIR)/nativeGen
#endif

/* in order-of-passes order, utility modules at the end */

#define READERSRCS_HS	\
parser/U_constr.hs	\
parser/U_binding.hs	\
parser/U_pbinding.hs	\
parser/U_coresyn.hs	\
parser/U_entidt.hs	\
parser/U_hpragma.hs	\
parser/U_list.hs	\
parser/U_literal.hs	\
parser/U_maybe.hs	\
parser/U_either.hs	\
parser/U_qid.hs		\
parser/U_tree.hs 	\
parser/U_ttype.hs

#define hsp_library libhsp.a

#define READERSRCS_LHS	\
parser/UgenUtil.lhs	\
parser/UgenAll.lhs	\
reader/ReadPrefix.lhs	\
reader/ReadPragmas.lhs	\
\
reader/PrefixSyn.lhs	\
reader/PrefixToHs.lhs	\
reader/RdrHsSyn.lhs	\
\
hsSyn/HsBinds.lhs  /* abstract Haskell syntax */ \
hsSyn/HsCore.lhs \
hsSyn/HsDecls.lhs \
hsSyn/HsExpr.lhs \
hsSyn/HsImpExp.lhs \
hsSyn/HsLit.lhs \
hsSyn/HsMatches.lhs \
hsSyn/HsPat.lhs \
hsSyn/HsPragmas.lhs \
hsSyn/HsTypes.lhs \
hsSyn/HsSyn.lhs

#define NOT_SO_BASICSRCS_LHS 	\
basicTypes/Unique.lhs		\
basicTypes/UniqSupply.lhs 	\
basicTypes/ProtoName.lhs 	\
basicTypes/Name.lhs 		\
basicTypes/NameTypes.lhs 	\
basicTypes/SrcLoc.lhs		\
basicTypes/Id.lhs		\
basicTypes/IdInfo.lhs		\
basicTypes/IdUtils.lhs		\
basicTypes/PragmaInfo.lhs	\
basicTypes/Literal.lhs		\
\
types/Class.lhs			\
types/Kind.lhs			\
types/PprType.lhs		\
types/TyCon.lhs			\
types/TyVar.lhs			\
types/Usage.lhs			\
types/Type.lhs			\
\
specialise/SpecEnv.lhs


#define RENAMERSRCS_LHS \
rename/RnPass1.lhs \
rename/RnPass2.lhs \
rename/RnPass3.lhs \
rename/RnPass4.lhs \
rename/RnHsSyn.lhs \
rename/RnUtils.lhs \
rename/RnMonad12.lhs \
rename/RnMonad3.lhs \
rename/RnMonad4.lhs \
rename/RnBinds4.lhs \
rename/RnExpr4.lhs \
rename/Rename.lhs

#define TCSRCS_LHS \
typecheck/TcHsSyn.lhs \
typecheck/GenSpecEtc.lhs \
typecheck/Inst.lhs	\
typecheck/TcBinds.lhs \
typecheck/TcClassDcl.lhs \
typecheck/TcDefaults.lhs \
typecheck/TcDeriv.lhs \
typecheck/TcExpr.lhs \
typecheck/TcGenDeriv.lhs \
typecheck/TcGRHSs.lhs \
typecheck/TcIfaceSig.lhs \
typecheck/TcInstDcls.lhs \
typecheck/TcInstUtil.lhs \
typecheck/TcMatches.lhs \
typecheck/TcModule.lhs \
typecheck/TcMonad.lhs \
typecheck/TcEnv.lhs \
typecheck/TcKind.lhs \
typecheck/TcType.lhs \
typecheck/TcMonoType.lhs \
typecheck/TcPat.lhs \
typecheck/TcSimplify.lhs \
typecheck/TcTyClsDecls.lhs \
typecheck/TcTyDecls.lhs \
typecheck/Typecheck.lhs \
typecheck/Unify.lhs

/*
typecheck/TcPragmas.lhs \
*/

#define DSSRCS_LHS \
deSugar/Desugar.lhs \
deSugar/Match.lhs \
deSugar/MatchCon.lhs \
deSugar/MatchLit.lhs \
deSugar/DsBinds.lhs \
deSugar/DsCCall.lhs \
deSugar/DsExpr.lhs \
deSugar/DsGRHSs.lhs \
deSugar/DsHsSyn.lhs \
deSugar/DsListComp.lhs \
deSugar/DsMonad.lhs \
deSugar/DsUtils.lhs \
\
coreSyn/CoreLift.lhs \
coreSyn/CoreLint.lhs

#define SIMPL_SRCS_LHS \
coreSyn/AnnCoreSyn.lhs \
coreSyn/FreeVars.lhs \
\
specialise/Specialise.lhs \
specialise/SpecUtils.lhs \
\
simplCore/SimplCase.lhs \
simplCore/SimplEnv.lhs \
simplCore/SimplMonad.lhs \
simplCore/SimplPgm.lhs \
simplCore/SimplUtils.lhs \
simplCore/SimplVar.lhs \
simplCore/Simplify.lhs \
\
simplCore/LiberateCase.lhs \
\
simplCore/ConFold.lhs \
simplCore/FloatIn.lhs \
simplCore/FloatOut.lhs \
simplCore/SAT.lhs \
simplCore/SATMonad.lhs \
simplCore/SetLevels.lhs \
simplCore/SimplCore.lhs \
simplCore/OccurAnal.lhs \
simplCore/FoldrBuildWW.lhs \
simplCore/AnalFBWW.lhs \
\
stranal/StrictAnal.lhs \
stranal/SaLib.lhs \
stranal/SaAbsInt.lhs \
stranal/WwLib.lhs \
stranal/WorkWrap.lhs \
\
profiling/SCCauto.lhs \
profiling/SCCfinal.lhs

#if GhcWithDeforester != YES
#define __omit_deforester_flag -DOMIT_DEFORESTER=1
#define DEFORESTER_SRCS_LHS /*none*/
#else
#define __omit_deforester_flag /*nope*/
#define DEFORESTER_SRCS_LHS \
deforest/DefSyn.lhs \
deforest/Core2Def.lhs \
deforest/Def2Core.lhs \
deforest/Deforest.lhs \
deforest/DefUtils.lhs \
deforest/DefExpr.lhs \
deforest/Cyclic.lhs \
deforest/TreelessForm.lhs
#endif /* GhcWithDeforester */

#define BACKSRCS_LHS \
stgSyn/CoreToStg.lhs \
stgSyn/StgSyn.lhs \
stgSyn/StgUtils.lhs \
stgSyn/StgLint.lhs \
\
simplStg/SatStgRhs.lhs \
simplStg/LambdaLift.lhs \
simplStg/StgVarInfo.lhs \
simplStg/UpdAnal.lhs \
simplStg/StgStats.lhs \
simplStg/StgSATMonad.lhs \
simplStg/StgSAT.lhs \
simplStg/SimplStg.lhs \
\
absCSyn/AbsCUtils.lhs \
absCSyn/AbsCSyn.lhs \
absCSyn/CLabel.lhs \
absCSyn/Costs.lhs \
absCSyn/HeapOffs.lhs \
absCSyn/PprAbsC.lhs \
\
codeGen/CodeGen.lhs \
codeGen/ClosureInfo.lhs \
codeGen/SMRep.lhs \
codeGen/CgConTbls.lhs \
codeGen/CgMonad.lhs \
codeGen/CgUsages.lhs \
codeGen/CgHeapery.lhs \
codeGen/CgStackery.lhs \
codeGen/CgExpr.lhs \
codeGen/CgCase.lhs \
codeGen/CgLetNoEscape.lhs \
codeGen/CgTailCall.lhs \
codeGen/CgClosure.lhs \
codeGen/CgCon.lhs \
codeGen/CgRetConv.lhs \
codeGen/CgBindery.lhs \
codeGen/CgUpdate.lhs

#if GhcWithNativeCodeGen == NO || GhcWithHscBuiltViaC == YES
    /* if building via C, we *assume* that it is the
       distributed C files, which do not have a native-code
       generator in them
    */
# define __omit_ncg_maybe -DOMIT_NATIVE_CODEGEN=1
# define NATIVEGEN_SRCS_LHS /*none*/
#else
# define __omit_ncg_maybe /*none*/
# if i386_TARGET_ARCH
# define __machdep_nativegen_lhs \
nativeGen/I386Desc.lhs \
nativeGen/I386Code.lhs \
nativeGen/I386Gen.lhs
# endif
# if sparc_TARGET_ARCH
# define __machdep_nativegen_lhs \
nativeGen/SparcDesc.lhs \
nativeGen/SparcCode.lhs \
nativeGen/SparcGen.lhs
# endif
# if alpha_TARGET_ARCH
# define __machdep_nativegen_lhs \
nativeGen/AlphaDesc.lhs \
nativeGen/AlphaCode.lhs \
nativeGen/AlphaGen.lhs
# endif

# define NATIVEGEN_SRCS_LHS \
nativeGen/AbsCStixGen.lhs \
nativeGen/AsmCodeGen.lhs \
nativeGen/AsmRegAlloc.lhs \
nativeGen/MachDesc.lhs \
nativeGen/Stix.lhs \
nativeGen/StixInfo.lhs \
nativeGen/StixInteger.lhs \
nativeGen/StixPrim.lhs \
nativeGen/StixMacro.lhs \
__machdep_nativegen_lhs /*arch-specific ones */
#endif

#define UTILSRCS_LHS \
utils/Argv.lhs \
utils/Bag.lhs \
utils/BitSet.lhs \
utils/CharSeq.lhs \
utils/Digraph.lhs \
utils/FiniteMap.lhs \
utils/ListSetOps.lhs \
utils/MatchEnv.lhs \
utils/Maybes.lhs \
utils/OrdList.lhs \
utils/Outputable.lhs \
utils/PprStyle.lhs \
utils/Pretty.lhs \
utils/SST.lhs \
utils/UniqFM.lhs \
utils/UniqSet.lhs \
utils/Unpretty.lhs \
utils/Util.lhs

#define MAIN_SRCS_LHS \
main/MainMonad.lhs \
main/CmdLineOpts.lhs \
main/ErrUtils.lhs \
main/Main.lhs

/* 
main/MkIface.lhs \
*/

#define VBASICSRCS_LHS \
prelude/PrelMods.lhs \
prelude/PrimRep.lhs \
prelude/PrimOp.lhs \
prelude/TysPrim.lhs \
prelude/TysWiredIn.lhs \
prelude/PrelVals.lhs \
prelude/PrelInfo.lhs \
\
absCSyn/CStrings.lhs \
codeGen/CgCompInfo.lhs \
coreSyn/CoreSyn.lhs \
coreSyn/CoreUnfold.lhs \
coreSyn/CoreUtils.lhs \
coreSyn/PprCore.lhs \
profiling/CostCentre.lhs \
simplCore/BinderInfo.lhs \
simplCore/MagicUFs.lhs

ALLSRCS_HS = READERSRCS_HS
ALLSRCS_LHS = /* all pieces of the compiler */ \
VBASICSRCS_LHS \
NOT_SO_BASICSRCS_LHS \
UTILSRCS_LHS \
MAIN_SRCS_LHS \
READERSRCS_LHS \
RENAMERSRCS_LHS \
TCSRCS_LHS \
DSSRCS_LHS

/*
SIMPL_SRCS_LHS
BACKSRCS_LHS
*/

/* 
NATIVEGEN_SRCS_LHS DEFORESTER_SRCS_LHS */
/* NB: all the ones that may be empty (e.g., NATIVEGEN_SRCS_LHS)
	need to be on the last line.
*/

/* should't use these fancy `make' things, really */
ALLHCS =$(ALLSRCS_LHS:.lhs=.hc) $(ALLSRCS_HS:.hs=.hc)
ALLOBJS=$(ALLSRCS_LHS:.lhs=.o)  $(ALLSRCS_HS:.hs=.o)
ALLINTS=$(ALLSRCS_LHS:.lhs=.hi) $(ALLSRCS_HS:.hs=.hi)

.PRECIOUS: $(ALLINTS)

#if GhcWithHscDebug == YES
# define use_DDEBUG -DDEBUG
#else
# define use_DDEBUG /*nothing*/
#endif

#if GhcWithHscOptimised == YES
#define __version_sensitive_flags -DUSE_ATTACK_PRAGMAS -fshow-pragma-name-errs -fomit-reexported-instances -fshow-import-specs
#else
#define __version_sensitive_flags -fomit-reexported-instances
#endif

#if GhcWithRegisterised == NO
    /* doing a raw boot from .hc files, presumably */
#define __unreg_opts_maybe -O -unregisterised
#else
#define __unreg_opts_maybe /*none*/
#endif

/* avoid use of AllProjectsHcOpts; then put in HcMaxHeapFlag "by hand" */
#undef  AllProjectsHcOpts
#define AllProjectsHcOpts /**/

HC_OPTS = -cpp HcMaxHeapFlag -fhaskell-1.3 -fglasgow-exts -DCOMPILING_GHC \
	-fomit-derived-read \
	-I. -i$(SUBDIR_LIST) \
	use_DDEBUG __version_sensitive_flags __unreg_opts_maybe __omit_ncg_maybe

#undef __version_sensitive_flags
#undef __unreg_opts_maybe
#undef __omit_ncg_maybe
#undef __omit_deforester_flag

#if GhcWithHscBuiltViaC == YES /* not using a Haskell compiler */

hcs:: $(ALLHCS)

# if HaskellCompilerType == HC_USE_HC_FILES
HC = $(GHC) /* uses the driver herein */
# endif

#endif /* using .hc files */

/*
    -DCOMPILING_GHC
	Used when compiling GHC.  Some GHC utility modules are
	*also* part of the GHC library.  There are a few bits
	of those modules that only apply to GHC itself and
	should not be in the library stuff.  We use this
	CPP thing to isolate those bits.
*/

BuildPgmFromHaskellModules(hsc,$(ALLOBJS) parser/hsclink.o parser/hschooks.o,,libhsp.a)

#if DoInstallGHCSystem == YES
MakeDirectories(install, $(INSTLIBDIR_GHC))
InstallBinaryTarget(hsc,$(INSTLIBDIR_GHC))
#endif

/* set up for going either to .hc or to .o files */
#if GhcWithHscBuiltViaC == YES

/*OLD:SuffixRule_hc_o() */

# if HaskellCompilerType == HC_USE_HC_FILES
    /* if we do not, we never try to compile .lhs files;
	we *blast* the macro we would normally use (HACK) (WDP 94/12)
     */

#  undef HaskellCompileWithSpecifiedFlags
#  define HaskellCompileWithSpecifiedFlags(module,isuf,osuf,flags)	@@\
module.osuf : module.isuf						\
_body_HaskellCompileWithSpecifiedFlags(module.isuf,module.osuf,module,isuf,flags)

#  define compile(module,isuf,extra_flags) \
HaskellCompileWithExtraFlags(module,hc,o,-c,extra_flags)

#  define compile_rec(module,isuf,extra_flags) \
HaskellCompileWithExtraFlags_Recursive(module,hc,o,-c,extra_flags)

# else /* we do! */

#  define compile(module,isuf,extra_flags) \
HaskellCompileWithExtraFlags(module,isuf,hc,-C,extra_flags)

#  define compile_rec(module,isuf,extra_flags) \
HaskellCompileWithExtraFlags_Recursive(module,isuf,hc,-C,extra_flags)

# endif /* ... == HC_USE_HC_FILES */

#else /* ! booting from C */

# define compile(module,isuf,extra_flags) \
HaskellCompileWithExtraFlags(module,isuf,o,-c,extra_flags)

# define compile_rec(module,isuf,extra_flags) \
HaskellCompileWithExtraFlags_Recursive(module,isuf,o,-c,extra_flags)

#endif /* ! booting from C */

#define if_ghc(x) x
#if GhcBuilderVersion >= 26
#  define if_ghc26(x) x
#else
#  define if_ghc26(x) /*nothing*/
#endif

/* OK, here we go: */

utils/Ubiq.hi : utils/Ubiq.lhi
	$(GHC_UNLIT) utils/Ubiq.lhi utils/Ubiq.hi

basicTypes/IdLoop.hi : basicTypes/IdLoop.lhi
	$(GHC_UNLIT) basicTypes/IdLoop.lhi basicTypes/IdLoop.hi
basicTypes/NameLoop.hi : basicTypes/NameLoop.lhi
	$(GHC_UNLIT) basicTypes/NameLoop.lhi basicTypes/NameLoop.hi
deSugar/DsLoop.hi : deSugar/DsLoop.lhi
	$(GHC_UNLIT) deSugar/DsLoop.lhi deSugar/DsLoop.hi
hsSyn/HsLoop.hi : hsSyn/HsLoop.lhi
	$(GHC_UNLIT) hsSyn/HsLoop.lhi hsSyn/HsLoop.hi
prelude/PrelLoop.hi : prelude/PrelLoop.lhi
	$(GHC_UNLIT) prelude/PrelLoop.lhi prelude/PrelLoop.hi
reader/RdrLoop.hi : reader/RdrLoop.lhi
	$(GHC_UNLIT) reader/RdrLoop.lhi reader/RdrLoop.hi
rename/RnLoop.hi : rename/RnLoop.lhi
	$(GHC_UNLIT) rename/RnLoop.lhi rename/RnLoop.hi
simplCore/SmplLoop.hi : simplCore/SmplLoop.lhi
	$(GHC_UNLIT) simplCore/SmplLoop.lhi simplCore/SmplLoop.hi
typecheck/TcMLoop.hi : typecheck/TcMLoop.lhi
	$(GHC_UNLIT) typecheck/TcMLoop.lhi typecheck/TcMLoop.hi
typecheck/TcLoop.hi : typecheck/TcLoop.lhi
	$(GHC_UNLIT) typecheck/TcLoop.lhi typecheck/TcLoop.hi
types/TyLoop.hi : types/TyLoop.lhi
	$(GHC_UNLIT) types/TyLoop.lhi types/TyLoop.hi

compile(absCSyn/AbsCUtils,lhs,)
compile(absCSyn/CStrings,lhs,)
compile(absCSyn/CLabel,lhs,)
compile(absCSyn/Costs,lhs,)
compile(absCSyn/HeapOffs,lhs,)
compile(absCSyn/PprAbsC,lhs,)
compile(absCSyn/AbsCSyn,lhs,if_ghc(-fno-omit-reexported-instances))

compile(hsSyn/HsBinds,lhs,)
compile(hsSyn/HsCore,lhs,)
compile(hsSyn/HsDecls,lhs,)
compile(hsSyn/HsExpr,lhs,)
compile(hsSyn/HsImpExp,lhs,)
compile(hsSyn/HsLit,lhs,)
compile(hsSyn/HsMatches,lhs,)
compile(hsSyn/HsPat,lhs,)
compile(hsSyn/HsPragmas,lhs,)
compile(hsSyn/HsTypes,lhs,)
compile(hsSyn/HsSyn,lhs,if_ghc(-fno-omit-reexported-instances))

compile(basicTypes/Id,lhs,)
compile(basicTypes/IdInfo,lhs,-K2m)
compile(basicTypes/IdUtils,lhs,)
compile(basicTypes/Literal,lhs,)
compile(basicTypes/Name,lhs,)
compile(basicTypes/NameTypes,lhs,)
compile(basicTypes/PragmaInfo,lhs,)
compile(basicTypes/ProtoName,lhs,)
compile(basicTypes/SrcLoc,lhs,)
compile(basicTypes/UniqSupply,lhs,)
compile(basicTypes/Unique,lhs,)

compile(codeGen/CgBindery,lhs,)
compile(codeGen/CgCase,lhs,)
compile(codeGen/CgClosure,lhs,)
compile(codeGen/CgCompInfo,lhs,-I$(COMPINFO_DIR))
compile(codeGen/CgCon,lhs,)
compile(codeGen/CgConTbls,lhs,)
compile(codeGen/CgExpr,lhs,)
compile(codeGen/CgHeapery,lhs,)
compile(codeGen/CgLetNoEscape,lhs,)
compile(codeGen/CgMonad,lhs,)
compile(codeGen/CgRetConv,lhs,)
compile(codeGen/CgStackery,lhs,)
compile(codeGen/CgTailCall,lhs,)
compile(codeGen/CgUpdate,lhs,)
compile(codeGen/CgUsages,lhs,)
compile(codeGen/ClosureInfo,lhs,)
compile(codeGen/CodeGen,lhs,)
compile(codeGen/SMRep,lhs,)

compile(coreSyn/AnnCoreSyn,lhs,if_ghc(-fno-omit-reexported-instances))
compile(coreSyn/CoreUtils,lhs,)
compile(coreSyn/CoreLift,lhs,)
compile(coreSyn/CoreLint,lhs,)
compile(coreSyn/CoreSyn,lhs,)
compile(coreSyn/PprCore,lhs,)
compile(coreSyn/CoreUnfold,lhs,)
compile(coreSyn/FreeVars,lhs,)

compile(deSugar/Desugar,lhs,)
compile(deSugar/DsBinds,lhs,)
compile(deSugar/DsCCall,lhs,)
compile(deSugar/DsExpr,lhs,)
compile(deSugar/DsGRHSs,lhs,)
compile(deSugar/DsHsSyn,lhs,)
compile(deSugar/DsListComp,lhs,)
compile(deSugar/DsMonad,lhs,)
compile(deSugar/DsUtils,lhs,)
compile(deSugar/Match,lhs,)
compile(deSugar/MatchCon,lhs,)
compile(deSugar/MatchLit,lhs,)

compile(main/CmdLineOpts,lhs,if_ghc(-fvia-C))
compile(main/ErrUtils,lhs,)
compile(main/Main,lhs,if_ghc(-fvia-C))
compile(main/MainMonad,lhs,)
compile(main/MkIface,lhs,)

#if GhcWithNativeCodeGen == YES
compile(nativeGen/AbsCStixGen,lhs,)
compile(nativeGen/AsmCodeGen,lhs,-I$(COMPINFO_DIR))
compile(nativeGen/AsmRegAlloc,lhs,-I$(COMPINFO_DIR))
compile(nativeGen/MachDesc,lhs,)
compile(nativeGen/Stix,lhs,)
compile(nativeGen/StixInfo,lhs,-I$(NATIVEGEN_DIR))
compile(nativeGen/StixInteger,lhs,)
compile(nativeGen/StixMacro,lhs,-I$(NATIVEGEN_DIR))
compile(nativeGen/StixPrim,lhs,)
# if i386_TARGET_ARCH
compile(nativeGen/I386Desc,lhs,)
compile(nativeGen/I386Code,lhs,-I$(NATIVEGEN_DIR) if_ghc(-monly-4-regs))
compile(nativeGen/I386Gen,lhs,)
# endif
# if sparc_TARGET_ARCH
compile(nativeGen/SparcDesc,lhs,)
compile(nativeGen/SparcCode,lhs,-I$(NATIVEGEN_DIR))
compile(nativeGen/SparcGen,lhs,)
# endif
# if alpha_TARGET_ARCH
compile(nativeGen/AlphaDesc,lhs,)
compile(nativeGen/AlphaCode,lhs,-I$(NATIVEGEN_DIR))
compile(nativeGen/AlphaGen,lhs,)
# endif
#endif

compile(prelude/PrelInfo,lhs,)
compile(prelude/PrelMods,lhs,)
compile(prelude/PrelVals,lhs,)
compile(prelude/PrimRep,lhs,-I$(COMPINFO_DIR))
compile(prelude/PrimOp,lhs,-K3m -H10m)
compile(prelude/TysPrim,lhs,)
compile(prelude/TysWiredIn,lhs,)

compile(profiling/SCCauto,lhs,)
compile(profiling/SCCfinal,lhs,)
compile(profiling/CostCentre,lhs,)

compile(reader/PrefixSyn,lhs,)
compile(reader/PrefixToHs,lhs,)
compile(reader/ReadPrefix,lhs,if_ghc(-fvia-C -I$(COMPINFO_DIR) -Iparser '-#include"hspincl.h"'))
compile(reader/ReadPragmas,lhs,)
compile(reader/RdrHsSyn,lhs,)

compile(rename/Rename,lhs,)
compile(rename/RnPass1,lhs,)
compile(rename/RnPass2,lhs,)
compile(rename/RnPass3,lhs,)
compile(rename/RnPass4,lhs,)
compile(rename/RnUtils,lhs,)
compile(rename/RnHsSyn,lhs,)
compile(rename/RnBinds4,lhs,)
compile(rename/RnExpr4,lhs,)
compile(rename/RnMonad12,lhs,)
compile(rename/RnMonad3,lhs,)
compile(rename/RnMonad4,lhs,)

compile(simplCore/BinderInfo,lhs,)
compile(simplCore/ConFold,lhs,)
compile(simplCore/FloatIn,lhs,)
compile(simplCore/FloatOut,lhs,)
compile(simplCore/LiberateCase,lhs,)
compile(simplCore/MagicUFs,lhs,)
compile(simplCore/OccurAnal,lhs,)

compile(simplCore/AnalFBWW,lhs,)
compile(simplCore/FoldrBuildWW,lhs,)

compile(simplCore/SAT,lhs,)
compile(simplCore/SATMonad,lhs,)
compile(simplCore/SetLevels,lhs,)
compile(simplCore/SimplCase,lhs,)
compile(simplCore/SimplCore,lhs,)
compile(simplCore/SimplEnv,lhs,)
compile(simplCore/SimplMonad,lhs,)
compile(simplCore/SimplPgm,lhs,)
compile(simplCore/SimplUtils,lhs,)
compile(simplCore/SimplVar,lhs,)
compile(simplCore/Simplify,lhs,)

compile(simplStg/SatStgRhs,lhs,)
compile(simplStg/LambdaLift,lhs,)
compile(simplStg/StgVarInfo,lhs,)
compile(simplStg/UpdAnal,lhs,)
compile(simplStg/StgStats,lhs,)
compile(simplStg/StgSATMonad,lhs,)
compile(simplStg/StgSAT,lhs,)
compile(simplStg/SimplStg,lhs,)

#if GhcWithDeforester == YES
compile(deforest/Core2Def,lhs,)
compile(deforest/Cyclic,lhs,)
compile(deforest/Def2Core,lhs,)
compile(deforest/DefExpr,lhs,)
compile(deforest/DefSyn,lhs,)
compile(deforest/DefUtils,lhs,)
compile(deforest/Deforest,lhs,)
compile(deforest/TreelessForm,lhs,)
#endif

compile(specialise/Specialise,lhs,)
compile(specialise/SpecEnv,lhs,)
compile(specialise/SpecUtils,lhs,)

compile(stgSyn/CoreToStg,lhs,)
compile(stgSyn/StgUtils,lhs,)
compile(stgSyn/StgLint,lhs,)
compile(stgSyn/StgSyn,lhs,if_ghc(-fno-omit-reexported-instances))

compile(stranal/SaAbsInt,lhs,)
compile(stranal/SaLib,lhs,)
compile(stranal/StrictAnal,lhs,)
compile(stranal/WorkWrap,lhs,)
compile(stranal/WwLib,lhs,)

compile(typecheck/GenSpecEtc,lhs,)
compile(typecheck/Inst,lhs,)
compile(typecheck/TcHsSyn,lhs,)
compile(typecheck/TcBinds,lhs,)
compile(typecheck/TcClassDcl,lhs,)
compile(typecheck/TcDefaults,lhs,)
compile(typecheck/TcDeriv,lhs,)
compile(typecheck/TcExpr,lhs,)
compile(typecheck/TcGRHSs,lhs,)
compile(typecheck/TcGenDeriv,lhs,)
compile(typecheck/TcIfaceSig,lhs,)
compile(typecheck/TcInstDcls,lhs,)
compile(typecheck/TcInstUtil,lhs,)
compile(typecheck/TcMatches,lhs,)
compile(typecheck/TcModule,lhs,)
compile(typecheck/TcMonad,lhs,)
compile(typecheck/TcKind,lhs,)
compile(typecheck/TcType,lhs,)
compile(typecheck/TcEnv,lhs,)
compile(typecheck/TcMonoType,lhs,)
compile(typecheck/TcPat,lhs,)
compile(typecheck/TcPragmas,lhs,)
compile(typecheck/TcSimplify,lhs,)
compile(typecheck/TcTyClsDecls,lhs,)
compile(typecheck/TcTyDecls,lhs,)
compile(typecheck/Typecheck,lhs,)
compile(typecheck/Unify,lhs,)

compile(types/Class,lhs,)
compile(types/Kind,lhs,)
compile(types/PprType,lhs,)
compile(types/TyCon,lhs,)
compile(types/TyVar,lhs,)
compile(types/Usage,lhs,)
compile(types/Type,lhs,)

compile(utils/Argv,lhs,if_ghc(-fvia-C))
compile(utils/Bag,lhs,)
compile(utils/BitSet,lhs,if_ghc26(-monly-4-regs))
compile(utils/CharSeq,lhs,if_ghc(-fvia-C)) /* uses stg_putc */
compile(utils/Digraph,lhs,)
compile(utils/FiniteMap,lhs,)
compile(utils/ListSetOps,lhs,)
compile(utils/Maybes,lhs,)
compile(utils/OrdList,lhs,)
compile(utils/Outputable,lhs,)
compile(utils/PprStyle,lhs,)
compile(utils/Pretty,lhs,)
compile(utils/SST,lhs,if_ghc(-fvia-C))
compile(utils/UniqFM,lhs,)
compile(utils/UniqSet,lhs,)
compile(utils/Unpretty,lhs,)
compile(utils/MatchEnv,lhs,)
compile(utils/Util,lhs,)

/* for convenience in cross-compiling */
objs:: $(ALLOBJS)

/* *** parser ************************************************* */

YACC_OPTS = -d
CC_OPTS = -Iparser -I. -I$(COMPINFO_DIR) -DUGEN_DEBUG=1 /*-DHSP_DEBUG=1*/ -g

/* add to these on the command line with, e.g., EXTRA_YACC_OPTS=-v */

XCOMM D_DEBUG = -DDEBUG

CPP_DEFINES = $(D_DEBUG)

HSP_SRCS_C =    parser/constr.c		\
		parser/binding.c	\
		parser/pbinding.c	\
		parser/coresyn.c	\
		parser/entidt.c		\
		parser/hpragma.c	\
		parser/hslexer.c	\
		parser/hsparser.tab.c	\
		parser/id.c		\
		parser/import_dirlist.c	\
		parser/infix.c		\
		parser/list.c		\
		parser/literal.c	\
		parser/maybe.c		\
		parser/either.c		\
		parser/qid.c		\
		parser/syntax.c		\
		parser/tree.c		\
		parser/ttype.c		\
		parser/type2context.c	\
		parser/util.c

HSP_OBJS_O =    parser/constr.o		\
		parser/binding.o	\
		parser/pbinding.o	\
		parser/coresyn.o	\
		parser/entidt.o		\
		parser/hpragma.o	\
		parser/hslexer.o	\
		parser/hsparser.tab.o	\
		parser/id.o		\
		parser/import_dirlist.o	\
		parser/infix.o		\
		parser/list.o		\
		parser/literal.o	\
		parser/maybe.o		\
		parser/either.o		\
		parser/qid.o		\
		parser/syntax.o		\
		parser/tree.o		\
		parser/ttype.o		\
		parser/type2context.o	\
		parser/util.o

/* this is for etags */
REAL_HSP_SRCS_C = parser/main.c 	\
		parser/hschooks.c	\
		parser/hsclink.c	\
		parser/id.c 		\
		parser/util.c 		\
		parser/syntax.c 	\
		parser/type2context.c 	\
		parser/import_dirlist.c \
		parser/infix.c 		\
		parser/printtree.c

UgenNeededHere(all depend)

/* Most hsp files are in libhsp.a, so we can either make
   a standalone parser, or incorporate the files into
   the hsc compiler directly (WDP 94/10)
*/
NormalLibraryTarget(hsp,$(HSP_OBJS_O))

/* We need the hsp program for hstags to work! */
BuildPgmFromCFiles(hsp,parser/printtree.o parser/main.o,,libhsp.a)

#if DoInstallGHCSystem == YES
MakeDirectories(install, $(INSTLIBDIR_GHC))
InstallBinaryTarget(hsp,$(INSTLIBDIR_GHC))
#endif /* DoInstall... */

YaccRunWithExpectMsg(parser/hsparser,16,0)

UgenTarget(parser/constr)
UgenTarget(parser/binding)
UgenTarget(parser/pbinding)
UgenTarget(parser/coresyn)
UgenTarget(parser/entidt)
UgenTarget(parser/hpragma)
UgenTarget(parser/list)
UgenTarget(parser/literal)
UgenTarget(parser/maybe)
UgenTarget(parser/either)
UgenTarget(parser/qid)
UgenTarget(parser/tree)
UgenTarget(parser/ttype)

UGENS_C = parser/constr.c	\
	parser/binding.c	\
	parser/pbinding.c	\
	parser/coresyn.c	\
	parser/entidt.c		\
	parser/literal.c	\
	parser/list.c		\
	parser/maybe.c		\
	parser/either.c		\
	parser/qid.c		\
	parser/hpragma.c	\
	parser/tree.c		\
	parser/ttype.c

/* Putting the -#include"hspincl.h" option into the
   PARSER_HS_OPTS line really does not work (it depends
   on the 'make' that you use).
*/
PARSER_HS_OPTS = if_ghc(-fvia-C -I$(COMPINFO_DIR) -Iparser)

compile(parser/UgenAll,lhs,if_ghc(-fvia-C))
compile(parser/UgenUtil,lhs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_constr,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_binding,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_pbinding,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_coresyn,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_entidt,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_hpragma,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_list,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_literal,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_maybe,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_either,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_qid,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_tree,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')
compile(parser/U_ttype,hs,$(PARSER_HS_OPTS) '-#include"hspincl.h"')

/* finished with local macros */
#undef compile
#undef compile_rec
#undef if_ghc

/* *** misc *************************************************** */

DEPSRCS = $(ALLSRCS_LHS) $(ALLSRCS_HS) SIMPL_SRCS_LHS

#if GhcWithHscBuiltViaC == NO
MKDEPENDHS_OPTS= -I$(MAIN_INCLUDE_DIR) -I$(COMPINFO_DIR) -x HsVersions.h
#else /* booting from .hc */
MKDEPENDHS_OPTS= -o .hc -I$(MAIN_INCLUDE_DIR) -I$(COMPINFO_DIR)  -x HsVersions.h
#endif /* booting from .hc files */

#if HaskellCompilerType != HC_USE_HC_FILES
    /* otherwise, the dependencies jeopardize our .hc files --
	which are all we have! */
HaskellDependTarget( $(DEPSRCS) )
#endif

ExtraStuffToClean( $(ALLOBJS) $(HSP_OBJS_O) )
#if GhcWithHscBuiltViaC == YES
ExtraStuffToClean( $(ALLHCS) )
#endif
ExtraStuffToBeVeryClean( $(STD_VERY_CLEAN) )

ClearTagsFile()
HsTagsTarget( $(ALLSRCS_LHS) )
HSTAGS_OPTS = $(HC_OPTS) -I$(MAIN_INCLUDE_DIR)

/* count the number of lines in the source files */
count_lines ::
	./count_lines $(ALLSRCS_LHS) $(ALLSRCS_HS)

/* accumulate similar info about the sizes of object files */
count_bytes ::
	./count_bytes $(ALLSRCS_LHS) $(ALLSRCS_HS)