Commit 9fff25ea authored by Simon Marlow's avatar Simon Marlow

Improve support for cross-compilation

Patchset from Stephen Blackheath <stephen.blackheath@ipwnstudios.com>
parent 4ff3a642
...@@ -526,7 +526,8 @@ AC_DEFUN([FP_EVAL_STDERR], ...@@ -526,7 +526,8 @@ AC_DEFUN([FP_EVAL_STDERR],
# XXX # XXX
# #
# $1 = the variable to set # $1 = the variable to set
# $2 = the command to look for # $2 = the with option name
# $3 = the command to look for
# #
AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG], AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG],
[ [
...@@ -544,10 +545,14 @@ AC_ARG_WITH($2, ...@@ -544,10 +545,14 @@ AC_ARG_WITH($2,
[ [
if test "$HostOS" != "mingw32" if test "$HostOS" != "mingw32"
then then
AC_PATH_PROG([$1], [$2]) if test "$target_alias" = "" ; then
AC_PATH_PROG([$1], [$3])
else
AC_PATH_PROG([$1], [$target_alias-$3])
fi
if test -z "$$1" if test -z "$$1"
then then
AC_MSG_ERROR([cannot find $2 in your PATH, no idea how to link]) AC_MSG_ERROR([cannot find $3 in your PATH, no idea how to link])
fi fi
fi fi
] ]
...@@ -635,7 +640,7 @@ AC_CHECK_TYPE([$1], [], [], [$3])[]dnl ...@@ -635,7 +640,7 @@ AC_CHECK_TYPE([$1], [], [], [$3])[]dnl
m4_pushdef([fp_Cache], [AS_TR_SH([fp_cv_alignment_$1])])[]dnl m4_pushdef([fp_Cache], [AS_TR_SH([fp_cv_alignment_$1])])[]dnl
AC_CACHE_CHECK([alignment of $1], [fp_Cache], AC_CACHE_CHECK([alignment of $1], [fp_Cache],
[if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
FP_COMPUTE_INT([(long) (&((struct { char c; $1 ty; } *)0)->ty)], FP_COMPUTE_INT([offsetof(struct { char c; $1 ty; },ty)],
[fp_Cache], [fp_Cache],
[AC_INCLUDES_DEFAULT([$3])], [AC_INCLUDES_DEFAULT([$3])],
[AC_MSG_ERROR([cannot compute alignment ($1) [AC_MSG_ERROR([cannot compute alignment ($1)
...@@ -1575,6 +1580,7 @@ AC_SUBST([ProjectPatchLevel]) ...@@ -1575,6 +1580,7 @@ AC_SUBST([ProjectPatchLevel])
# timer_create() in certain versions of Linux (see bug #1933). # timer_create() in certain versions of Linux (see bug #1933).
# #
AC_DEFUN([FP_CHECK_TIMER_CREATE], AC_DEFUN([FP_CHECK_TIMER_CREATE],
if test "$cross_compiling" = "no" ; then
[AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)], [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
[fptools_cv_timer_create_works], [fptools_cv_timer_create_works],
[AC_TRY_RUN([ [AC_TRY_RUN([
...@@ -1698,6 +1704,7 @@ case $fptools_cv_timer_create_works in ...@@ -1698,6 +1704,7 @@ case $fptools_cv_timer_create_works in
yes) AC_DEFINE([USE_TIMER_CREATE], 1, yes) AC_DEFINE([USE_TIMER_CREATE], 1,
[Define to 1 if we can use timer_create(CLOCK_PROCESS_CPUTIME_ID,...)]);; [Define to 1 if we can use timer_create(CLOCK_PROCESS_CPUTIME_ID,...)]);;
esac esac
fi
]) ])
# FP_ICONV # FP_ICONV
...@@ -1996,6 +2003,10 @@ AC_DEFUN([XCODE_VERSION],[ ...@@ -1996,6 +2003,10 @@ AC_DEFUN([XCODE_VERSION],[
# FIND_GCC() # FIND_GCC()
# -------------------------------- # --------------------------------
# Finds where gcc is # Finds where gcc is
#
# $1 = the variable to set
# $2 = the with option name
# $3 = the command to look for
AC_DEFUN([FIND_GCC],[ AC_DEFUN([FIND_GCC],[
if test "$TargetOS_CPP" = "darwin" && if test "$TargetOS_CPP" = "darwin" &&
test "$XCodeVersion1" -eq 4 && test "$XCodeVersion1" -eq 4 &&
...@@ -2004,13 +2015,11 @@ AC_DEFUN([FIND_GCC],[ ...@@ -2004,13 +2015,11 @@ AC_DEFUN([FIND_GCC],[
# In Xcode 4.1, 'gcc-4.2' is the gcc legacy backend (rather # In Xcode 4.1, 'gcc-4.2' is the gcc legacy backend (rather
# than the LLVM backend). We prefer the legacy gcc, but in # than the LLVM backend). We prefer the legacy gcc, but in
# Xcode 4.2 'gcc-4.2' was removed. # Xcode 4.2 'gcc-4.2' was removed.
FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc-4.2]) FP_ARG_WITH_PATH_GNU_PROG([$1], [gcc-4.2], [gcc-4.2])
else else
FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc]) FP_ARG_WITH_PATH_GNU_PROG([$1], [$2], [$3])
fi fi
export CC AC_SUBST($1)
WhatGccIsCalled="$CC"
AC_SUBST(WhatGccIsCalled)
]) ])
# LocalWords: fi # LocalWords: fi
...@@ -150,6 +150,10 @@ $(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs)) ...@@ -150,6 +150,10 @@ $(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs))
PLATFORM_H = ghc_boot_platform.h PLATFORM_H = ghc_boot_platform.h
ifeq "$(BuildingCrossCompiler)" "YES"
compiler/stage1/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
cp $< $@
else
compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
$(call removeFiles,$@) $(call removeFiles,$@)
@echo "Creating $@..." @echo "Creating $@..."
...@@ -192,6 +196,7 @@ endif ...@@ -192,6 +196,7 @@ endif
@echo >> $@ @echo >> $@
@echo "#endif /* __PLATFORM_H__ */" >> $@ @echo "#endif /* __PLATFORM_H__ */" >> $@
@echo "Done." @echo "Done."
endif
# For stage2 and above, the BUILD platform is the HOST of stage1, and # For stage2 and above, the BUILD platform is the HOST of stage1, and
# the HOST platform is the TARGET of stage1. The TARGET remains the same # the HOST platform is the TARGET of stage1. The TARGET remains the same
......
...@@ -333,19 +333,75 @@ then ...@@ -333,19 +333,75 @@ then
fi fi
AC_SUBST([SplitObjsBroken]) AC_SUBST([SplitObjsBroken])
dnl ** Building a cross compiler?
dnl --------------------------------------------------------------
BuildingCrossCompiler=NO
PortingCompiler=NO
CrossCompiling=NO
# If 'host' and 'target' differ, then this means we are building a cross-compiler.
if test "$host" != "$target" ; then
BuildingCrossCompiler=YES
CrossCompiling=YES
cross_compiling=yes # This tells configure that it can accept just 'target',
# otherwise you get
# configure: error: cannot run C compiled programs.
# If you meant to cross compile, use `--host'.
fi
if test "$build" != "$host" ; then
CrossCompiling=YES
PortingCompiler=YES
fi
# Note: cross_compiling is set to 'yes' in both 'port' and 'toolchain' cases
if ! test "$host" == "$target" -o "$host" == "$build" ; then
AC_MSG_ERROR([
You've selected:
build: $build (the architecture we're building on)
host: $host (the architecture the compiler we're building will execute on)
target: $target (the architecture the compiler we're building will produce code for)
host must equal build or target. The two allowed cases are:
--host=<arch> --target=<arch> to _port_ GHC to run on a foreign architecture
and produce code for that architecture
--target=<arch> to build a cross compiler _toolchain_ that runs
locally but produces code for a foreign
architecture
])
fi
if [[ "$CrossCompiling" == "YES" ]] ; then
CrossCompilePrefix="${target}-"
else
CrossCompilePrefix=""
fi
TargetPlatformFull="${target}"
AC_SUBST(BuildingCrossCompiler) # 'toolchain' case
AC_SUBST(PortingCompiler) # 'port' case
AC_SUBST(CrossCompiling) # BuildingCrossCompiler OR PortingCompiler
AC_SUBST(CrossCompilePrefix)
AC_SUBST(TargetPlatformFull)
AC_ARG_WITH([alien],
[AC_HELP_STRING([--with-alien=ARG],
[Supply script for running target binaries locally when cross-compiling])],
[AlienScript="$withval"],
[AlienScript=""])
AC_SUBST(AlienScript)
dnl ** Which gcc to use? dnl ** Which gcc to use?
dnl -------------------------------------------------------------- dnl --------------------------------------------------------------
FIND_GCC() FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
CC="$WhatGccIsCalled"
export CC
dnl ** Which ld to use? dnl ** Which ld to use?
dnl -------------------------------------------------------------- dnl --------------------------------------------------------------
FP_ARG_WITH_PATH_GNU_PROG([LD], [ld]) FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
LdCmd="$LD" LdCmd="$LD"
AC_SUBST([LdCmd]) AC_SUBST([LdCmd])
dnl ** Which nm to use? dnl ** Which nm to use?
dnl -------------------------------------------------------------- dnl --------------------------------------------------------------
FP_ARG_WITH_PATH_GNU_PROG([NM], [nm]) FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm])
NmCmd="$NM" NmCmd="$NM"
AC_SUBST([NmCmd]) AC_SUBST([NmCmd])
...@@ -642,17 +698,19 @@ dnl ** check for more functions ...@@ -642,17 +698,19 @@ dnl ** check for more functions
dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too. dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale]) AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r sched_setaffinity setlocale])
AC_TRY_RUN([ if test "$cross_compiling" = "no" ; then
#include <sys/types.h> AC_TRY_RUN([
#include <sys/time.h> #include <sys/types.h>
int main(void) { #include <sys/time.h>
struct itimerval tval; int main(void) {
tval.it_value.tv_sec = 1; struct itimerval tval;
tval.it_value.tv_usec = 0; tval.it_value.tv_sec = 1;
tval.it_interval = tval.it_value; tval.it_value.tv_usec = 0;
return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0; tval.it_interval = tval.it_value;
} return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0;
],[AC_DEFINE([HAVE_SETITIMER_VIRTUAL], [1], [Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else.])]) }
],[AC_DEFINE([HAVE_SETITIMER_VIRTUAL], [1], [Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else.])])
fi
dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
dnl ** _POSIX_C_SOURCE is defined dnl ** _POSIX_C_SOURCE is defined
...@@ -852,8 +910,11 @@ echo ["\ ...@@ -852,8 +910,11 @@ echo ["\
fi fi
echo ["\ echo ["\
Using GCC : $WhatGccIsCalled Using GCC : $WhatGccIsCalled
which is version : $GccVersion which is version : $GccVersion
Building a cross compiler : $BuildingCrossCompiler
Porting to foreign arch : $PortingCompiler
Alien script : $AlienScript
ld : $LdCmd ld : $LdCmd
Happy : $HappyCmd ($HappyVersion) Happy : $HappyCmd ($HappyVersion)
......
...@@ -380,7 +380,9 @@ endef ...@@ -380,7 +380,9 @@ endef
define addPackage # args: $1 = package, $2 = condition define addPackage # args: $1 = package, $2 = condition
ifneq "$(filter $1,$(PKGS_THAT_USE_TH)) $(GhcProfiled)" "$1 YES" ifneq "$(filter $1,$(PKGS_THAT_USE_TH)) $(GhcProfiled)" "$1 YES"
ifeq "$(filter $1,$(PKGS_THAT_BUILD_WITH_STAGE2))" "$1" ifeq "$(filter $1,$(PKGS_THAT_BUILD_WITH_STAGE2))" "$1"
ifneq "$(BuildingCrossCompiler)" "YES"
$(call addPackageGeneral,PACKAGES_STAGE2,$1,$2) $(call addPackageGeneral,PACKAGES_STAGE2,$1,$2)
endif
else else
$(call addPackageGeneral,PACKAGES_STAGE1,$1,$2) $(call addPackageGeneral,PACKAGES_STAGE1,$1,$2)
endif endif
...@@ -574,9 +576,15 @@ BUILD_DIRS += \ ...@@ -574,9 +576,15 @@ BUILD_DIRS += \
$(GHC_GENPRIMOP_DIR) $(GHC_GENPRIMOP_DIR)
endif endif
ifeq "$(BuildingCrossCompiler)-$(phase)" "YES-final"
MAYBE_GHCI=
else
MAYBE_GHCI=driver/ghci
endif
BUILD_DIRS += \ BUILD_DIRS += \
driver \ driver \
driver/ghci \ $(MAYBE_GHCI) \
driver/ghc \ driver/ghc \
driver/haddock \ driver/haddock \
libffi \ libffi \
...@@ -600,24 +608,38 @@ else ifneq "$(findstring clean,$(MAKECMDGOALS))" "" ...@@ -600,24 +608,38 @@ else ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
BUILD_DIRS += libraries/integer-gmp/gmp BUILD_DIRS += libraries/integer-gmp/gmp
endif endif
ifeq "$(BuildingCrossCompiler)-$(phase)" "YES-final"
MAYBE_COMPILER=
MAYBE_GHCTAGS=
MAYBE_HPC=
MAYBE_RUNGHC=
else
MAYBE_COMPILER=compiler
MAYBE_GHCTAGS=utils/ghctags
MAYBE_HPC=utils/hpc
MAYBE_RUNGHC=utils/runghc
endif
BUILD_DIRS += \ BUILD_DIRS += \
utils/haddock \ utils/haddock \
utils/haddock/doc \ utils/haddock/doc \
compiler \ $(MAYBE_COMPILER) \
$(GHC_HSC2HS_DIR) \ $(GHC_HSC2HS_DIR) \
$(GHC_PKG_DIR) \ $(GHC_PKG_DIR) \
utils/testremove \ utils/testremove \
utils/ghctags \ $(MAYBE_GHCTAGS) \
utils/ghc-pwd \ utils/ghc-pwd \
$(GHC_CABAL_DIR) \ $(GHC_CABAL_DIR) \
utils/hpc \ $(MAYBE_HPC) \
utils/runghc \ $(MAYBE_RUNGHC) \
ghc ghc
ifneq "$(BINDIST)" "YES" ifneq "$(BINDIST)" "YES"
ifneq "$(BuildingCrossCompiler)-$(phase)" "YES-final"
BUILD_DIRS += \ BUILD_DIRS += \
utils/mkUserGuidePart utils/mkUserGuidePart
endif endif
endif
BUILD_DIRS += utils/count_lines BUILD_DIRS += utils/count_lines
BUILD_DIRS += utils/compare_sizes BUILD_DIRS += utils/compare_sizes
...@@ -810,7 +832,7 @@ else ...@@ -810,7 +832,7 @@ else
done done
# We rename ghc-stage2, so that the right program name is used in error # We rename ghc-stage2, so that the right program name is used in error
# messages etc. # messages etc.
"$(MV)" "$(DESTDIR)$(ghclibexecdir)/ghc-stage2" "$(DESTDIR)$(ghclibexecdir)/ghc" "$(MV)" "$(DESTDIR)$(ghclibexecdir)/ghc-stage$(INSTALL_GHC_STAGE)" "$(DESTDIR)$(ghclibexecdir)/ghc"
endif endif
install_topdirs: $(INSTALL_TOPDIRS) install_topdirs: $(INSTALL_TOPDIRS)
...@@ -855,9 +877,11 @@ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe ...@@ -855,9 +877,11 @@ INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
endif endif
INSTALLED_PKG_DIRS := $(addprefix libraries/,$(PACKAGES_STAGE1)) \ INSTALLED_PKG_DIRS := $(addprefix libraries/,$(PACKAGES_STAGE1))
compiler \ ifeq "$(BuildingCrossCompiler)" "NO"
$(addprefix libraries/,$(PACKAGES_STAGE2)) INSTALLED_PKG_DIRS := $(INSTALLED_PKG_DIRS) compiler
endif
INSTALLED_PKG_DIRS := $(INSTALLED_PKG_DIRS) $(addprefix libraries/,$(PACKAGES_STAGE2))
ifeq "$(InstallExtraPackages)" "NO" ifeq "$(InstallExtraPackages)" "NO"
INSTALLED_PKG_DIRS := $(filter-out $(addprefix libraries/,$(EXTRA_PACKAGES)),\ INSTALLED_PKG_DIRS := $(filter-out $(addprefix libraries/,$(EXTRA_PACKAGES)),\
$(INSTALLED_PKG_DIRS)) $(INSTALLED_PKG_DIRS))
...@@ -879,6 +903,7 @@ install_packages: rts/package.conf.install ...@@ -879,6 +903,7 @@ install_packages: rts/package.conf.install
"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install "$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
$(foreach p, $(INSTALLED_PKG_DIRS), \ $(foreach p, $(INSTALLED_PKG_DIRS), \
$(call make-command, \ $(call make-command, \
CROSS_COMPILE="$(CrossCompilePrefix)" \
"$(GHC_CABAL_INPLACE)" install \ "$(GHC_CABAL_INPLACE)" install \
"$(INSTALLED_GHC_REAL)" \ "$(INSTALLED_GHC_REAL)" \
"$(INSTALLED_GHC_PKG_REAL)" \ "$(INSTALLED_GHC_PKG_REAL)" \
......
...@@ -86,6 +86,10 @@ endif ...@@ -86,6 +86,10 @@ endif
ifneq "$(filter-out 2,$(stage))" "" ifneq "$(filter-out 2,$(stage))" ""
ghc_stage2_NOT_NEEDED = YES ghc_stage2_NOT_NEEDED = YES
endif endif
# When cross-compiling, the stage 1 compiler is our release compiler, so omit stage 2
ifeq "$(BuildingCrossCompiler)" "YES"
ghc_stage2_NOT_NEEDED = YES
endif
# stage 3 has to be requested explicitly with stage=3 # stage 3 has to be requested explicitly with stage=3
ifneq "$(stage)" "3" ifneq "$(stage)" "3"
ghc_stage3_NOT_NEEDED = YES ghc_stage3_NOT_NEEDED = YES
...@@ -147,7 +151,7 @@ install: install_ghc_link ...@@ -147,7 +151,7 @@ install: install_ghc_link
.PNONY: install_ghc_link .PNONY: install_ghc_link
install_ghc_link: install_ghc_link:
$(call removeFiles,"$(DESTDIR)$(bindir)/ghc") $(call removeFiles,"$(DESTDIR)$(bindir)/ghc")
$(LN_S) ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghc" $(LN_S) $(CrossCompilePrefix)ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc"
else else
# On Windows we install the main binary as $(bindir)/ghc.exe # On Windows we install the main binary as $(bindir)/ghc.exe
# To get ghc-<version>.exe we have a little C program in driver/ghc # To get ghc-<version>.exe we have a little C program in driver/ghc
...@@ -155,6 +159,6 @@ install: install_ghc_post ...@@ -155,6 +159,6 @@ install: install_ghc_post
.PHONY: install_ghc_post .PHONY: install_ghc_post
install_ghc_post: install_bins install_ghc_post: install_bins
$(call removeFiles,$(DESTDIR)$(bindir)/ghc.exe) $(call removeFiles,$(DESTDIR)$(bindir)/ghc.exe)
"$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc.exe
endif endif
...@@ -129,7 +129,7 @@ endif ...@@ -129,7 +129,7 @@ endif
includes_DERIVEDCONSTANTS = includes/dist-derivedconstants/header/DerivedConstants.h includes_DERIVEDCONSTANTS = includes/dist-derivedconstants/header/DerivedConstants.h
ifeq "$(PORTING_HOST)" "YES" ifeq "$(PORTING_HOST)-$(AlienScript)" "YES-"
DerivedConstants.h : DerivedConstants.h :
@echo "*** Cross-compiling: please copy DerivedConstants.h from the target system" @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
...@@ -145,9 +145,18 @@ $(eval $(call build-prog,includes,dist-derivedconstants,0)) ...@@ -145,9 +145,18 @@ $(eval $(call build-prog,includes,dist-derivedconstants,0))
$(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES) $(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM) includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
ifneq "$(AlienScript)" ""
$(INPLACE_BIN)/mkDerivedConstants$(exeext): includes/$(includes_dist-derivedconstants_C_SRCS) | $$(dir $$@)/.
$(WhatGccIsCalled) -o $@ $< $(CFLAGS) $(includes_CC_OPTS)
endif
ifneq "$(BINDIST)" "YES" ifneq "$(BINDIST)" "YES"
$(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/. $(includes_DERIVEDCONSTANTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
ifeq "$(AlienScript)" ""
./$< >$@ ./$< >$@
else
$(AlienScript) run ./$< >$@
endif
endif endif
endif endif
...@@ -157,7 +166,7 @@ endif ...@@ -157,7 +166,7 @@ endif
includes_GHCCONSTANTS = includes/dist-ghcconstants/header/GHCConstants.h includes_GHCCONSTANTS = includes/dist-ghcconstants/header/GHCConstants.h
ifeq "$(PORTING_HOST)" "YES" ifeq "$(PORTING_HOST)-$(AlienScript)" "YES-"
$(includes_GHCCONSTANTS) : $(includes_GHCCONSTANTS) :
@echo "*** Cross-compiling: please copy DerivedConstants.h from the target system" @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
...@@ -176,8 +185,17 @@ $(includes_dist-ghcconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_ ...@@ -176,8 +185,17 @@ $(includes_dist-ghcconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_
includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM) includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
ifneq "$(AlienScript)" ""
$(INPLACE_BIN)/mkGHCConstants$(exeext): includes/$(includes_dist-ghcconstants_C_SRCS) | $$(dir $$@)/.
$(WhatGccIsCalled) -o $@ $< $(CFLAGS) $(includes_CC_OPTS) $(includes_dist-ghcconstants_CC_OPTS)
endif
$(includes_GHCCONSTANTS) : $(INPLACE_BIN)/mkGHCConstants$(exeext) | $$(dir $$@)/. $(includes_GHCCONSTANTS) : $(INPLACE_BIN)/mkGHCConstants$(exeext) | $$(dir $$@)/.
ifeq "$(AlienScript)" ""
./$< >$@ ./$< >$@
else
$(AlienScript) run ./$< >$@
endif
endif endif
endif endif
......
...@@ -82,7 +82,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP) ...@@ -82,7 +82,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
--prefix=$(TOP)/libffi/build/inst \ --prefix=$(TOP)/libffi/build/inst \
--enable-static=yes \ --enable-static=yes \
--enable-shared=$(libffi_EnableShared) \ --enable-shared=$(libffi_EnableShared) \
--host=$(HOSTPLATFORM) --build=$(BUILDPLATFORM) --host=$(TargetPlatformFull)
# wc on OS X has spaces in its output, which libffi's Makefile # wc on OS X has spaces in its output, which libffi's Makefile
# doesn't expect, so we tweak it to sed them out # doesn't expect, so we tweak it to sed them out
......
...@@ -139,7 +139,7 @@ PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\ ...@@ -139,7 +139,7 @@ PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
# the compiler you build with is generating registerised binaries), but # the compiler you build with is generating registerised binaries), but
# the stage2 compiler will be an unregisterised binary. # the stage2 compiler will be an unregisterised binary.
# #
ifneq "$(findstring $(HostArch_CPP), i386 x86_64 powerpc arm)" "" ifneq "$(findstring $(TargetArch_CPP), i386 x86_64 powerpc arm)" ""
GhcUnregisterised=NO GhcUnregisterised=NO
else else
GhcUnregisterised=YES GhcUnregisterised=YES
...@@ -151,8 +151,8 @@ endif ...@@ -151,8 +151,8 @@ endif
# Target platforms supported: # Target platforms supported:
# i386, powerpc # i386, powerpc
# AIX is not supported # AIX is not supported
ArchSupportsNCG=$(strip $(patsubst $(HostArch_CPP), YES, $(findstring $(HostArch_CPP), i386 x86_64 powerpc sparc))) ArchSupportsNCG=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc sparc)))
OsSupportsNCG=$(strip $(patsubst $(HostOS_CPP), YES, $(patsubst aix,,$(HostOS_CPP)))) OsSupportsNCG=$(strip $(patsubst $(TargetOS_CPP), YES, $(patsubst aix,,$(TargetOS_CPP))))
# lazy test, because $(GhcUnregisterised) might be set in build.mk later. # lazy test, because $(GhcUnregisterised) might be set in build.mk later.
GhcWithNativeCodeGen=$(strip\ GhcWithNativeCodeGen=$(strip\
...@@ -163,7 +163,7 @@ HaveLibDL = @HaveLibDL@ ...@@ -163,7 +163,7 @@ HaveLibDL = @HaveLibDL@
# ArchSupportsSMP should be set iff there is support for that arch in # ArchSupportsSMP should be set iff there is support for that arch in
# includes/stg/SMP.h # includes/stg/SMP.h
ArchSupportsSMP=$(strip $(patsubst $(HostArch_CPP), YES, $(findstring $(HostArch_CPP), i386 x86_64 sparc powerpc arm))) ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc arm)))
# lazy test, because $(GhcUnregisterised) might be set in build.mk later. # lazy test, because $(GhcUnregisterised) might be set in build.mk later.
GhcWithSMP=$(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO)) GhcWithSMP=$(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
...@@ -171,8 +171,8 @@ GhcWithSMP=$(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)), ...@@ -171,8 +171,8 @@ GhcWithSMP=$(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),
# Whether to include GHCi in the compiler. Depends on whether the RTS linker # Whether to include GHCi in the compiler. Depends on whether the RTS linker
# has support for this OS/ARCH combination. # has support for this OS/ARCH combination.
OsSupportsGHCi=$(strip $(patsubst $(HostOS_CPP), YES, $(findstring $(HostOS_CPP), mingw32 cygwin32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu))) OsSupportsGHCi=$(strip $(patsubst $(TargetOS_CPP), YES, $(findstring $(TargetOS_CPP), mingw32 cygwin32 linux solaris2 freebsd dragonfly netbsd openbsd darwin kfreebsdgnu)))
ArchSupportsGHCi=$(strip $(patsubst $(HostArch_CPP), YES, $(findstring $(HostArch_CPP), i386 x86_64 powerpc sparc sparc64))) ArchSupportsGHCi=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 powerpc sparc sparc64)))
ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES" ifeq "$(OsSupportsGHCi)$(ArchSupportsGHCi)" "YESYES"
GhcWithInterpreter=YES GhcWithInterpreter=YES
...@@ -194,7 +194,7 @@ endif ...@@ -194,7 +194,7 @@ endif
# Whether to use libffi for adjustors (foreign import "wrapper") or # Whether to use libffi for adjustors (foreign import "wrapper") or
# not. If we have built-in support (rts/Adjustor.c) then we use that, # not. If we have built-in support (rts/Adjustor.c) then we use that,
# otherwise we fall back on libffi, which is slightly slower. # otherwise we fall back on libffi, which is slightly slower.
ArchHasAdjustorSupport = $(if $(findstring $(HostArch_CPP),i386 x86_64),YES,NO) ArchHasAdjustorSupport = $(if $(findstring $(TargetArch_CPP),i386 x86_64),YES,NO)
ifeq "$(ArchHasAdjustorSupport)" "YES" ifeq "$(ArchHasAdjustorSupport)" "YES"
UseLibFFIForAdjustors=NO UseLibFFIForAdjustors=NO
else else
...@@ -515,9 +515,6 @@ GHC_STAGE1 = $(INPLACE_BIN)/ghc-stage1$(exeext) ...@@ -515,9 +515,6 @@ GHC_STAGE1 = $(INPLACE_BIN)/ghc-stage1$(exeext)
GHC_STAGE2 = $(INPLACE_BIN)/ghc-stage2$(exeext) GHC_STAGE2 = $(INPLACE_BIN)/ghc-stage2$(exeext)
GHC_STAGE3 = $(INPLACE_BIN)/ghc-stage3$(exeext) GHC_STAGE3 = $(INPLACE_BIN)/ghc-stage3$(exeext)
# Install stage 2 by default, can be changed to 3
INSTALL_GHC_STAGE=2
BOOTSTRAPPING_CONF = libraries/bootstrapping.conf BOOTSTRAPPING_CONF = libraries/bootstrapping.conf
INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d INPLACE_PACKAGE_CONF = $(INPLACE_LIB)/package.conf.d
...@@ -553,8 +550,17 @@ endif ...@@ -553,8 +550,17 @@ endif
# the flag --with-gcc=<blah> instead. The reason is that the configure script # the flag --with-gcc=<blah> instead. The reason is that the configure script
# needs to know which gcc you're using in order to perform its tests. # needs to know which gcc you're using in order to perform its tests.
WhatGccIsCalled = @WhatGccIsCalled@ WhatGccIsCalled = @WhatGccIsCalled@
GccVersion = @GccVersion@ GccVersion = @GccVersion@
AlienScript = @AlienScript@
ifeq "$(phase)" "0"