Commit 7ef211e8 authored by Ian Lynagh's avatar Ian Lynagh

Use DESTDIR when installing

parent 21afd63e
......@@ -163,7 +163,6 @@ 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 "------------------------------------------------------------------------"; \
......@@ -207,8 +206,8 @@ endif
# Install gcc-extra-opts
install ::
@$(INSTALL_DIR) $(libdir)
$(INSTALL_DATA) $(INSTALL_OPTS) extra-gcc-opts $(libdir)
$(INSTALL_DIR) $(DESTDIR)$(libdir)
$(INSTALL_DATA) $(INSTALL_OPTS) extra-gcc-opts $(DESTDIR)$(libdir)
install-docs ::
@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
......
......@@ -11,7 +11,7 @@ include $(TOP)/mk/boilerplate.mk
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
LINK = ghc
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
......
......@@ -25,7 +25,7 @@ install::
else
LINK = ghci
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
......
......@@ -323,7 +323,7 @@ $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
install.library.%: installPackage/installPackage ifBuildable/ifBuildable
if ifBuildable/ifBuildable $*; then \
cd $* && \
../installPackage/installPackage $(prefix) $(bindir)/ghc-pkg; \
../installPackage/installPackage $(DESTDIR)$(prefix) $(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)/ghc-pkg-inplace $(DESTDIR)$(libdir)/package.conf; \
fi
.PHONY: binary-dist binary-dist.library.%
......
import Distribution.PackageDescription
import Distribution.Program
import Distribution.Setup
import Distribution.Simple
import Distribution.Simple.Configure
......@@ -10,7 +11,7 @@ import System.Environment
main :: IO ()
main = do args <- getArgs
case args of
pref : ghcpkg : args' ->
pref : ghcpkg : ghcpkgconf : args' ->
let verbosity = case args' of
[] -> normal
['-':'v':v] ->
......@@ -19,12 +20,12 @@ main = do args <- getArgs
_ -> Just v
in flagToVerbosity m
_ -> error ("Bad arguments: " ++ show args)
in doit pref ghcpkg verbosity
in doit pref ghcpkg ghcpkgconf verbosity
_ ->
error "Missing arguments"
doit :: FilePath -> FilePath -> Verbosity -> IO ()
doit pref ghcpkg verbosity =
doit :: FilePath -> FilePath -> FilePath -> Verbosity -> IO ()
doit pref ghcpkg ghcpkgconf verbosity =
do let userHooks = simpleUserHooks
copyFlags = (emptyCopyFlags NoCopyDest) {
copyVerbose = verbosity
......@@ -33,11 +34,11 @@ doit pref ghcpkg verbosity =
regUser = MaybeUserGlobal,
regVerbose = verbosity,
regGenScript = False,
regInPlace = False,
regWithHcPkg = Just ghcpkg
regInPlace = False
}
lbi <- getPersistBuildConfig
let pd = localPkgDescr lbi
i = installDirTemplates lbi
-- XXX This is an almighty hack, shadowing the base
-- Setup.hs hack
mkLib filt = case library pd of
......@@ -54,12 +55,23 @@ doit pref ghcpkg verbosity =
pd_reg = pd { library = Just (mkLib (const True)) }
-- When coying, we need to actually give a concrete
-- directory to copy to rather than "$topdir"
lbi_copy = lbi { installDirTemplates = (installDirTemplates lbi) { prefixDirTemplate = toPathTemplate pref } }
i_copy = i { prefixDirTemplate = toPathTemplate pref }
lbi_copy = lbi { installDirTemplates = i_copy }
-- 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_reg = lbi { installDirTemplates = (installDirTemplates lbi) { libSubdirTemplate = toPathTemplate "$pkgid" } }
progs = withPrograms lbi
prog = ConfiguredProgram {
programId = programName ghcPkgProgram,
programVersion = Nothing,
programArgs = ["--global-conf", ghcpkgconf],
programLocation = UserSpecified ghcpkg
}
progs' = updateProgram prog progs
i_reg = i { libSubdirTemplate = toPathTemplate "$pkgid" }
lbi_reg = lbi { installDirTemplates = i_reg,
withPrograms = progs' }
(copyHook simpleUserHooks) pd_copy lbi_copy userHooks copyFlags
(regHook simpleUserHooks) pd_reg lbi_reg userHooks registerFlags
return ()
......
......@@ -73,14 +73,14 @@ endif
# install links to script drivers.
#
install ::
@$(INSTALL_DIR) $(bindir)
@if ( $(PERL) -e '$$fn="$(bindir)/$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(bindir)"; \
$(RM) $(bindir)/$(LINK); \
$(LN_S) $(LINK_TARGET) $(bindir)/$(LINK); \
$(INSTALL_DIR) $(DESTDIR)$(bindir)
if ( $(PERL) -e '$$fn="$(DESTDIR)$(bindir)/$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(DESTDIR)$(bindir)"; \
$(RM) $(DESTDIR)$(bindir)/$(LINK); \
$(LN_S) $(LINK_TARGET) $(DESTDIR)$(bindir)/$(LINK); \
else \
echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(bindir) failed: \`$(bindir)/$(LINK)' already exists"; \
echo "Perhaps remove \`$(bindir)/$(LINK)' manually?"; \
echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(DESTDIR)$(bindir) failed: \`$(DESTDIR)$(bindir)/$(LINK)' already exists"; \
echo "Perhaps remove \`$(DESTDIR)$(bindir)/$(LINK)' manually?"; \
exit 1; \
fi;
......@@ -114,25 +114,27 @@ endif # LINK
.PHONY: install install-docs installdirs install-strip install-dirs install-docs show-install
show-install :
@echo "DESTDIR = $(DESTDIR)"
@echo "bindir = $(bindir)"
@echo "libdir = $(libdir)"
@echo "libexecdir = $(libexecdir) # by default, same as libdir"
@echo "datadir = $(datadir) # unused for ghc project"
@echo "ifacedir = $(ifacedir)"
@echo "headerdir = $(headerdir)"
@echo "includedir = $(includedir)"
#
# Sometimes useful to separate out the creation of install directories
# from the installation itself.
#
install-dirs ::
@$(INSTALL_DIR) $(bindir)
@$(INSTALL_DIR) $(libdir)
@$(INSTALL_DIR) $(libexecdir)
@$(INSTALL_DIR) $(datadir)
$(INSTALL_DIR) $(DESTDIR)$(bindir)
$(INSTALL_DIR) $(DESTDIR)$(libdir)
$(INSTALL_DIR) $(DESTDIR)$(libexecdir)
$(INSTALL_DIR) $(DESTDIR)$(datadir)
# Better do this first...
# but we won't for the moment, do it on-demand from
# within the various install targets instead.
#install:: install-dirs
install:: install-dirs
#
# Setting user/group ownership for the installed entities
......@@ -159,12 +161,11 @@ ifneq "$(strip $(INSTALL_PROGS))" ""
INSTALL_PROGS := $(foreach p, $(INSTALL_PROGS), $(addsuffix $(if $(suffix $(p)),,$(exeext)), $(basename $(p))))
install:: $(INSTALL_PROGS)
@$(INSTALL_DIR) $(bindir)
@for i in $(INSTALL_PROGS); do \
echo $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir); \
$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir) ; \
$(INSTALL_DIR) $(DESTDIR)$(bindir)
for i in $(INSTALL_PROGS); do \
$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
if test "$(darwin_TARGET_OS)" = "1"; then \
sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(bindir)/$$i ; \
sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
fi ; \
done
endif
......@@ -175,45 +176,45 @@ endif
#
ifneq "$(strip $(INSTALL_SCRIPTS))" ""
install:: $(INSTALL_SCRIPTS)
@$(INSTALL_DIR) $(bindir)
$(INSTALL_DIR) $(DESTDIR)$(bindir)
for i in $(INSTALL_SCRIPTS); do \
$(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(bindir); \
$(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(bindir); \
done
endif
ifneq "$(strip $(INSTALL_LIB_SCRIPTS))" ""
install:: $(INSTALL_LIB_SCRIPTS)
@$(INSTALL_DIR) $(libdir)
$(INSTALL_DIR) $(DESTDIR)$(libdir)
for i in $(INSTALL_LIB_SCRIPTS); do \
$(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(libdir); \
$(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
done
endif
ifneq "$(strip $(INSTALL_LIBEXEC_SCRIPTS))" ""
install:: $(INSTALL_LIBEXEC_SCRIPTS)
@$(INSTALL_DIR) $(libexecdir)
$(INSTALL_DIR) $(DESTDIR)$(libexecdir)
for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
$(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(libexecdir); \
$(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
done
endif
ifneq "$(strip $(INSTALL_LIBS))" ""
install:: $(INSTALL_LIBS)
@$(INSTALL_DIR) $(libdir)
$(INSTALL_DIR) $(DESTDIR)$(libdir)
for i in $(INSTALL_LIBS); do \
case $$i in \
*.a) \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(libdir); \
$(RANLIB) $(libdir)/`basename $$i` ;; \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
$(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
*.dll) \
$(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(libdir) ;; \
$(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
*.so) \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(libdir) ;; \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
*.dylib) \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(libdir); \
install_name_tool -id $(libdir)/`basename $$i` $(libdir)/`basename $$i` ;; \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
*) \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(libdir); \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
esac; \
done
endif
......@@ -226,61 +227,61 @@ ifneq "$(strip $(INSTALL_LIBEXECS))" ""
INSTALL_LIBEXECS := $(foreach p, $(INSTALL_LIBEXECS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
install:: $(INSTALL_LIBEXECS)
@$(INSTALL_DIR) $(libexecdir)
$(INSTALL_DIR) $(DESTDIR)$(libexecdir)
-for i in $(INSTALL_LIBEXECS); do \
$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(libexecdir); \
$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
if test "$(darwin_TARGET_OS)" = "1"; then \
sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(libexecdir)/`basename $$i` ; \
sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(DESTDIR)$(libexecdir)/`basename $$i` ; \
fi ; \
done
endif
ifneq "$(strip $(INSTALL_DATAS))" ""
install:: $(INSTALL_DATAS)
@$(INSTALL_DIR) $(datadir)
$(INSTALL_DIR) $(DESTDIR)$(datadir)
for i in $(INSTALL_DATAS); do \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir); \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(datadir); \
done
endif
ifneq "$(strip $(INSTALL_HEADERS))" ""
install:: $(INSTALL_HEADERS)
@$(INSTALL_DIR) $(headerdir)
$(INSTALL_DIR) $(DESTDIR)$(headerdir)
for i in $(INSTALL_HEADERS); do \
$(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(headerdir); \
$(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
done
endif
ifneq "$(strip $(INSTALL_IFACES))" ""
install:: $(INSTALL_IFACES)
@$(INSTALL_DIR) $(ifacedir)
$(INSTALL_DIR) $(DESTDIR)$(ifacedir)
for i in $(INSTALL_IFACES); do \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(ifacedir); \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(ifacedir); \
done
endif
ifneq "$(strip $(INSTALL_IFACES_WITH_DIRS))" ""
install:: $(INSTALL_IFACES_WITH_DIRS)
@$(INSTALL_DIR) $(ifacedir)
$(INSTALL_DIR) $(DESTDIR)$(ifacedir)
for i in $(INSTALL_IFACES_WITH_DIRS); do \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(ifacedir)/`dirname $$i`; \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(ifacedir)/`dirname $$i`; \
done
endif
ifneq "$(strip $(INSTALL_INCLUDES))" ""
install:: $(INSTALL_INCLUDES)
@$(INSTALL_DIR) $(includedir)
$(INSTALL_DIR) $(DESTDIR)$(includedir)
for i in $(INSTALL_INCLUDES); do \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(includedir); \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(includedir); \
done
endif
ifneq "$(strip $(INSTALL_DOCS))" ""
ifneq "$(XMLDocWays)" ""
install-docs:: $(INSTALL_DOCS)
@$(INSTALL_DIR) $(datadir)
$(INSTALL_DIR) $(DESTDIR)$(datadir)
for i in $(INSTALL_DOCS); do \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir); \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(datadir); \
done
endif
endif
......@@ -289,21 +290,21 @@ endif
ifneq "$(strip $(INSTALL_XML_DOC))" ""
ifneq "$(XMLDocWays)" ""
install-docs:: $(foreach i,$(XMLDocWays),$(INSTALL_XML_DOC)$(patsubst %.html-no-chunks,%.html,$(patsubst %.html,%/index.html,.$(i))))
@$(INSTALL_DIR) $(datadir)
@for i in $(XMLDocWays); do \
$(INSTALL_DIR) $(DESTDIR)$(datadir)
for i in $(XMLDocWays); do \
if [ $$i = "html" ]; then \
$(INSTALL_DIR) $(datadir)/html; \
$(INSTALL_DIR) $(datadir)/html/$(INSTALL_XML_DOC); \
echo "( cd $(INSTALL_XML_DOC) && $(CP) * $(datadir)/html/$(INSTALL_XML_DOC) )" ; \
( cd $(INSTALL_XML_DOC) && $(CP) * $(datadir)/html/$(INSTALL_XML_DOC) ) ; \
$(INSTALL_DIR) $(DESTDIR)$(datadir)/html; \
$(INSTALL_DIR) $(DESTDIR)$(datadir)/html/$(INSTALL_XML_DOC); \
echo "( cd $(INSTALL_XML_DOC) && $(CP) * $(DESTDIR)$(datadir)/html/$(INSTALL_XML_DOC) )" ; \
( cd $(INSTALL_XML_DOC) && $(CP) * $(DESTDIR)$(datadir)/html/$(INSTALL_XML_DOC) ) ; \
else \
$(INSTALL_DIR) $(datadir)/doc; \
echo $(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(datadir)/doc; \
$(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(datadir)/doc; \
$(INSTALL_DIR) $(DESTDIR)$(datadir)/doc; \
echo $(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(DESTDIR)$(datadir)/doc; \
$(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(DESTDIR)$(datadir)/doc; \
fi; \
if [ $$i = "html-no-chunks" ]; then \
echo $(CP) $(FPTOOLS_CSS_ABS) $(datadir)/doc; \
$(CP) $(FPTOOLS_CSS_ABS) $(datadir)/doc; \
echo $(CP) $(FPTOOLS_CSS_ABS) $(DESTDIR)$(datadir)/doc; \
$(CP) $(FPTOOLS_CSS_ABS) $(DESTDIR)$(datadir)/doc; \
fi \
done
endif
......@@ -314,6 +315,6 @@ endif
#
ifneq "$(way)" ""
install-strip::
@$(MAKE) EXTRA_INSTALL_OPTS='-s' install
$(MAKE) EXTRA_INSTALL_OPTS='-s' install
endif
......@@ -84,7 +84,7 @@ install::
-x c $(PACKAGE_CPP_OPTS) package.conf.in \
| grep -v '^#pragma GCC' \
| sed -e 's/""//g' -e 's/:[ ]*,/: /g' \
| $(bindir)/ghc-pkg update - --force
| $(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)/ghc-pkg-inplace --global-conf $(DESTDIR)$(libdir)/package.conf update - --force
# we could be more accurate here and add a dependency on
# driver/package.conf, but that doesn't work too well because of
......
......@@ -83,7 +83,7 @@ CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG)
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
LINK = ghc-pkg
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
......
......@@ -60,7 +60,7 @@ else
INSTALL_LIBEXECS += $(HS_PROG)
LINK = hsc2hs
LINK_TARGET = $(LINK)-$(ProjectVersion)
INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET)
INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT)
......
......@@ -15,7 +15,7 @@ all::
cat ghcprof.prl >> $(INPLACE_SCRIPT)
$(EXECUTABLE_FILE) $(INPLACE_SCRIPT)
INSTALLED_SCRIPT=$(bindir)/ghcprof
INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/ghcprof
install::
$(RM) -f $(INSTALLED_SCRIPT)
echo '#!$(PERL)' >> $(INSTALLED_SCRIPT)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment