Commit 9412e629 authored by Ian Lynagh's avatar Ian Lynagh

Get building GHC itself with Cabal more-or-less working

Installing and bindist creation don't work, but they were already broken.
Only tested validating with one setup.
parent e0b93c02
......@@ -67,12 +67,12 @@ include $(TOP)/mk/boilerplate.mk
# We can't 'make boot' in libraries until stage1 is built
ifeq "$(BootingFromHc)" "YES"
SUBDIRS_BUILD = includes rts compiler docs utils driver
SUBDIRS_BUILD = includes rts compiler ghc docs utils driver
else
SUBDIRS_BUILD = includes utils driver docs compiler rts libraries/Cabal/doc
SUBDIRS_BUILD = includes utils driver docs compiler ghc rts libraries/Cabal/doc
endif
SUBDIRS = gmp libffi includes utils driver docs rts libraries compiler libraries/Cabal/doc
SUBDIRS = gmp libffi includes utils driver docs rts compiler ghc libraries libraries/Cabal/doc
check-all: check-tools check-packages
......@@ -142,6 +142,7 @@ stage1 : $(GCC_LIB_DEP) check-all
stage2 : check-all
$(MAKE) -C compiler boot stage=2
$(MAKE) -C compiler stage=2
$(MAKE) -C ghc stage=2
stage3 : check-all
......
This diff is collapsed.
# This Makefile builds the GHC binary for stage2. In stage2, the GHC binary
# is built as a single Main module that links to the GHC package. It
# is easier to do this with a separate Makefile, because we don't want most
# of the options normally dumped into SRC_HC_OPTS by the main GHC Makefile.
# In particular, we don't want the .hi files picked up along the home package
# search path when compiling Main, we need the compiler to find them in
# the GHC package.
TOP = ..
include $(TOP)/mk/boilerplate.mk
ifeq "$(stage)" "2"
HC=$(GHC_STAGE1)
endif
ifeq "$(stage)" "3"
HC=$(GHC_STAGE2)
endif
EXCLUDED_C_SRCS += ghc-inplace.c
SRC_HC_OPTS += -Wall
SRC_HC_OPTS += -package ghc
SRC_HC_OPTS += -Istage$(stage)
SRC_HC_OPTS += \
-cpp -fglasgow-exts -XNoGenerics -Rghc-timing \
-I. -IcodeGen -InativeGen -Iparser
SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
ifeq "$(TargetOS_CPP)" "openbsd"
SRC_HC_OPTS += -optl-Xlinker -optl-E
endif
ifeq "$(GhcWithInterpreter)" "YES"
SRC_HC_OPTS += -DGHCI
# Should the debugger commands be enabled?
ifeq "$(GhciWithDebugger)" "YES"
SRC_HC_OPTS += -DDEBUGGER
endif
endif
ifeq "$(GhcThreaded)" "YES"
SRC_HC_OPTS += -threaded
endif
ifeq "$(GhcProfiled)" "YES"
SRC_HC_OPTS += -prof
endif
ifeq "$(GhcDebugged)" "YES"
SRC_LD_OPTS += -debug
endif
odir=stage$(stage)
HS_SRCS = main/Main.hs
HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
$(odir)/main/Main.o : libHSghc$(_way).a
WAYS=$(GhcCompilerWays)
include $(TOP)/mk/target.mk
# Local GHC-build-tree customization for Cabal makefiles. We want to build
# libraries using flags that the user has put in build.mk/validate.mk and
# appropriate flags for Mac OS X deployment targets.
# Careful here: including boilerplate.mk breaks things, because paths.mk and
# opts.mk overrides some of the variable settings in the Cabal Makefile, so
# we just include config.mk and custom-settings.mk.
TOP=..
SAVE_GHC := $(GHC)
SAVE_AR := $(AR)
SAVE_LD := $(LD)
include $(TOP)/mk/config.mk
include $(TOP)/mk/custom-settings.mk
GHC := $(SAVE_GHC)
AR := $(SAVE_AR)
LD := $(SAVE_LD)
# Now add flags from the GHC build system to the Cabal build:
GHC_CC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
GHC_OPTS += $(SRC_HC_OPTS)
GHC_OPTS += $(GhcHcOpts)
GHC_OPTS += $(GhcStage$(stage)HcOpts)
GHC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
LIB_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
# XXX These didn't work in the old build system, according to the
# comment at least. We should actually handle them properly at some
# point:
# Some .hs files #include other source files, but since ghc -M doesn't spit out
# these dependencies we have to include them manually.
# We don't add dependencies on HsVersions.h, ghcautoconf.h, or ghc_boot_platform.h,
# because then modifying one of these files would force recompilation of everything,
# which is probably not what you want. However, it does mean you have to be
# careful to recompile stuff you need if you reconfigure or change HsVersions.h.
# Aargh, these don't work properly anyway, because GHC's recompilation checker
# just reports "compilation NOT required". Do we have to add -fforce-recomp for each
# of these .hs files? I haven't done anything about this yet.
# $(odir)/codeGen/Bitmap.$(way_)o : ../includes/MachDeps.h
# $(odir)/codeGen/CgCallConv.$(way_)o : ../includes/StgFun.h
# $(odir)/codeGen/CgProf.$(way_)o : ../includes/MachDeps.h
# $(odir)/codeGen/CgProf.$(way_)o : ../includes/Constants.h
# $(odir)/codeGen/CgProf.$(way_)o : ../includes/DerivedConstants.h
# $(odir)/codeGen/CgTicky.$(way_)o : ../includes/DerivedConstants.h
# $(odir)/codeGen/ClosureInfo.$(way_)o : ../includes/MachDeps.h
# $(odir)/codeGen/SMRep.$(way_)o : ../includes/MachDeps.h
# $(odir)/codeGen/SMRep.$(way_)o : ../includes/ClosureTypes.h
# $(odir)/ghci/ByteCodeAsm.$(way_)o : ../includes/Bytecodes.h
# $(odir)/ghci/ByteCodeFFI.$(way_)o : nativeGen/NCG.h
# $(odir)/ghci/ByteCodeInstr.$(way_)o : ../includes/MachDeps.h
# $(odir)/ghci/ByteCodeItbls.$(way_)o : ../includes/ClosureTypes.h
# $(odir)/ghci/ByteCodeItbls.$(way_)o : nativeGen/NCG.h
# $(odir)/main/Constants.$(way_)o : ../includes/MachRegs.h
# $(odir)/main/Constants.$(way_)o : ../includes/Constants.h
# $(odir)/main/Constants.$(way_)o : ../includes/MachDeps.h
# $(odir)/main/Constants.$(way_)o : ../includes/DerivedConstants.h
# $(odir)/main/Constants.$(way_)o : ../includes/GHCConstants.h
# $(odir)/nativeGen/AsmCodeGen.$(way_)o : nativeGen/NCG.h
# $(odir)/nativeGen/MachCodeGen.$(way_)o : nativeGen/NCG.h
# $(odir)/nativeGen/MachCodeGen.$(way_)o : ../includes/MachDeps.h
# $(odir)/nativeGen/MachInstrs.$(way_)o : nativeGen/NCG.h
# $(odir)/nativeGen/MachRegs.$(way_)o : nativeGen/NCG.h
# $(odir)/nativeGen/MachRegs.$(way_)o : ../includes/MachRegs.h
# $(odir)/nativeGen/PositionIndependentCode.$(way_)o : nativeGen/NCG.h
# $(odir)/nativeGen/PprMach.$(way_)o : nativeGen/NCG.h
# $(odir)/nativeGen/RegAllocInfo.$(way_)o : nativeGen/NCG.h
# $(odir)/typecheck/TcForeign.$(way_)o : nativeGen/NCG.h
# $(odir)/utils/Binary.$(way_)o : ../includes/MachDeps.h
# $(odir)/utils/FastMutInt.$(way_)o : ../includes/MachDeps.h
# $(PRIMOP_BITS) is defined in Makefile
# $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
#! /usr/bin/perl
#
%DirCount = ();
%ModCount = ();
%DirComments = ();
%ModComments = ();
foreach $f ( @ARGV ) {
if ( $f =~ /\.lhs$/ ) {
open(INF, "../utils/unlit/unlit $f - |") || die "Couldn't unlit $f!\n";
} else {
open(INF, "< $f") || die "Couldn't open $f!\n";
}
$cnt = 0;
while (<INF>) {
s/--.*//;
s/{-.*-}//;
next if /^\s*$/;
$cnt++;
}
close(INF);
$f_wc = `wc $f`; die "wc failed: $f\n" if $? != 0;
if ( $f_wc =~ /\s*(\d+)\s*(\d+)\s*(\d+)/ ) {
$comments = $1 - $cnt;
} else {
die "Can't grok wc format: $f_wc";
}
if ( $f =~ /(.*)\/(.*)/ ) {
local($dir) = $1;
local($mod) = $2;
$DirCount{$dir} += $cnt;
$ModCount{$mod} += $cnt;
$DirComments{$dir} += $comments;
$ModComments{$mod} += $comments;
} else {
print STDERR "not counted in a directory: $f\n";
$ModCount{$f} += $cnt;
$ModComments{$f} += $comments;
}
}
# print the info
$tot = 0;
$totcmts = 0;
foreach $d (sort (keys %DirCount)) {
printf "%-20s %6d %6d\n", $d, $DirCount{$d}, $DirComments{$d};
$tot += $DirCount{$d};
$totcmts += $DirComments{$d};
}
printf "\n%-20s %6d %6d\n\n\n", 'TOTAL:', $tot, $totcmts;
$tot = 0;
$totcmts = 0;
printf "\n Code Comments\n";
foreach $m (sort (keys %ModCount)) {
printf "%-20s %6d %6d\n", $m, $ModCount{$m}, $ModComments{$m};
$tot += $ModCount{$m};
$totcmts += $ModComments{$m};
}
printf "\n%-20s %6d %6d\n", 'TOTAL:', $tot, $totcmts;
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <shell-tools.c>
int main(int argc, char **argv) {
char **args;
args = malloc(sizeof(char *) * (argc + 4));
if (args == NULL) {
fprintf(stderr, "Malloc failed\n");
exit(1);
}
args[0] = "GHC_PATH"; /* Gets replaced by sed */
args[1] = "-BTOP_ABS"; /* Gets replaced by sed */
args[2] = "-dynload";
args[3] = "wrapped";
if ((argc >= 2) && (strcmp(argv[1], "-v") == 0)) {
printf("Using %s %s %s %s\n", args[0], args[1], args[2], args[3]);
fflush(stdout);
}
memcpy(args + 4, argv + 1, sizeof(char *) * (argc - 1));
args[argc+3] = NULL;
return run(argv[0],
"GHC_PATH", /* Gets replaced by sed */
argc + 3,
args);
}
Name: ghc
-- XXX Version number!
Version: 6.9
Copyright: XXX
-- License: XXX
License-File: XXX
Author: XXX
Maintainer: glasgow-haskell-users@haskell.org
Homepage: http://www.haskell.org/ghc/
Synopsis: XXX
Description:
XXX
Category: XXX
Build-Type: Simple
Cabal-Version: >= 1.2
Flag base3
Description: Choose the new smaller, split-up base package.
Flag dynlibs
Description: Dynamic library support
Flag editline
Description: Use editline
Flag ghci
Description: Build GHCi support.
Flag stage1
Description: Is this stage 1?
Flag windows
Description: On a Windows machine
Library
if flag(base3)
Build-Depends: base >= 3 && < 4,
directory >= 1 && < 1.1,
process >= 1 && < 1.1,
bytestring >= 0.9 && < 0.10,
old-time >= 1 && < 1.1,
containers >= 0.1 && < 0.2,
array >= 0.1 && < 0.2
else
Build-Depends: base < 3
Build-Depends: filepath >= 1 && < 1.2
Build-Depends: haskell98, Cabal, hpc
if flag(windows)
Build-Depends: Win32
else
Build-Depends: unix
if flag(editline)
Build-Depends: editline
CPP-Options: -DUSE_EDITLINE
GHC-Options: -Wall -fno-warn-name-shadowing -fno-warn-orphans
if flag(ghci)
Build-Depends: template-haskell
CPP-Options: -DGHCI
Include-Dirs: ../libffi/build/include
Extensions: CPP, MagicHash, UnboxedTuples, PatternGuards,
ForeignFunctionInterface, EmptyDataDecls,
TypeSynonymInstances, MultiParamTypeClasses,
FlexibleInstances, Rank2Types, PatternSignatures
Include-Dirs: . parser utils
-- XXX Change these directory names: The stage2 files are what
-- we want for all stages >= 1
if flag(stage1)
Include-Dirs: stage1
else
Include-Dirs: stage2
Install-Includes: HsVersions.h, ghc_boot_platform.h
c-sources:
parser/cutils.c
utils/md5.c
-- For GHC < 6.5:
cbits/unicode.c
if flag(dynlibs)
c-sources:
ghci/keepCAFsForGHCi.c
hs-source-dirs:
basicTypes
cmm
codeGen
coreSyn
cprAnalysis
deSugar
ghci
hsSyn
iface
main
nativeGen
parser
prelude
profiling
rename
simplCore
simplStg
specialise
stgSyn
stranal
typecheck
types
utils
vectorise
Exposed-Modules:
BasicTypes
DataCon
Demand
Id
IdInfo
Literal
MkId
Module
Name
NameEnv
NameSet
NewDemand
OccName
RdrName
SrcLoc
UniqSupply
Unique
Var
VarEnv
VarSet
BlockId
CLabel
Cmm
CmmBrokenBlock
CmmCPS
CmmCPSGen
CmmCPSZ
CmmCallConv
CmmCommonBlockElimZ
CmmContFlowOpt
CmmCvt
CmmExpr
CmmInfo
CmmLex
CmmLint
CmmLive
CmmLiveZ
CmmOpt
CmmParse
CmmProcPoint
CmmProcPointZ
CmmSpillReload
CmmTx
CmmUtils
CmmZipUtil
DFMonad
Dataflow
MachOp
MkZipCfg
MkZipCfgCmm
OptimizationFuel
PprC
PprCmm
PprCmmZ
StackColor
StackPlacements
ZipCfg
ZipCfgCmmRep
ZipCfgExtras
ZipDataflow
Bitmap
CgBindery
CgCallConv
CgCase
CgClosure
CgCon
CgExpr
CgForeignCall
CgHeapery
CgHpc
CgInfoTbls
CgLetNoEscape
CgMonad
CgParallel
CgPrimOp
CgProf
CgStackery
CgTailCall
CgTicky
CgUtils
ClosureInfo
CodeGen
SMRep
CoreFVs
CoreLint
CorePrep
CoreSubst
CoreSyn
CoreTidy
CoreUnfold
CoreUtils
ExternalCore
MkExternalCore
PprCore
PprExternalCore
CprAnalyse
Check
Coverage
Desugar
DsArrows
DsBinds
DsCCall
DsExpr
DsForeign
DsGRHSs
DsListComp
DsMonad
DsUtils
Match
MatchCon
MatchLit
HsBinds
HsDecls
HsDoc
HsExpr
HsImpExp
HsLit
HsPat
HsSyn
HsTypes
HsUtils
BinIface
BuildTyCl
IfaceEnv
IfaceSyn
IfaceType
LoadIface
MkIface
TcIface
BreakArray
CmdLineParser
CodeOutput
Config
Constants
DriverMkDepend
DriverPhases
DriverPipeline
DynFlags
ErrUtils
Finder
GHC
HeaderInfo
HscMain
HscStats
HscTypes
InteractiveEval
PackageConfig
Packages
ParsePkgConf
PprTyThing
StaticFlags
SysTools
TidyPgm
AsmCodeGen
MachCodeGen
MachInstrs
MachRegs
NCGMonad
PositionIndependentCode
PprMach
RegAllocColor
RegAllocInfo
RegAllocLinear
RegAllocStats
RegArchBase
RegArchX86
RegCoalesce
RegLiveness
RegSpill
RegSpillClean
RegSpillCost
Ctype
HaddockLex
HaddockParse
HaddockUtils
LexCore
Lexer
Parser
ParserCore
ParserCoreUtils
RdrHsSyn
ForeignCall
PrelInfo
PrelNames
PrelRules
PrimOp
TysPrim
TysWiredIn
CostCentre
SCCfinal
RnBinds
RnEnv
RnExpr
RnHsDoc
RnHsSyn
RnNames
RnPat
RnSource
RnTypes
CSE
FloatIn
FloatOut
LiberateCase
OccurAnal
SAT
SetLevels
SimplCore
SimplEnv
SimplMonad
SimplUtils
Simplify
SRT
SimplStg
StgStats
Rules
SpecConstr
Specialise
CoreToStg
StgLint
StgSyn
DmdAnal
SaAbsInt
SaLib
StrictAnal
WorkWrap
WwLib
FamInst
Inst
TcArrows
TcBinds
TcClassDcl
TcDefaults
TcDeriv
TcEnv
TcExpr
TcForeign
TcGenDeriv
TcHsSyn
TcHsType
TcInstDcls
TcMType
TcMatches
TcPat
TcRnDriver
TcRnMonad
TcRnTypes
TcRules
TcSimplify
TcTyClsDecls
TcTyDecls
TcTyFuns
TcType
TcUnify
Class
Coercion
FamInstEnv
FunDeps
Generics
InstEnv
TyCon
Type
TypeRep
Unify
Bag
Binary
BufWrite
Digraph
Encoding
FastBool
FastFunctions
FastMutInt
FastString