rust/mk/dist.mk

226 lines
7.6 KiB
Makefile
Raw Normal View History

2014-03-21 19:40:31 +01:00
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
2011-05-01 22:18:52 +02:00
######################################################################
# Distribution
######################################################################
2014-03-21 19:40:31 +01:00
# Primary targets:
#
# * dist - make all distribution artifacts
# * distcheck - sanity check dist artifacts
# * dist-tar-src - source tarballs
# * dist-win - Windows exe installers
# * dist-osx - OS X .pkg installers
# * dist-tar-bins - Ad-hoc Unix binary installers
2011-05-01 22:18:52 +02:00
PKG_NAME := rust
PKG_DIR = $(PKG_NAME)-$(CFG_RELEASE)
PKG_TAR = dist/$(PKG_DIR).tar.gz
2011-05-01 22:18:52 +02:00
ifeq ($(CFG_OSTYPE), apple-darwin)
PKG_OSX = dist/$(PKG_DIR).pkg
endif
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt
2011-10-06 02:41:01 +02:00
2012-01-19 02:25:54 +01:00
PKG_FILES := \
$(S)COPYRIGHT \
2012-12-07 23:37:01 +01:00
$(S)LICENSE-APACHE \
$(S)LICENSE-MIT \
$(S)AUTHORS.txt \
$(S)CONTRIBUTING.md \
2012-12-07 23:37:01 +01:00
$(S)README.md \
$(S)RELEASES.txt \
2011-05-01 22:18:52 +02:00
$(S)configure $(S)Makefile.in \
2012-01-20 21:06:14 +01:00
$(S)man \
2011-05-01 22:18:52 +02:00
$(addprefix $(S)src/, \
README.md \
2012-01-10 23:34:53 +01:00
compiletest \
doc \
driver \
2012-01-10 23:34:53 +01:00
etc \
$(foreach crate,$(CRATES),lib$(crate)) \
2012-01-10 23:34:53 +01:00
rt \
rustllvm \
snapshots.txt \
test) \
$(PKG_GITMODULES) \
$(filter-out Makefile config.stamp config.mk, \
$(MKFILE_DEPS))
2011-05-01 22:18:52 +02:00
2012-01-19 02:25:54 +01:00
UNROOTED_PKG_FILES := $(patsubst $(S)%,./%,$(PKG_FILES))
2012-12-08 03:45:27 +01:00
LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
cat $^ > $@
2011-05-01 22:18:52 +02:00
######################################################################
# Source tarball
######################################################################
$(PKG_TAR): $(PKG_FILES)
2011-05-01 22:18:52 +02:00
@$(call E, making dist dir)
$(Q)rm -Rf tmp/dist/$(PKG_DIR)
$(Q)mkdir -p tmp/dist/$(PKG_DIR)
$(Q)tar \
-C $(S) \
--exclude-vcs \
--exclude=*~ \
--exclude=*/llvm/test/*/*.ll \
--exclude=*/llvm/test/*/*.td \
--exclude=*/llvm/test/*/*.s \
--exclude=*/llvm/test/*/*/*.ll \
--exclude=*/llvm/test/*/*/*.td \
--exclude=*/llvm/test/*/*/*.s \
-c $(UNROOTED_PKG_FILES) | tar -x -C tmp/dist/$(PKG_DIR)
$(Q)tar -czf $(PKG_TAR) -C tmp/dist $(PKG_DIR)
$(Q)rm -Rf tmp/dist/$(PKG_DIR)
2011-05-01 22:18:52 +02:00
2014-03-21 19:40:31 +01:00
dist-tar-src: $(PKG_TAR)
######################################################################
# Windows .exe installer
######################################################################
2012-01-20 03:29:48 +01:00
ifdef CFG_ISCC
2014-03-21 19:40:31 +01:00
PKG_EXE = dist/$(PKG_DIR)-install.exe
%.iss: $(S)src/etc/pkg/%.iss
cp $< $@
2012-01-20 03:29:48 +01:00
%.ico: $(S)src/etc/pkg/%.ico
cp $< $@
2012-01-20 03:29:48 +01:00
$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
$(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
dist-prepare-win
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin
@$(call E, ISCC: $@)
$(Q)"$(CFG_ISCC)" $<
dist-prepare-win: PREPARE_HOST=$(CFG_BUILD)
dist-prepare-win: PREPARE_TARGETS=$(CFG_BUILD)
dist-prepare-win: PREPARE_DEST_DIR=tmp/dist/win
dist-prepare-win: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-prepare-win: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-prepare-win: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-prepare-win: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-prepare-win: PREPARE_CLEAN=true
dist-prepare-win: prepare-base
2011-05-01 22:18:52 +02:00
2012-01-20 03:29:48 +01:00
endif
2014-03-21 19:40:31 +01:00
dist-win: $(PKG_EXE)
######################################################################
# OS X .pkg installer
######################################################################
ifeq ($(CFG_OSTYPE), apple-darwin)
dist-prepare-osx: PREPARE_HOST=$(CFG_BUILD)
dist-prepare-osx: PREPARE_TARGETS=$(CFG_BUILD)
dist-prepare-osx: PREPARE_DEST_DIR=tmp/dist/pkgroot
dist-prepare-osx: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-prepare-osx: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-prepare-osx: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-prepare-osx: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-prepare-osx: prepare-base
$(PKG_OSX): Distribution.xml LICENSE.txt dist-prepare-osx
@$(call E, making OS X pkg)
$(Q)pkgbuild --identifier org.rust-lang.rust --root tmp/dist/pkgroot rust.pkg
$(Q)productbuild --distribution Distribution.xml --resources . $(PKG_OSX)
$(Q)rm -rf tmp rust.pkg
dist-osx: $(PKG_OSX)
endif
######################################################################
# Unix binary installer tarballs
######################################################################
2014-03-21 19:40:31 +01:00
dist-install-dirs: $(foreach host,$(CFG_HOST),dist-install-dir-$(host))
dist-tar-bins: $(foreach host,$(CFG_HOST),dist/$(PKG_DIR)-$(host).tar.gz)
define DEF_INSTALLER
dist-install-dir-$(1): PREPARE_HOST=$(1)
dist-install-dir-$(1): PREPARE_TARGETS=$(1)
dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_DIR)-$(1)
dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-install-dir-$(1): PREPARE_CLEAN=true
dist-install-dir-$(1): prepare-base
$$(Q)(cd $$(PREPARE_DEST_DIR)/ && find -type f) \
> $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/$$(CFG_RUSTLIBDIR)/manifest
$$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR)
dist/$$(PKG_DIR)-$(1).tar.gz: dist-install-dir-$(1)
@$(call E, build: $$@)
$$(Q)tar -czf dist/$$(PKG_DIR)-$(1).tar.gz -C tmp/dist $$(PKG_DIR)-$(1)
endef
$(foreach host,$(CFG_HOST),\
$(eval $(call DEF_INSTALLER,$(host))))
######################################################################
# Primary targets (dist, distcheck)
######################################################################
ifdef CFG_WINDOWSY_$(CFG_BUILD)
2014-03-21 19:40:31 +01:00
dist: dist-win
distcheck: dist
@echo
@echo -----------------------------------------------
2014-03-21 19:40:31 +01:00
@echo Rust ready for distribution (see ./dist)
@echo -----------------------------------------------
else
2014-03-21 19:40:31 +01:00
dist: dist-tar-src
distcheck: $(PKG_TAR)
$(Q)rm -Rf dist
$(Q)mkdir -p dist
@$(call E, unpacking $(PKG_TAR) in dist/$(PKG_DIR))
$(Q)cd dist && tar -xzf ../$(PKG_TAR)
@$(call E, configuring in dist/$(PKG_DIR)-build)
$(Q)mkdir -p dist/$(PKG_DIR)-build
$(Q)cd dist/$(PKG_DIR)-build && ../$(PKG_DIR)/configure
@$(call E, making 'check' in dist/$(PKG_DIR)-build)
$(Q)+make -C dist/$(PKG_DIR)-build check
@$(call E, making 'clean' in dist/$(PKG_DIR)-build)
$(Q)+make -C dist/$(PKG_DIR)-build clean
$(Q)rm -Rf dist
@echo
@echo -----------------------------------------------
2014-03-21 19:40:31 +01:00
@echo Rust ready for distribution (see ./dist)
@echo -----------------------------------------------
endif
.PHONY: dist distcheck