bootstrap.mk 5.47 KB
Newer Older
1
# -----------------------------------------------------------------------------
2
# $Id: bootstrap.mk,v 1.34 2005/05/10 10:29:49 simonmar Exp $
3 4 5
#
# Makefile rules for booting from .hc files without a driver.
#
6 7 8 9
# When booting from .hc files without a compiler installed, we don't have
# the benefit of the GHC driver to add all the magic options required to
# compile the .hc files, so we have to duplicate that functionality here.
# The result is unfortunately ugly, but we don't have another choice.
10 11 12 13 14 15 16 17 18 19 20

# -----------------------------------------------------------------------------
# Set the platform-specific options to send to the C compiler.  These should
# match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs.
#

PLATFORM_CC_OPTS =
PLATFORM_HC_BOOT_CC_OPTS =

ifeq "$(i386_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -DDONT_WANT_WIN32_DLL_SUPPORT
21 22 23 24 25
PLATFORM_HC_BOOT_CC_OPTS += -fno-defer-pop -fomit-frame-pointer -fno-builtin
endif

ifeq "$(x86_64_TARGET_ARCH)" "1"
PLATFORM_HC_BOOT_CC_OPTS += -fomit-frame-pointer -fno-asynchronous-unwind-tables -fno-unit-at-a-time -fno-builtin
26 27 28
endif

ifeq "$(hppa_TARGET_ARCH)" "1"
29
PLATFORM_CC_OPTS += -D_HPUX_SOURCE
30 31 32 33 34 35 36 37 38
endif

ifeq "$(powerpc_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -static
PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
endif

ifeq "$(rs6000_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -static
ken's avatar
ken committed
39
PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
40 41
endif

ken's avatar
ken committed
42
ifeq "$(alpha_TARGET_ARCH)" "1"
ken's avatar
ken committed
43
PLATFORM_CC_OPTS += -static -w
ken's avatar
ken committed
44
PLATFORM_HC_BOOT_CC_OPTS += -mieee
ken's avatar
ken committed
45 46 47 48
endif

ifeq "$(sparc_TARGET_ARCH)" "1"
PLATFORM_HC_BOOT_CC_OPTS += -w
ken's avatar
ken committed
49 50
endif

sof's avatar
sof committed
51
ifeq "$(BootingFromUnregisterisedHc)" "YES"
52
PLATFORM_HC_BOOT_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
sof's avatar
sof committed
53 54
endif

55 56
PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 

57
HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
58

59
SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/$(GHC_INCLUDE_DIR_REL) -I$(FPTOOLS_TOP_ABS)/libraries/base/include -I$(FPTOOLS_TOP_ABS)/libraries/unix/include -I$(FPTOOLS_TOP_ABS)/libraries/parsec/include
60

61 62 63 64 65 66
# C code compiled with UseGhcForCc=YES assumes the existence of certain CPP
# symbols defined by GHC (eg. __GLASGOW_HASKELL__), so we better make sure
# they're defined.  We can't test $(UseGhcForCc) here though - it isn't defined
# yet, so we use lazy expansion.
SRC_CC_OPTS += $(if $(findstring YES,$(UseGhcForCc)), $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS))

67 68 69 70
ifeq "$(GhcWithInterpreter)" "YES"
SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/libraries/readline/include
endif

71 72 73
# -----------------------------------------------------------------------------
# Linking: we have to give all the libraries explicitly.

sof's avatar
sof committed
74 75 76 77 78 79
ifeq "$(LeadingUnderscore)" "YES"
UNDERSCORE=_
else
UNDERSCORE=
endif

80
HC_BOOT_LD_OPTS =				\
81
   -L$(FPTOOLS_TOP_ABS)/$(GHC_RTS_DIR_REL)	\
82 83
   -L$(FPTOOLS_TOP_ABS)/libraries/base		\
   -L$(FPTOOLS_TOP_ABS)/libraries/base/cbits	\
84 85
   -L$(FPTOOLS_TOP_ABS)/libraries/haskell98	\
   -L$(FPTOOLS_TOP_ABS)/libraries/parsec        \
