Commit 430453c5 authored by Ian Lynagh's avatar Ian Lynagh

Rework the build system a bit

Key changes:
* Always build as if BIN_DIST is 1. BIN_DIST is thus removed.
* Libraries are configured with prefix set to $$topdir rather than $(prefix)
parent ad9d754d
......@@ -135,6 +135,7 @@ endif
# Same as default rule, but we pass $(INSTALL_STAGE) to $(MAKE) too
install :: check-packages
$(INSTALL_DIR) $(bindir)
@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
for i in $(SUBDIRS); do \
echo "------------------------------------------------------------------------"; \
......@@ -248,10 +249,6 @@ BINARY_DIST_PRE_RULES=$(foreach d,$(BinDistDirs),binary-dist-pre-$d)
binary-dist:: binary-dist-pre $(BINARY_DIST_PRE_RULES)
binary-dist-pre::
ifeq "$(BIN_DIST)" ""
@echo "WARNING: To run the binary-dist target, you need to set BIN_DIST=1 in mk/build.mk"
@false
endif
-rm -rf $(BIN_DIST_DIR)
-$(RM) $(BIN_DIST_DIR).tar.gz
$(MKDIRHIER) $(BIN_DIST_DIR)/bin/$(TARGETPLATFORM)
......
......@@ -6,7 +6,6 @@
#
# To use:
#
# - make sure you set BIN_DIST=1 in your mk/build.mk before you built GHC.
# $ cd <top of GHC build tree>
# $ make binary-dist
#
......
......@@ -8,23 +8,18 @@ include $(TOP)/mk/boilerplate.mk
# -----------------------------------------------------------------------------
# ghc script
ifeq "$(BIN_DIST)" "1"
GHCBIN=$$\"\"libexecdir/ghc-$(ProjectVersion)
GHCLIB=$$\"\"libdir
else
GHCBIN=$(libexecdir)/ghc-$(ProjectVersion)
GHCLIB=$(libdir)
endif # BIN_DIST
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
SCRIPT_PROG = ghc-$(ProjectVersion)
LINK = ghc
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
LINK = ghc
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
echo "GHCBIN=$(libexecdir)/ghc-$(ProjectVersion)" >> $(INSTALLED_SCRIPT)
echo "TOPDIROPT=-B$(libdir)" >> $(INSTALLED_SCRIPT)
echo 'exec $$GHCBIN $$TOPDIROPT $${1+"$$@"}' >> $(INSTALLED_SCRIPT)
$(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
endif
SCRIPT_OBJS = ghc.sh
INTERP = $(SHELL)
TOPDIROPT = -B$(GHCLIB)
SCRIPT_SUBST_VARS = GHCBIN TOPDIROPT
INSTALL_SCRIPTS += $(SCRIPT_PROG)
# -----------------------------------------------------------------------------
......
# Mini-driver for GHC
exec $GHCBIN $TOPDIROPT ${1+"$@"}
......@@ -11,22 +11,6 @@ INSTALLING=1
# -----------------------------------------------------------------------------
# ghci script
ifeq "$(INSTALLING)" "1"
ifeq "$(BIN_DIST)" "1"
GHCBIN=$$\"\"libexecdir/ghc-$(ProjectVersion)
GHCLIB=$$\"\"libdir
else
GHCBIN=$(libexecdir)/ghc-$(ProjectVersion)
GHCLIB=$(libdir)
endif # BIN_DIST
else
GHCBIN=$(FPTOOLS_TOP_ABS)/$(GHC_COMPILER_DIR_REL)/ghc-$(ProjectVersion)
GHCLIB=$(FPTOOLS_TOP_ABS)
endif
INSTALLED_SCRIPT_PROG = ghci-$(ProjectVersion)
INPLACE_SCRIPT_PROG = ghci-inplace
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
C_PROG = ghci
C_OBJS += ghci.res
......@@ -34,31 +18,42 @@ else
C_SRCS=
endif
SCRIPT_OBJS = ghci.sh
INTERP = $(SHELL)
SCRIPT_SUBST_VARS = GHCBIN TOPDIROPT
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
INSTALL_SCRIPTS += $(SCRIPT_PROG)
else
INSTALL_SCRIPTS += ghcii.sh
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
INSTALL_PROGS += $(C_PROG)
GHCII_SCRIPT=$(bindir)/ghcii.sh
install::
$(RM) -f $(GHCII_SCRIPT)
echo "#!$(SHELL)" >> $(GHCII_SCRIPT)
echo 'exec "$0"/../ghc --interactive $${1+"$$@"}' >> $(GHCII_SCRIPT)
else
LINK = ghci
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
echo "GHCBIN=$(libexecdir)/ghc-$(ProjectVersion)" >> $(INSTALLED_SCRIPT)
echo "TOPDIROPT=-B$(libdir)" >> $(INSTALLED_SCRIPT)
echo 'exec $$GHCBIN $$TOPDIROPT --interactive $${1+"$$@"}' >> $(INSTALLED_SCRIPT)
$(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
endif
TOPDIROPT = -B$(GHCLIB)
ifeq "$(INSTALLING)" "1"
SCRIPT_PROG = $(INSTALLED_SCRIPT_PROG)
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
LINK = ghci
endif
else
SCRIPT_PROG = $(INPLACE_SCRIPT_PROG)
INPLACE_SCRIPT=ghc-pkg-inplace
all::
$(RM) -f $(INPLACE_SCRIPT)
echo "#!$(SHELL)" >> $(INPLACE_SCRIPT)
echo "GHCBIN=$(FPTOOLS_TOP_ABS)/$(GHC_COMPILER_DIR_REL)/ghc-$(ProjectVersion)" >> $(INPLACE_SCRIPT)
echo "TOPDIROPT=$(FPTOOLS_TOP_ABS)" >> $(INPLACE_SCRIPT)
echo 'exec $$GHCPKGBIN --global-conf $$PKGCONF $${1+"$$@"}' >> $(INPLACE_SCRIPT)
$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
endif
# don't recurse on 'make install'
#
ifeq "$(INSTALLING)" "1"
all clean distclean maintainer-clean ::
$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
$(MAKE) INSTALLING=0 $(MFLAGS) $@
endif
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
......
......@@ -4,15 +4,16 @@
TOP=../..
include $(TOP)/mk/boilerplate.mk
SCRIPT_PROG = ghc-asm
INTERP=perl
SCRIPT_SUBST_VARS := TARGETPLATFORM
INSTALL_LIBEXEC_SCRIPTS += $(SCRIPT_PROG)
CLEAN_FILES += $(SCRIPT_OBJS)
PROG = ghc-asm
all:: $(PROG).prl
$(RM) -f $(PROG)
echo '#!$(PERL)' >> $(PROG)
echo '$$TARGETPLATFORM = "$(TARGETPLATFORM)";' >> $(PROG)
cat $< >> $(PROG)
$(EXECUTABLE_FILE) $(PROG)
INSTALL_LIBEXEC_SCRIPTS += $(PROG)
CLEAN_FILES += $(PROG) $(PROG).prl
# needed for bootstrapping with HC files
ifeq "$(BootingFromHc)" "YES"
......
......@@ -4,14 +4,15 @@
TOP=../..
include $(TOP)/mk/boilerplate.mk
SCRIPT_PROG = ghc-split
PROG = ghc-split
all:: $(PROG).prl
$(RM) -f $(PROG)
echo '#!$(PERL)' >> $(PROG)
echo '$$TARGETPLATFORM = "$(TARGETPLATFORM)";' >> $(PROG)
cat $< >> $(PROG)
$(EXECUTABLE_FILE) $(PROG)
INTERP=perl
SCRIPT_SUBST_VARS := TARGETPLATFORM
INSTALL_LIBEXEC_SCRIPTS += $(SCRIPT_PROG)
CLEAN_FILES += $(SCRIPT_OBJS)
INSTALL_LIBEXEC_SCRIPTS += $(PROG)
CLEAN_FILES += $(PROG) $(PROG).prl
include $(TOP)/mk/target.mk
......@@ -183,7 +183,8 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
-$(RM) -f stamp/configure.library.*.$* $*/unbuildable
( cd $* && setup/Setup configure \
$(CONFIGURE_OPTS) \
--prefix=$(prefix) \
--prefix='$$topdir' \
--libsubdir='$$compiler/lib/$$pkgid' \
--with-compiler=../../compiler/ghc-inplace$(dot_bat) \
--with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
--with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
......@@ -227,16 +228,17 @@ doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
.PHONY: install install-docs install.library.%
INSTALL_DIR=$(prefix)/share/ghc/doc/html/
ROOT=$(prefix)/share/ghc/doc/html/
install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
ifneq "$(NO_HADDOCK_DOCS)" "YES"
$(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
$(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
$(INSTALL_DIR) $(ROOT)
$(INSTALL_DATA) index.html doc-index.html $(ROOT)
$(INSTALL_SCRIPT) gen_contents_index $(ROOT)
# Hacks:
$(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
$(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
$(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
$(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(ROOT)
$(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(ROOT)
$(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(ROOT)
endif
# Cabal doesn't let us ask to install docs only, so do nothing here
......@@ -248,7 +250,7 @@ install-docs:
# Thus if you install without building then it will just break.
$(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
install.library.%: installPackage/installPackage ifBuildable/ifBuildable
ifBuildable/ifBuildable $* ../installPackage/installPackage
ifBuildable/ifBuildable $* ../installPackage/installPackage $(prefix) $(bindir)/ghc-pkg
.PHONY: binary-dist binary-dist.library.%
......
......@@ -6,11 +6,14 @@ import Distribution.Simple.Configure
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Utils
import Distribution.Verbosity
import System.Cmd
import System.Environment
main :: IO ()
main = do args <- getArgs
let verbosity = case args of
case args of
pref : ghcpkg : args' ->
let verbosity = case args' of
[] -> normal
['-':'v':v] ->
let m = case v of
......@@ -18,11 +21,24 @@ main = do args <- getArgs
_ -> Just v
in flagToVerbosity m
_ -> error ("Bad arguments: " ++ show args)
userHooks = simpleUserHooks
installFlags = InstallFlags {
installUserFlags = MaybeUserGlobal,
installVerbose = verbosity
}
in doit pref ghcpkg verbosity
_ ->
error "Missing arguments"
doit :: FilePath -> FilePath -> Verbosity -> IO ()
doit pref ghcpkg verbosity =
do let userHooks = simpleUserHooks
copyFlags = CopyFlags {
copyDest = NoCopyDest,
copyVerbose = verbosity
}
registerFlags = RegisterFlags {
regUser = MaybeUserGlobal,
regGenScript = False,
regInPlace = False,
regWithHcPkg = Just ghcpkg,
regVerbose = verbosity
}
pdFile <- defaultPackageDesc verbosity
pd <- readPackageDescription verbosity pdFile
lbi <- getPersistBuildConfig
......@@ -36,25 +52,15 @@ main = do args <- getArgs
Nothing ->
error "Expected a library, but none found"
pd' = pd { library = Just lib' }
-- When installing we need to use the non-inplace ghc-pkg.
-- We also set the compiler to be non-inplace, but that
-- probably doesn't matter.
c = compiler lbi
c' = c { compilerPath = dropInPlace (compilerPath c),
compilerPkgTool = dropInPlace (compilerPkgTool c)
}
lbi' = lbi { compiler = c' }
(instHook simpleUserHooks) pd' lbi' userHooks installFlags
dropInPlace :: FilePath -> FilePath
dropInPlace "" = ""
dropInPlace xs@(x:xs') = case dropPrefix "-inplace" xs of
Nothing -> x : dropInPlace xs'
Just xs'' -> dropInPlace xs''
dropPrefix :: Eq a => [a] -> [a] -> Maybe [a]
dropPrefix [] ys = Just ys
dropPrefix (x:xs) (y:ys)
| x == y = dropPrefix xs ys
dropPrefix _ _ = Nothing
-- When coying, we need to actually give a concrete
-- directory to copy to rather than "$topdir"
lbi_copy = lbi { prefix = pref }
-- When we run GHC we give it a $topdir that includes the
-- $compiler/lib/ part of libsubdir, so we only want the
-- $pkgid part in the package.conf file. This is a bit of
-- a hack, really.
lbi_register = lbi { libsubdir = "$pkgid" }
(copyHook simpleUserHooks) pd' lbi_copy userHooks copyFlags
(regHook simpleUserHooks) pd' lbi_register userHooks registerFlags
return ()
......@@ -786,6 +786,7 @@ LNDIR = $(GHC_LNDIR_DIR)/$(GHC_LNDIR_PGM)
RUNTEST = $(GHC_RUNTEST_DIR)/$(GHC_RUNTEST_PGM)
GENERATED_FILE = chmod a-w
EXECUTABLE_FILE = chmod +x
#-----------------------------------------------------------------------------
# Haskell compilers and mkdependHS
......
......@@ -22,13 +22,8 @@ PKG_DATADIR = $$topdir
else
ifeq "$(BIN_DIST)" ""
PKG_LIBDIR = $(libdir)
PKG_DATADIR = $(datadir)
else
PKG_LIBDIR = $$libdir
PKG_DATADIR = $$datadir
endif
endif # Unix
......@@ -373,7 +368,6 @@ CLEAN_FILES += $(PACKAGE).haddock
$(HC) $(HC_OPTS) -D__HADDOCK__ -E $< -o $@
HTML_INSTALL_DIR = $(datadir)/html/libraries/$(PACKAGE)
# NOT the same as HTML_DIR_INSTALLED when BIN_DIST is on
install-docs :: $(HTML_DOC)
@$(INSTALL_DIR) $(HTML_INSTALL_DIR)
......
......@@ -233,7 +233,7 @@ TAGS_C_SRCS=$(C_SRCS)
# Specifically glafp-utils/mkdependC/mkdependC.prl and others in driver/ and
# possibly others elsewhere in the tree. ToDo: fix this properly.
MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) $(HSC_C_OBJS) $(GC_C_OBJS)
CLEAN_FILES += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \
CLEAN_FILES += $(HS_PROG) $(C_PROG) $(SCRIPT_LINK) \
$(PROG) $(LIBRARY) a.out \
$(DERIVED_HSC_SRCS) \
$(DERIVED_GC_SRCS) \
......
......@@ -215,7 +215,6 @@ endif
# HS_PROG Haskell program
# C_PROG C program
# LIBRARY Library
# SCRIPT_PROG Script (e.g. Perl script)
#
# For details of exactly what rule is generated, see the
# relevant section below
......@@ -483,77 +482,6 @@ DllVersionInfo.$(way_)rc ExeVersionInfo.$(way_)rc:
echo " END" >> $@
echo "END" >> $@
#----------------------------------------
# Script programs
ifneq "$(SCRIPT_PROG)" ""
# To produce a fully functional script, you may
# have to add some configuration variables at the top of
# the script, i.e., the compiler driver needs to know
# the path to various utils in the build tree for instance.
#
# To have the build rule for the script automatically do this
# for you, set the variable SCRIPT_SUBST_VARS to the list of
# variables you need to put in.
#
# SCRIPT_SUBST creates a string of echo commands that
# will when evaluated append the (perl)variable name and its value
# to the target it is used for, i.e.,
#
# A=foo
# B=bar
# SCRIPT_SUBST_VARS = A B
# SCRIPT_SUBST=echo "$""A=\"foo\";" >> $@; echo "$""B=\"bar\";" >> $@
#
# so if you have a rule like the following
#
# foo:
# @(RM) $@
# @(TOUCH) $@
# @eval $(SCRIPT_SUBST)
#
# `make foo' would create a file `foo' containing the following
#
# % cat foo
# $A=foo;
# $B=bar;
# %
#
# ToDo: make this work for shell scripts (drop the initial $).
#
ifeq "$(INTERP)" "$(SHELL)"
SCRIPT_SUBST=$(foreach val,$(SCRIPT_SUBST_VARS),"echo \"$(val)=\\\"$($(val))\\\";\" >> $@;")
else
SCRIPT_SUBST=$(foreach val,$(SCRIPT_SUBST_VARS),"echo \"$$\"\"$(val)=\\\"$($(val))\\\";\" >> $@;")
endif
all :: $(SCRIPT_PROG)
$(SCRIPT_PROG) : $(SCRIPT_OBJS)
$(RM) $@
@echo Creating $@...
ifeq "$(INTERP)" "perl"
echo "#! "$(PERL) > $@
else
ifneq "$(INTERP)" ""
@echo "#!"$(INTERP) > $@
else
@touch $@
endif
endif
ifneq "$(SCRIPT_PREFIX_FILES)" ""
@cat $(SCRIPT_PREFIX_FILES) >> $@
endif
ifneq "$(SCRIPT_SUBST)" ""
@eval $(SCRIPT_SUBST)
endif
@cat $(SCRIPT_OBJS) >> $@
@chmod a+x $@
@echo Done.
endif
# ---------------------------------------------------------------------------
# Symbolic links
......@@ -562,43 +490,17 @@ endif
ifneq "$(LINK)" ""
all :: $(LINK)
CLEAN_FILES += $(LINK)
ifeq "$(LINK_TARGET)" ""
ifneq "$(SCRIPT_PROG)" ""
LINK_TARGET = $(SCRIPT_PROG)
else
ifneq "$(HS_PROG)" ""
LINK_TARGET = $(HS_PROG)
else
ifneq "$(C_PROG)" ""
LINK_TARGET = $(C_PROG)
else
LINK_TARGET = dunno
$(error Cannot deduce LINK_TARGET)
endif
endif
endif
endif
#
# Don't want to overwrite $(LINK)s that aren't symbolic
# links. Testing for symbolic links is problematic to do in
# a portable fashion using a /bin/sh test, so we simply rely
# on perl.
#
$(LINK) : $(LINK_TARGET)
@if ( $(PERL) -e '$$fn="$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK)"; \
$(RM) $(LINK); \
$(LN_S) $(LINK_TARGET) $(LINK); \
else \
echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) failed: \`$(LINK)' already exists"; \
echo "Perhaps remove \`$(LINK)' manually?"; \
exit 1; \
fi;
#
# install links to script drivers.
......
TOP=../..
include $(TOP)/mk/boilerplate.mk
# hack for ghci-inplace script, see below
INSTALLING=1
# -----------------------------------------------------------------------------
# ghc-pkg.bin
......@@ -53,60 +50,36 @@ DIST_CLEAN_FILES += $(VERSION_HS)
# -----------------------------------------------------------------------------
# ghc-pkg script
ifeq "$(INSTALLING)" "1"
ifeq "$(BIN_DIST)" "1"
GHCPKGBIN=$$\"\"libexecdir/$(HS_PROG)
PKGCONF=$$\"\"libdir/package.conf
else
GHCPKGBIN=$(libexecdir)/$(HS_PROG)
PKGCONF=$(libdir)/package.conf
endif # BIN_DIST
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
# See "MSys Note 3" in compiler/Makefile
INPLACE_SCRIPT=ghc-pkg-inplace.bat
all::
$(RM) -f $(INPLACE_SCRIPT)
echo '@call $(subst /,\,$(FPTOOLS_TOP_ABS_PLATFORM)/utils/ghc-pkg/$(HS_PROG)) --global-conf $(FPTOOLS_TOP_ABS_PLATFORM)/driver/package.conf.inplace %*' >> $(INPLACE_SCRIPT)
$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
else
GHCPKGBIN=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/$(HS_PROG)
PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/driver/package.conf.inplace
endif
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
INSTALLED_SCRIPT_PROG = ghc-pkg-$(ProjectVersion)
endif
INPLACE_SCRIPT_PROG = ghc-pkg-inplace
SCRIPT_OBJS = ghc-pkg.sh
INTERP = $(SHELL)
SCRIPT_SUBST_VARS = GHCPKGBIN PKGCONFOPT
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
INSTALL_SCRIPTS += $(SCRIPT_PROG)
INPLACE_SCRIPT=ghc-pkg-inplace
all::
$(RM) -f $(INPLACE_SCRIPT)
echo "#!$(SHELL)" >> $(INPLACE_SCRIPT)
echo "GHCPKGBIN=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/$(HS_PROG)" >> $(INPLACE_SCRIPT)
echo "PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/driver/package.conf.inplace" >> $(INPLACE_SCRIPT)
echo 'exec $$GHCPKGBIN --global-conf $$PKGCONF $${1+"$$@"}' >> $(INPLACE_SCRIPT)
$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
endif
PKGCONFOPT = --global-conf $(PKGCONF)
CLEAN_FILES += $(INPLACE_SCRIPT)
ifeq "$(INSTALLING)" "1"
SCRIPT_PROG = $(INSTALLED_SCRIPT_PROG)
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
LINK = ghc-pkg
endif
else
SCRIPT_PROG = $(INPLACE_SCRIPT_PROG)
endif
# -----------------------------------------------------------------------------
# don't recurse on 'make install'
#
ifeq "$(INSTALLING)" "1"
all :: $(HS_PROG)
$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
clean distclean maintainer-clean ::
$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
endif
ifeq "$(INSTALLING)$(HOSTPLATFORM)" "0i386-unknown-mingw32"
all :: $(INPLACE_SCRIPT_PROG).bat
# See "MSys Note 3" in compiler/Makefile
$(INPLACE_SCRIPT_PROG).bat :
echo '@call $(subst /,\,$(FPTOOLS_TOP_ABS_PLATFORM)/utils/ghc-pkg/$(HS_PROG)) --global-conf $(PKGCONF) %*' >> $@
chmod 755 $@
CLEAN_FILES += $(INPLACE_SCRIPT_PROG).bat
LINK = ghc-pkg
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
echo "GHCPKGBIN=$(libexecdir)/$(HS_PROG)" >> $(INSTALLED_SCRIPT)
echo "PKGCONF=$(libdir)/package.conf" >> $(INSTALLED_SCRIPT)
echo 'exec $$GHCPKGBIN --global-conf $$PKGCONF $${1+"$$@"}' >> $(INSTALLED_SCRIPT)
$(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
endif
# ghc-pkg is needed to boot in rts/ and library dirs
......
# Mini-driver for ghc-pkg
exec $GHCPKGBIN $PKGCONFOPT ${1+"$@"}
......@@ -5,8 +5,6 @@
TOP=../..
include $(TOP)/mk/boilerplate.mk
INSTALLING=1
# This causes libghccompat.a to be used:
include $(GHC_COMPAT_DIR)/compat.mk
......@@ -28,77 +26,57 @@ endif
# clean solution impossible. So we revert to a hack in Main.hs...
SRC_HC_OPTS += -Wall
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
INSTALLED_SCRIPT_PROG = hsc2hs-ghc
endif
INPLACE_SCRIPT_PROG = hsc2hs-inplace
ifeq "$(INSTALLING)" "1"
TOP_PWD := $(prefix)
SCRIPT_PROG = $(INSTALLED_SCRIPT_PROG)
else
TOP_PWD := $(FPTOOLS_TOP_ABS)
SCRIPT_PROG = $(INPLACE_SCRIPT_PROG)
endif
ifeq "$(INSTALLING)" "1"
ifeq "$(BIN_DIST)" "1"
HSC2HS_BINDIR=$$\"\"libexecdir
HSC2HS_DIR=$$\"\"libdir
HSC2HS_EXTRA=
else
HSC2HS_BINDIR=$(libexecdir)
HSC2HS_DIR=$(libdir)
HSC2HS_EXTRA=--cc=$(bindir)/ghc-$(ProjectVersion)
endif # BIN_DIST
else
HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)
HSC2HS_DIR=$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_HSC2HS_DIR_REL)
# -----------------------------------------------------------------------------
# hsc2hs script
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
endif
HSC2HS_INPLACE_EXTRA=--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_INCLUDE_DIR_REL)
HSC2HS_EXTRA=--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_INCLUDE_DIR_REL)
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
# See "MSys Note 3" in compiler/Makefile
INPLACE_SCRIPT=hsc2hs-inplace.bat
FULL_INPLACE_PATH=$(subst /,\,$(FPTOOLS_TOP_ABS_PLATFORM)/utils/hsc2hs/)
all::
$(RM) -f $(INPLACE_SCRIPT)
echo '@call $(FULL_INPLACE_PATH)$(HS_PROG)) ----template=$(FULL_INPLACE_PATH)template-hsc.h $(HSC2HS_EXTRA) %*' >> $(INPLACE_SCRIPT)
$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
else
INPLACE_SCRIPT=hsc2hs-inplace
all::
$(RM) -f $(INPLACE_SCRIPT)
echo "#!$(SHELL)" >> $(INPLACE_SCRIPT)
echo "HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)" >> $(INPLACE_SCRIPT)
echo "HSC2HS_DIR=$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_HSC2HS_DIR_REL)" >> $(INPLACE_SCRIPT)
echo "HS_PROG=$(HS_PROG)" >> $(INPLACE_SCRIPT)
echo "HSC2HS_EXTRA=$(HSC2HS_INPLACE_EXTRA)" >> $(INPLACE_SCRIPT)
cat hsc2hs.sh >> $(INPLACE_SCRIPT)
$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
endif
CLEAN_FILES += $(INPLACE_SCRIPT)
$(SCRIPT_PROG) : Makefile
$(INSTALLED_SCRIPT_PROG) : $(TOP)/mk/config.mk
SCRIPT_SUBST_VARS = HSC2HS_BINDIR HSC2HS_DIR HS_PROG HSC2HS_EXTRA
SCRIPT_OBJS=hsc2hs.sh
INTERP=$(SHELL)
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
INSTALL_SCRIPTS += $(SCRIPT_PROG)
INSTALL_LIBEXECS += $(HS_PROG)
else
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
INSTALL_PROGS += $(HS_PROG)
else
INSTALL_LIBEXECS += $(HS_PROG)
LINK = hsc2hs
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
echo "HSC2HS_BINDIR=$(libexecdir)" >> $(INSTALLED_SCRIPT)
echo "HSC2HS_DIR=$(libdir)" >> $(INSTALLED_SCRIPT)
echo "HS_PROG=$(HS_PROG)" >> $(INSTALLED_SCRIPT)
echo "HSC2HS_EXTRA=" >> $(INSTALLED_SCRIPT)
cat hsc2hs.sh >> $(INSTALLED_SCRIPT)
$(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
endif
override datadir=$(libdir)
INSTALL_DATAS += template-hsc.h
# -----------------------------------------------------------------------------
# don't recurse on 'make install'
#
ifeq "$(INSTALLING)" "1"
all :: $(HS_PROG)
$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
clean distclean maintainer-clean ::
$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
endif
ifeq "$(INSTALLING)$(HOSTPLATFORM)" "0i386-unknown-mingw32"
all :: $(INPLACE_SCRIPT_PROG).bat
# See "MSys Note 3" in compiler/Makefile
FULL_INPLACE_PATH=$(subst /,\,$(FPTOOLS_TOP_ABS_PLATFORM)/utils/hsc2hs/)
$(INPLACE_SCRIPT_PROG).bat :
echo '@call $(FULL_INPLACE_PATH)$(HS_PROG) --template=$(FULL_INPLACE_PATH)template-hsc.h $(HSC2HS_EXTRA) %*' >> $@
chmod 755 $@
endif
override datadir=$(libdir)
INSTALL_DATAS += template-hsc.h
include $(TOP)/mk/target.mk
......@@ -16,10 +16,6 @@ SCRIPT_SUBST_VARS=\
TOP_PWD \
ProjectVersionInt
ifneq "$(BIN_DIST)" "1"
SCRIPT_SUBST_VARS += libdir libexecdir DEFAULT_TMPDIR
endif
#
# The hstags script is configured with different
# set of config variables, depending on whether it
......@@ -27,9 +23,7 @@ endif
#
ifeq "$(INSTALLING)" "1"
TOP_PWD := $(prefix)
ifeq "$(BIN_DIST)" "1"
SCRIPT_PREFIX_FILES += prefix.txt
endif
else
TOP_PWD := $(FPTOOLS_TOP_ABS)
HSP_IMPORTS:="$(TOP_PWD)/ghc/lib/ghc":"$(TOP_PWD)/ghc/lib/required":"$(TOP_PWD)/ghc/lib/glaExts":"$(TOP_PWD)/ghc/lib/concurrent"
......@@ -66,5 +60,5 @@ include $(TOP)/mk/target.mk
#
install ::
@$(RM) $(SCRIPT_PROG)
@$(MAKE) $(MFLAGS) BIN_DIST=0 $(SCRIPT_PROG)
@$(MAKE) $(MFLAGS) $(SCRIPT_PROG)
......@@ -7,15 +7,15 @@ include $(TOP)/mk/boilerplate.mk
boot :: all
SCRIPT_PROG=mkdependC
SCRIPT_OBJS=mkdependC.prl
#