Commit ed5ebee4 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Merge branch 'master' of darcs.haskell.org:/home/darcs/ghc

parents b9fccbc8 911bc5ce
......@@ -1185,13 +1185,6 @@ searchForLibUsingGcc dflags so dirs = do
-- ----------------------------------------------------------------------------
-- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
mkSOName :: Platform -> FilePath -> FilePath
mkSOName platform root
= case platformOS platform of
OSDarwin -> ("lib" ++ root) <.> "dylib"
OSMinGW32 -> root <.> "dll"
_ -> ("lib" ++ root) <.> "so"
-- Darwin / MacOS X only: load a framework
-- a framework is a dynamic library packaged inside a directory of the same
-- name. They are searched for in different paths than normal libraries.
......
......@@ -371,7 +371,7 @@ linkingNeeded dflags linkables pkg_deps = do
| Just c <- map (lookupPackage pkg_map) pkg_deps,
lib <- packageHsLibs dflags c ]
pkg_libfiles <- mapM (uncurry findHSLib) pkg_hslibs
pkg_libfiles <- mapM (uncurry (findHSLib dflags)) pkg_hslibs
if any isNothing pkg_libfiles then return True else do
e_lib_times <- mapM (tryIO . getModificationUTCTime)
(catMaybes pkg_libfiles)
......@@ -408,9 +408,11 @@ ghcLinkInfoSectionName :: String
ghcLinkInfoSectionName = ".debug-ghc-link-info"
-- if we use the ".debug" prefix, then strip will strip it by default
findHSLib :: [String] -> String -> IO (Maybe FilePath)
findHSLib dirs lib = do
let batch_lib_file = "lib" ++ lib <.> "a"
findHSLib :: DynFlags -> [String] -> String -> IO (Maybe FilePath)
findHSLib dflags dirs lib = do
let batch_lib_file = if dopt Opt_Static dflags
then "lib" ++ lib <.> "a"
else mkSOName (targetPlatform dflags) lib
found <- filterM doesFileExist (map (</> batch_lib_file) dirs)
case found of
[] -> return Nothing
......@@ -1662,13 +1664,24 @@ linkBinary dflags o_files dep_packages = do
-- explicit packages with the auto packages and all of their
-- dependencies, and eliminating duplicates.
full_output_fn <- if isAbsolute output_fn
then return output_fn
else do d <- getCurrentDirectory
return $ normalise (d </> output_fn)
pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
let pkg_lib_path_opts = concat (map get_pkg_lib_path_opts pkg_lib_paths)
let pkg_lib_path_opts = concatMap get_pkg_lib_path_opts pkg_lib_paths
get_pkg_lib_path_opts l
| osElfTarget (platformOS platform) &&
dynLibLoader dflags == SystemDependent &&
not (dopt Opt_Static dflags)
= ["-L" ++ l, "-Wl,-rpath", "-Wl," ++ l]
= let libpath = if dopt Opt_RelativeDynlibPaths dflags
then "$ORIGIN" </>
(l `makeRelativeTo` full_output_fn)
else l
rpath = if dopt Opt_RPath dflags
then ["-Wl,-rpath", "-Wl," ++ libpath]
else []
in ["-L" ++ l, "-Wl,-rpath-link", "-Wl," ++ l] ++ rpath
| otherwise = ["-L" ++ l]
let lib_paths = libraryPaths dflags
......
This diff is collapsed.
......@@ -37,6 +37,8 @@ module HscTypes (
PackageInstEnv, PackageRuleBase,
mkSOName,
-- * Annotations
prepareAnnotations,
......@@ -157,6 +159,7 @@ import Fingerprint
import MonadUtils
import Bag
import ErrUtils
import Platform
import Util
import Control.Monad ( mplus, guard, liftM, when )
......@@ -1778,6 +1781,15 @@ type OrigNameCache = ModuleEnv (OccEnv Name)
\end{code}
\begin{code}
mkSOName :: Platform -> FilePath -> FilePath
mkSOName platform root
= case platformOS platform of
OSDarwin -> ("lib" ++ root) <.> "dylib"
OSMinGW32 -> root <.> "dll"
_ -> ("lib" ++ root) <.> "so"
\end{code}
%************************************************************************
%* *
......
......@@ -87,6 +87,7 @@ module Util (
escapeSpaces,
parseSearchPath,
Direction(..), reslash,
makeRelativeTo,
-- * Utils for defining Data instances
abstractConstr, abstractDataType, mkNoRepType,
......@@ -1006,6 +1007,17 @@ reslash d = f
slash = case d of
Forwards -> '/'
Backwards -> '\\'
makeRelativeTo :: FilePath -> FilePath -> FilePath
this `makeRelativeTo` that = directory </> thisFilename
where (thisDirectory, thisFilename) = splitFileName this
thatDirectory = dropFileName that
directory = joinPath $ f (splitPath thisDirectory)
(splitPath thatDirectory)
f (x : xs) (y : ys)
| x == y = f xs ys
f xs ys = replicate (length ys) ".." ++ xs
\end{code}
%************************************************************************
......
......@@ -18,7 +18,7 @@ dnl--------------------------------------------------------------------
FP_GMP
bootstrap_target=`ghc/stage2/build/tmp/ghc-stage2 +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
bootstrap_target=@TargetPlatform@
FPTOOLS_SET_PLATFORM_VARS
BuildingCrossCompiler=NO
......
......@@ -32,6 +32,7 @@ driver/ghci_dist_C_SRCS = ghci.c ../utils/cwrapper.c ../utils/getLocation.c
driver/ghci_dist_CC_OPTS += -I driver/utils
driver/ghci_dist_PROG = ghci$(exeext)
driver/ghci_dist_INSTALL = YES
driver/ghci_dist_INSTALL_INPLACE = YES
driver/ghci_dist_OTHER_OBJS = driver/ghci/ghci.res
$(eval $(call build-prog,driver/ghci,dist,1))
......
......@@ -796,57 +796,53 @@ TAGS: TAGS_compiler
# Installation
install: install_libs install_packages install_libexecs \
install_libexec_scripts install_bins install_topdirs
install_bins install_topdirs
ifeq "$(HADDOCK_DOCS)" "YES"
install: install_docs
endif
install_bins: $(INSTALL_BINS)
$(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
for i in $(INSTALL_BINS); do \
$(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(bindir)") ; \
done
install_libs: $(INSTALL_LIBS)
$(call INSTALL_DIR,"$(DESTDIR)$(ghclibdir)")
for i in $(INSTALL_LIBS); do \
define installLibsTo
# $1 = libraries to install
# $2 = directory to install to
$(call INSTALL_DIR,$2)
for i in $1; do \
case $$i in \
*.a) \
$(call INSTALL_DATA,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)"); \
$(call INSTALL_DATA,$(INSTALL_OPTS),$$i,$2); \
$(RANLIB) $(DESTDIR)$(ghclibdir)/`basename $$i` ;; \
*.dll) \
$(call INSTALL_PROGRAM,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)") ; \
$(STRIP_CMD) "$(DESTDIR)$(ghclibdir)"/$$i ;; \
$(call INSTALL_PROGRAM,$(INSTALL_OPTS),$$i,$2) ; \
$(STRIP_CMD) $2/$$i ;; \
*.so) \
$(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)") ;; \
$(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,$2) ;; \
*.dylib) \
$(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)");; \
$(call INSTALL_SHLIB,$(INSTALL_OPTS),$$i,$2);; \
*) \
$(call INSTALL_DATA,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibdir)"); \
$(call INSTALL_DATA,$(INSTALL_OPTS),$$i,$2); \
esac; \
done
endef
install_libexec_scripts: $(INSTALL_LIBEXEC_SCRIPTS)
ifeq "$(INSTALL_LIBEXEC_SCRIPTS)" ""
@:
else
$(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)")
for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
$(call INSTALL_SCRIPT,$(INSTALL_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)"); \
install_bins: $(INSTALL_BINS)
$(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
for i in $(INSTALL_BINS); do \
$(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(bindir)") ; \
done
endif
install_libs: $(INSTALL_LIBS)
$(call installLibsTo, $(INSTALL_LIBS), "$(DESTDIR)$(ghclibdir)")
install_libexecs: $(INSTALL_LIBEXECS)
ifeq "$(INSTALL_LIBEXECS)" ""
@:
else
$(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)")
$(call INSTALL_DIR,"$(DESTDIR)$(ghclibexecdir)/bin")
for i in $(INSTALL_LIBEXECS); do \
$(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)"); \
$(call INSTALL_PROGRAM,$(INSTALL_BIN_OPTS),$$i,"$(DESTDIR)$(ghclibexecdir)/bin"); \
done
# We rename ghc-stage2, so that the right program name is used in error
# messages etc.
"$(MV)" "$(DESTDIR)$(ghclibexecdir)/ghc-stage$(INSTALL_GHC_STAGE)" "$(DESTDIR)$(ghclibexecdir)/ghc"
"$(MV)" "$(DESTDIR)$(ghclibexecdir)/bin/ghc-stage$(INSTALL_GHC_STAGE)" "$(DESTDIR)$(ghclibexecdir)/bin/ghc"
endif
install_topdirs: $(INSTALL_TOPDIRS)
......@@ -884,8 +880,8 @@ INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
# Install packages in the right order, so that ghc-pkg doesn't complain.
# Also, install ghc-pkg first.
ifeq "$(Windows)" "NO"
INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/ghc
INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/ghc-pkg
INSTALLED_GHC_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc
INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(ghclibexecdir)/bin/ghc-pkg
else
INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
......@@ -914,14 +910,29 @@ install_packages: rts/package.conf.install
$(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
$(call removeTrees,"$(INSTALLED_PACKAGE_CONF)")
$(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF)")
$(call INSTALL_DIR,"$(DESTDIR)$(topdir)/rts-1.0")
$(call installLibsTo, $(RTS_INSTALL_LIBS), "$(DESTDIR)$(topdir)/rts-1.0")
ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
$(foreach p, $(PKGS_THAT_ARE_INTREE_ONLY), \
$(call installLibsTo, $(wildcard libraries/$p/dist-install/build/*.so libraries/$p/dist-install/build/*.dll libraries/$p/dist-install/build/*.dylib), "$(DESTDIR)$(topdir)/$p-$(libraries/$p_dist-install_VERSION)"))
endif
$(foreach p, $(INSTALLED_PKG_DIRS), \
$(call make-command, \
CROSS_COMPILE="$(CrossCompilePrefix)" \
"$(GHC_CABAL_INPLACE)" copy \
"$(STRIP_CMD)" \
$p $(INSTALL_DISTDIR_$p) \
'$(DESTDIR)' \
'$(prefix)' \
'$(ghclibdir)' \
'$(docdir)/html/libraries'))
"$(INSTALLED_GHC_PKG_REAL)" --force --global-package-db "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
$(foreach p, $(INSTALLED_PKG_DIRS), \
$(call make-command, \
CROSS_COMPILE="$(CrossCompilePrefix)" \
"$(GHC_CABAL_INPLACE)" install \
CROSS_COMPILE="$(CrossCompilePrefix)" \
"$(GHC_CABAL_INPLACE)" register \
"$(INSTALLED_GHC_REAL)" \
"$(INSTALLED_GHC_PKG_REAL)" \
"$(STRIP_CMD)" \
"$(DESTDIR)$(topdir)" \
$p $(INSTALL_DISTDIR_$p) \
'$(DESTDIR)' \
......@@ -977,6 +988,7 @@ $(eval $(call bindist,.,\
$(wildcard libraries/*/dist-install/doc/) \
$(wildcard libraries/*/*/dist-install/doc/) \
$(filter-out settings,$(INSTALL_LIBS)) \
$(RTS_INSTALL_LIBS) \
$(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
mk/project.mk \
mk/install.mk.in \
......
......@@ -77,6 +77,9 @@ ghc_stage3_SHELL_WRAPPER = YES
ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
ghc_stage1_INSTALL_INPLACE = YES
ghc_stage2_INSTALL_INPLACE = YES
ghc_stage3_INSTALL_INPLACE = YES
ghc_stage$(INSTALL_GHC_STAGE)_INSTALL = YES
ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
......
......@@ -44,6 +44,10 @@ ifneq "$(GhcWithSMP)" "YES"
includes_CC_OPTS += -DNOSMP
endif
ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT
endif
ifneq "$(BINDIST)" "YES"
ifeq "$(PORTING_HOST)" "YES"
......@@ -148,6 +152,7 @@ else
includes_dist-derivedconstants_C_SRCS = mkDerivedConstants.c
includes_dist-derivedconstants_PROG = mkDerivedConstants$(exeext)
includes_dist-derivedconstants_INSTALL_INPLACE = YES
$(eval $(call build-prog,includes,dist-derivedconstants,0))
......
......@@ -776,6 +776,14 @@ main(int argc, char *argv[])
#endif
);
constantBool("dYNAMIC_BY_DEFAULT",
#ifdef DYNAMIC_BY_DEFAULT
1
#else
0
#endif
);
constantInt("lDV_SHIFT", LDV_SHIFT);
constantInteger("iLDV_CREATE_MASK", LDV_CREATE_MASK);
constantInteger("iLDV_STATE_CREATE", LDV_STATE_CREATE);
......
......@@ -129,6 +129,12 @@ endif
PlatformSupportsSharedLibs = $(if $(filter $(TARGETPLATFORM),\
$(SharedLibsPlatformList)),YES,NO)
SharedLibsByDefaultPlatformList = \
x86_64-unknown-linux
DYNAMIC_BY_DEFAULT = $(if $(filter $(TARGETPLATFORM),\
$(SharedLibsByDefaultPlatformList)),YES,NO)
# Build a compiler that will build *unregisterised* libraries and
# binaries by default. Unregisterised code is supposed to compile and
# run without any support for architecture-specific assembly mangling,
......@@ -261,7 +267,7 @@ endif
# (see GhcWithSMP).
GhcRTSWays += thr thr_debug thr_l
GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p,)
GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn,)
GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn,)
# We can only build GHCi threaded if we have a threaded RTS:
GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
......
......@@ -26,8 +26,13 @@ GhcStage2HcOpts += -O -fwarn-tabs -dcore-lint
# running of the tests, and faster building of the utils to be installed
GhcLibHcOpts += -O -dcore-lint
# We define DefaultFastGhcLibWays in this style so that the value is
# correct even if the user alters DYNAMIC_BY_DEFAULT
DefaultFastGhcLibWays = $(if $(filter $(DYNAMIC_BY_DEFAULT),YES),v dyn,v)
ifeq "$(ValidateSpeed)" "FAST"
GhcLibWays := v
GhcLibWays = $(DefaultFastGhcLibWays)
else
GhcLibWays := $(filter v dyn,$(GhcLibWays))
endif
......
......@@ -22,7 +22,7 @@
#
# The ways currently defined.
#
ALL_WAYS=v p t l s mp mg debug dyn thr thr_l debug_dyn thr_dyn thr_debug_dyn thr_p thr_debug debug_p thr_debug_p
ALL_WAYS=v p t l s mp mg debug dyn thr thr_l debug_dyn thr_dyn thr_debug_dyn thr_p thr_debug debug_p thr_debug_p l_dyn thr_l_dyn
#
# The following ways currently have treated specially, p t mg,
......@@ -34,23 +34,23 @@ ALL_WAYS=v p t l s mp mg debug dyn thr thr_l debug_dyn thr_dyn thr_debug_dyn thr
# Way 'v':
WAY_v_NAME=vanilla
WAY_v_HC_OPTS=
WAY_v_HC_OPTS= -static
# Way 'p':
WAY_p_NAME=profiling
WAY_p_HC_OPTS= -prof
WAY_p_HC_OPTS= -static -prof
# Way 'l':
WAY_l_NAME=event logging
WAY_l_HC_OPTS= -eventlog
WAY_l_HC_OPTS= -static -eventlog
# Way `mp':
WAY_mp_NAME=parallel
WAY_mp_HC_OPTS=-parallel
WAY_mp_HC_OPTS= -static -parallel
# Way `mg':
WAY_mg_NAME=GranSim
WAY_mg_HC_OPTS=-gransim
WAY_mg_HC_OPTS= -static -gransim
#
# These ways apply to the RTS only:
......@@ -58,31 +58,31 @@ WAY_mg_HC_OPTS=-gransim
# Way 'thr':
WAY_thr_NAME=threaded
WAY_thr_HC_OPTS=-optc-DTHREADED_RTS
WAY_thr_HC_OPTS= -static -optc-DTHREADED_RTS
# Way 'thr_p':
WAY_thr_p_NAME=threaded profiled
WAY_thr_p_HC_OPTS=-optc-DTHREADED_RTS -prof
WAY_thr_p_HC_OPTS= -static -optc-DTHREADED_RTS -prof
# Way 'thr_l':
WAY_thr_l_NAME=threaded event logging
WAY_thr_l_HC_OPTS=-optc-DTHREADED_RTS -eventlog
WAY_thr_l_HC_OPTS= -static -optc-DTHREADED_RTS -eventlog
# Way 'debug':
WAY_debug_NAME=debug
WAY_debug_HC_OPTS=-optc-DDEBUG
WAY_debug_HC_OPTS= -static -optc-DDEBUG
# Way 'debug_p':
WAY_debug_p_NAME=debug profiled
WAY_debug_p_HC_OPTS=-optc-DDEBUG -prof
WAY_debug_p_HC_OPTS= -static -optc-DDEBUG -prof
# Way 'thr_debug':
WAY_thr_debug_NAME=threaded
WAY_thr_debug_HC_OPTS=-optc-DTHREADED_RTS -optc-DDEBUG
WAY_thr_debug_HC_OPTS= -static -optc-DTHREADED_RTS -optc-DDEBUG
# Way 'thr_debug_p':
WAY_thr_debug_p_NAME=threaded debug profiling
WAY_thr_debug_p_HC_OPTS=-optc-DTHREADED_RTS -optc-DDEBUG -prof
WAY_thr_debug_p_HC_OPTS= -static -optc-DTHREADED_RTS -optc-DDEBUG -prof
# Way 'dyn': build dynamic shared libraries
WAY_dyn_NAME=dyn
......@@ -93,9 +93,18 @@ WAY_thr_dyn_NAME=thr_dyn
WAY_thr_dyn_HC_OPTS=-fPIC -dynamic -optc-DTHREADED_RTS
# Way 'thr_debug_dyn':
WAY_thr_debug_dyn_NAME=thr_dyn
WAY_thr_debug_dyn_NAME=thr_debug_dyn
WAY_thr_debug_dyn_HC_OPTS=-fPIC -dynamic -optc-DTHREADED_RTS -optc-DDEBUG
# Way 'debug_dyn':
WAY_debug_dyn_NAME=thr_dyn
WAY_debug_dyn_NAME=debug_dyn
WAY_debug_dyn_HC_OPTS=-fPIC -dynamic -optc-DDEBUG
# Way 'l_dyn':
WAY_l_dyn_NAME=event logging dynamic
WAY_l_dyn_HC_OPTS= -fPIC -dynamic -eventlog
# Way 'thr_l_dyn':
WAY_thr_l_dyn_NAME=threaded event logging dynamic
WAY_thr_l_dyn_HC_OPTS= -fPIC -dynamic -optc-DTHREADED_RTS -eventlog
......@@ -508,9 +508,9 @@ endif
# -----------------------------------------------------------------------------
# installing
INSTALL_LIBS += $(ALL_RTS_LIBS)
INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL))
RTS_INSTALL_LIBS += $(ALL_RTS_LIBS)
RTS_INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
RTS_INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL))
install: install_libffi_headers
......
......@@ -16,7 +16,7 @@ hidden-modules:
import-dirs:
#ifdef INSTALLING
library-dirs: LIB_DIR PAPI_LIB_DIR
library-dirs: LIB_DIR"/rts-1.0" PAPI_LIB_DIR
#else /* !INSTALLING */
library-dirs: TOP"/rts/dist/build" PAPI_LIB_DIR
#endif
......
......@@ -115,6 +115,13 @@ $$(foreach way,$$($1_$2_WAYS),$$(eval \
$$(call build-package-way,$1,$2,$$(way),$3) \
))
# Programs will need to depend on either the vanilla lib (if -static
# is the default) or the dyn lib (if -dynamic is the default). We
# conservatively make them depend on both, to keep things simple.
# If dyn libs are not being built then $$($1_$2_dyn_LIB) will just
# expand to the empty string, and be ignored.
$1_$2_PROGRAM_DEP_LIB = $$($1_$2_v_LIB) $$($1_$2_dyn_LIB)
# C and S files are possibly built the "dyn" way.
ifeq "$$(BuildSharedLibs)" "YES"
$(call c-objs,$1,$2,dyn)
......
......@@ -54,6 +54,26 @@ ifeq "$$($1_USES_CABAL)" "YES"
$1_$2_USES_CABAL = YES
endif
ifeq "$$(Windows)" "YES"
$1_$2_WANT_INPLACE_WRAPPER = NO
else ifneq "$$($1_$2_INSTALL_INPLACE)" "YES"
$1_$2_WANT_INPLACE_WRAPPER = NO
else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
$1_$2_WANT_INPLACE_WRAPPER = YES
else
$1_$2_WANT_INPLACE_WRAPPER = NO
endif
ifeq "$$(Windows)" "YES"
$1_$2_WANT_INSTALLED_WRAPPER = NO
else ifneq "$$($1_$2_INSTALL)" "YES"
$1_$2_WANT_INSTALLED_WRAPPER = NO
else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
$1_$2_WANT_INSTALLED_WRAPPER = YES
else
$1_$2_WANT_INSTALLED_WRAPPER = NO
endif
$(call package-config,$1,$2,$3)
$1_$2_depfile_base = $1/$2/build/.depend
......@@ -66,8 +86,8 @@ $1_$2_INPLACE =
endif
else
# Where do we install the inplace version?
ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO"
$1_$2_INPLACE = $$(INPLACE_LIB)/$$($1_$2_PROG)
ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES"
$1_$2_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG)
else
ifeq "$$($1_$2_TOPDIR)" "YES"
$1_$2_INPLACE = $$(INPLACE_TOPDIR)/$$($1_$2_PROG)
......@@ -93,7 +113,7 @@ $(call all-target,$1_$2,$1/$2/build/tmp/$$($1_$2_PROG))
# INPLACE_BIN might be empty if we're distcleaning
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
ifeq "$$($1_$2_INSTALL_INPLACE)" "YES"
$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
"$$(CP)" -p $$< $$@
endif
......@@ -142,17 +162,25 @@ ifeq "$$($1_$2_v_HS_OBJS)" ""
$1_$2_GHC_LD_OPTS = -no-auto-link-packages -no-hs-main
endif
ifneq "$3" "0"
ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
$1_$2_GHC_LD_OPTS = \
-fno-use-rpaths \
$$(addprefix -optl-Wl$$(comma)-rpath -optl-Wl$$(comma),$$($1_$2_RPATHS))
endif
endif
ifneq "$$(BINDIST)" "YES"
# The quadrupled $'s here are because the _v_LIB variables aren't
# necessarily set when this part of the makefile is read
$1/$2/build/tmp/$$($1_$2_PROG) : \
$$(foreach dep,$$($1_$2_DEP_NAMES),\
$$(if $$(filter ghc,$$(dep)),\
$(if $(filter 0,$3),$$(compiler_stage1_v_LIB),\
$(if $(filter 1,$3),$$(compiler_stage2_v_LIB),\
$(if $(filter 2,$3),$$(compiler_stage2_v_LIB),\
$(if $(filter 0,$3),$$(compiler_stage1_PROGRAM_DEP_LIB),\
$(if $(filter 1,$3),$$(compiler_stage2_PROGRAM_DEP_LIB),\
$(if $(filter 2,$3),$$(compiler_stage2_PROGRAM_DEP_LIB),\
$$(error Bad build stage)))),\
$$$$(libraries/$$(dep)_dist-$(if $(filter 0,$3),boot,install)_v_LIB)))
$$$$(libraries/$$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB)))
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
......@@ -184,7 +212,7 @@ endif
$(call clean-target,$1,$2_inplace,$$($1_$2_INPLACE))
ifeq "$$($1_$2_INSTALL)" "YES"
ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO"
ifeq "$$($1_$2_WANT_INSTALLED_WRAPPER)" "YES"
INSTALL_LIBEXECS += $1/$2/build/tmp/$$($1_$2_PROG)
else ifeq "$$($1_$2_TOPDIR)" "YES"
INSTALL_TOPDIRS += $1/$2/build/tmp/$$($1_$2_PROG)
......
......@@ -16,31 +16,47 @@ $(call profStart, shell-wrapper($1,$2))
# $1 = dir
# $2 = distdir
ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO"
ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" ""
$1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROG).wrapper
endif
ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
all_$1_$2 : $$(INPLACE_BIN)/$$($1_$2_PROG)
ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES"
ifeq "$$($1_$2_TOPDIR)" "YES"
INPLACE_WRAPPER = $$(INPLACE_LIB)/$$($1_$2_PROG)
else
INPLACE_WRAPPER = $$(INPLACE_BIN)/$$($1_$2_PROG)
endif
all_$1_$2 : $$(INPLACE_WRAPPER)
$$(INPLACE_BIN)/$$($1_$2_PROG): WRAPPER=$$@
$$(INPLACE_BIN)/$$($1_$2_PROG): $$($1_$2_INPLACE) $$($1_$2_SHELL_WRAPPER_NAME)
$$(call removeFiles, $$@)
echo '#!$$(SHELL)' >> $$@
echo 'executablename="$$(TOP)/$$<"' >> $$@
echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
$$(INPLACE_WRAPPER): $$($1_$2_SHELL_WRAPPER_NAME)
endif
$$(INPLACE_WRAPPER): $$($1_$2_INPLACE)
$$(call removeFiles, $$@)
echo '#!$$(SHELL)' >> $$@
echo 'executablename="$$(TOP)/$$<"' >> $$@
echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
$$($1_$2_SHELL_WRAPPER_EXTRA)
$$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
$$(EXECUTABLE_FILE) $$@
ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
echo 'export LD_LIBRARY_PATH="$$($1_$2_DEP_LIB_DIRS_SEARCHPATH)"' >> $$@
endif
ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
else
echo 'exec "$$$$executablename" $$$${1+"$$$$@"}' >> $$@
endif
$$(EXECUTABLE_FILE) $$@
endif
ifeq "$$($1_$2_INSTALL)" "YES"
ifeq "$$($1_$2_WANT_INSTALLED_WRAPPER)" "YES"
ifeq "$$($1_$2_INSTALL_SHELL_WRAPPER_NAME)" ""
$1_$2_INSTALL_SHELL_WRAPPER_NAME = $$($1_$2_PROG)
......@@ -59,7 +75,7 @@ install_$1_$2_wrapper:
$$(call removeFiles, "$$(WRAPPER)")
$$(CREATE_SCRIPT) "$$(WRAPPER)"
echo '#!$$(SHELL)' >> "$$(WRAPPER)"
echo 'exedir="$$(ghclibexecdir)"' >> "$$(WRAPPER)"
echo 'exedir="$$(ghclibexecdir)/bin"' >> "$$(WRAPPER)"
echo 'exeprog="$$($1_$2_PROG)"' >> "$$(WRAPPER)"
echo 'executablename="$$$$exedir/$$$$exeprog"' >> "$$(WRAPPER)"
echo 'datadir="$$(datadir)"' >> "$$(WRAPPER)"
......@@ -70,9 +86,7 @@ install_$1_$2_wrapper:
cat $$($1_$2_SHELL_WRAPPER_NAME) >> "$$(WRAPPER)"
$$(EXECUTABLE_FILE) "$$(WRAPPER)"
endif # $1_$2_INSTALL
endif # $1_$2_SHELL_WRAPPER && !Windows
endif
$(call profEnd, shell-wrapper($1,$2))
endef
......@@ -3,6 +3,7 @@ utils/compare_sizes_USES_CABAL = YES
utils/compare_sizes_PACKAGE = compareSizes
utils/compare_sizes_MODULES = Main
utils/compare_sizes_dist-install_PROG = compareSizes$(exeext)
utils/compare_sizes_dist-install_INSTALL_INPLACE = NO
$(eval $(call build-prog,utils/compare_sizes,dist-install,1))
......@@ -12,6 +12,7 @@
utils/genapply_dist_MODULES = GenApply
utils/genapply_dist_PROG = $(GHC_GENAPPLY_PGM)
utils/genapply_dist_INSTALL_INPLACE = YES
utils/genapply_HC_OPTS += -package pretty
......
......@@ -13,5 +13,6 @@
utils/genprimopcode_dist_MODULES = Lexer Main ParserM Parser Syntax
utils/genprimopcode_dist_PROG = $(GHC_GENPRIMOP_PGM)
utils/genprimopcode_dist_HC_OPTS = -package array
utils/genprimopcode_dist_INSTALL_INPLACE = YES
$(eval $(call build-prog,utils/genprimopcode,dist,0))
This diff is collapsed.
......@@ -55,6 +55,7 @@ $(GHC_CABAL_DIR)_PACKAGE = ghc-cabal
$(GHC_CABAL_DIR)_dist-install_PROG = ghc-cabal$(exeext)
$(GHC_CABAL_DIR)_dist-install_INSTALL_INPLACE = NO
$(GHC_CABAL_DIR)_dist-install_MODULES = Main
$(GHC_CABAL_DIR)_dist-install_MORE_HC_OPTS = -static
$(eval $(call build-prog,utils/ghc-cabal,dist-install,1))
utils/ghc-pwd_USES_CABAL = YES
utils/ghc-pwd_PACKAGE = ghc-pwd
utils/ghc-pwd_dist-install_INSTALL_INPLACE = YES
utils/ghc-pwd_dist-install_PROG = ghc-pwd$(exeext)
utils/ghc-pwd_dist-install_MORE_HC_OPTS += -static
$(eval $(call build-prog,utils/ghc-pwd,dist-install,1))
......@@ -10,8 +10,9 @@
#
# -----------------------------------------------------------------------------
utils/ghctags_dist-install_MODULES = Main
utils/ghctags_dist-install_HC_OPTS = -package ghc
utils/ghctags_dist-install_INSTALL = NO
utils/ghctags_dist-install_PROG = ghctags$(exeext)
utils/ghctags_dist-install_MODULES = Main
utils/ghctags_dist-install_HC_OPTS = -package ghc
utils/ghctags_dist-install_INSTALL = NO
utils/ghctags_dist-install_INSTALL_INPLACE = YES
utils/ghctags_dist-install_PROG = ghctags$(exeext)
$(eval $(call build-prog,utils/ghctags,dist-install,2))
......@@ -10,14 +10,15 @@
#
# -----------------------------------------------------------------------------
utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \
Reorder.c TopTwenty.c AuxFile.c Deviation.c \
HpFile.c Marks.c Scale.c TraceElement.c \
Axes.c Dimensions.c Key.c PsFile.c Shade.c \
Utilities.c
utils/hp2ps_dist_C_SRCS = AreaBelow.c Curves.c Error.c Main.c \