86 87 88
   -L$(FPTOOLS_TOP_ABS)/libraries/regex-base    \
   -L$(FPTOOLS_TOP_ABS)/libraries/regex-posix   \
   -L$(FPTOOLS_TOP_ABS)/libraries/regex-compat  \
89
   -L$(FPTOOLS_TOP_ABS)/libraries/Cabal
90 91 92

ifeq "$(GhcWithInterpreter)" "YES"
HC_BOOT_LD_OPTS += \
93
   -L$(FPTOOLS_TOP_ABS)/libraries/template-haskell	\
94 95 96 97 98 99
   -L$(FPTOOLS_TOP_ABS)/libraries/readline	\
   -L$(FPTOOLS_TOP_ABS)/libraries/unix          \
   -L$(FPTOOLS_TOP_ABS)/libraries/unix/cbits
endif

HC_BOOT_LD_OPTS += \
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
   -u "$(UNDERSCORE)base_GHCziBase_Izh_static_info" \
   -u "$(UNDERSCORE)base_GHCziBase_Czh_static_info" \
   -u "$(UNDERSCORE)base_GHCziFloat_Fzh_static_info" \
   -u "$(UNDERSCORE)base_GHCziFloat_Dzh_static_info" \
   -u "$(UNDERSCORE)base_GHCziPtr_Ptr_static_info" \
   -u "$(UNDERSCORE)base_GHCziWord_Wzh_static_info" \
   -u "$(UNDERSCORE)base_GHCziInt_I8zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziInt_I16zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziInt_I32zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziInt_I64zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziWord_W8zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziWord_W16zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziWord_W32zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziWord_W64zh_static_info" \
   -u "$(UNDERSCORE)base_GHCziStable_StablePtr_static_info" \
   -u "$(UNDERSCORE)base_GHCziBase_Izh_con_info" \
   -u "$(UNDERSCORE)base_GHCziBase_Czh_con_info" \
   -u "$(UNDERSCORE)base_GHCziFloat_Fzh_con_info" \
   -u "$(UNDERSCORE)base_GHCziFloat_Dzh_con_info" \
   -u "$(UNDERSCORE)base_GHCziPtr_Ptr_con_info" \
   -u "$(UNDERSCORE)base_GHCziStable_StablePtr_con_info" \
   -u "$(UNDERSCORE)base_GHCziBase_False_closure" \
   -u "$(UNDERSCORE)base_GHCziBase_True_closure" \
   -u "$(UNDERSCORE)base_GHCziPack_unpackCString_closure" \
   -u "$(UNDERSCORE)base_GHCziIOBase_stackOverflow_closure" \
   -u "$(UNDERSCORE)base_GHCziIOBase_heapOverflow_closure" \
126
   -u "$(UNDERSCORE)base_GHCziIOBase_nonTermination_closure" \
127 128 129
   -u "$(UNDERSCORE)base_GHCziIOBase_BlockedOnDeadMVar_closure" \
   -u "$(UNDERSCORE)base_GHCziIOBase_Deadlock_closure" \
   -u "$(UNDERSCORE)base_GHCziWeak_runFinalizzerBatch_closure" \
sof's avatar
sof committed
130
   -u "$(UNDERSCORE)__stginit_Prelude"
131

132 133 134 135

HC_BOOT_LIBS =

ifeq "$(GhcWithInterpreter)" "YES"
136
HC_BOOT_LIBS += -lHSreadline -lHStemplate-haskell -lHSunix -lHSunix_cbits
137 138
endif

139
HC_BOOT_LIBS +=  -lHSregex-compat -lHSregex-posix -lHSregex-base -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm -lrt $(EXTRA_HC_BOOT_LIBS)
140 141

ifeq "$(GhcLibsWithReadline)" "YES"
142
HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
143 144 145 146 147
endif

ifeq "$(HaveLibDL)" "YES"
HC_BOOT_LIBS += -ldl
endif