cargo/Makefile.in
Alex Crichton bb82035f9c Bump version numbers
Working on 0.12.0 now
2016-05-26 09:36:37 -07:00

337 lines
11 KiB
Makefile

CFG_RELEASE_NUM=0.12.0
CFG_RELEASE_LABEL=
OPENSSL_VERS=1.0.2h
OPENSSL_SHA256=1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919
include config.mk
ifneq ($(CFG_LOCAL_RUST_ROOT),)
export LD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(LD_LIBRARY_PATH)
export DYLD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(DYLD_LIBRARY_PATH)
endif
export PATH := $(dir $(CFG_RUSTC)):$(PATH)
ifdef CFG_ENABLE_NIGHTLY
CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)-nightly
CFG_PACKAGE_VERS = nightly
else
CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)
CFG_PACKAGE_VERS=$(CFG_RELEASE)
endif
CFG_BUILD_DATE = $(shell date +%F)
ifeq ($(wildcard .git),)
CFG_VERSION = $(CFG_RELEASE) (built $(CFG_BUILD_DATE))
else
CFG_VER_DATE = $(shell git log -1 --date=short --pretty=format:'%cd')
CFG_VER_HASH = $(shell git rev-parse --short HEAD)
CFG_VERSION = $(CFG_RELEASE) ($(CFG_VER_HASH) $(CFG_VER_DATE))
endif
PKG_NAME = cargo-$(CFG_PACKAGE_VERS)
ifdef CFG_DISABLE_VERIFY_INSTALL
MAYBE_DISABLE_VERIFY=--disable-verify
else
MAYBE_DISABLE_VERIFY=
endif
ifdef CFG_DISABLE_OPTIMIZE
OPT_FLAG=
else
OPT_FLAG=--release
endif
ifdef VERBOSE
VERBOSE_FLAG=--verbose
else
VERBOSE_FLAG=
endif
ifdef CFG_CUSTOM_BUILD_DIR
export CARGO_TARGET_DIR := $(CFG_CUSTOM_BUILD_DIR)
endif
S := $(CFG_SRC_DIR)/
export CFG_VERSION
export CFG_DISABLE_CROSS_TESTS
ifeq ($(OS),Windows_NT)
X = .exe
endif
TARGET_ROOT = target
BIN_TARGETS := cargo
BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%)
BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS))
define DIST_TARGET
ifdef CFG_DISABLE_OPTIMIZE
TARGET_$(1) = $$(TARGET_ROOT)/$(1)/debug
else
TARGET_$(1) = $$(TARGET_ROOT)/$(1)/release
endif
DISTDIR_$(1) = $$(TARGET_$(1))/dist
IMGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)-image
OVERLAYDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)-overlay
PKGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)
BIN_TARGETS_$(1) := $$(BIN_TARGETS:%=$$(TARGET_$(1))/%$$(X))
endef
$(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target))))
ifdef CFG_LOCAL_CARGO
CARGO := $(CFG_LOCAL_CARGO)
else
CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X)
endif
all: $(foreach target,$(CFG_TARGET),cargo-$(target))
define CARGO_TARGET
cargo-$(1): $$(CARGO) target/openssl/$(1).stamp
$$(CFG_RUSTC) -V
$$(CARGO) --version
$$(CARGO) build --target $(1) \
--manifest-path $(S)Cargo.toml \
$$(OPT_FLAG) $$(VERBOSE_FLAG) $$(ARGS)
test-unit-$(1): $$(CARGO)
@mkdir -p target/$(1)/cit
$$(CARGO) test --target $(1) $$(VERBOSE_FLAG) $$(only)
endef
$(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target))))
$(TARGET_ROOT)/snapshot/bin/cargo$(X): $(S)src/snapshots.txt
$(CFG_PYTHON) $(S)src/etc/dl-snapshot.py $(CFG_BUILD)
touch $@
# === Tests
test: style no-exes $(foreach target,$(CFG_TARGET),test-unit-$(target))
style:
sh tests/check-style.sh
no-exes:
find $$(git ls-files) -type f \
\( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
-not -name configure -not -name '*.sh' -not -name '*.rs' \
-not -name '*.py' -not -wholename "*/rust-installer/*" | \
grep '.*' \
&& exit 1 || exit 0
# === Misc
Makefile config.mk: config.stamp
config.stamp: $(CFG_SRC_DIR)configure $(CFG_SRC_DIR)Makefile.in
$(CFG_SRC_DIR)configure $(CFG_CONFIGURE_ARGS)
clean-all: clean
clean:
rm -rf $(TARGET_ROOT)
# === Documentation
DOCS := index faq config guide manifest build-script pkgid-spec crates-io \
environment-variables specifying-dependencies
DOC_DIR := target/doc
DOC_OPTS := --markdown-no-toc \
--markdown-css stylesheets/normalize.css \
--markdown-css stylesheets/all.css \
--markdown-css stylesheets/prism.css \
--html-in-header src/doc/html-headers.html \
--html-before-content src/doc/header.html \
--html-after-content src/doc/footer.html
ASSETS := CNAME images/noise.png images/forkme.png images/Cargo-Logo-Small.png \
stylesheets/all.css stylesheets/normalize.css javascripts/prism.js \
javascripts/all.js stylesheets/prism.css images/circle-with-i.png \
images/search.png images/org-level-acl.png images/auth-level-acl.png \
favicon.ico
doc: $(foreach doc,$(DOCS),target/doc/$(doc).html) \
$(foreach asset,$(ASSETS),target/doc/$(asset)) \
target/doc/cargo/index.html
target/doc/cargo/index.html:
$(CARGO) doc --no-deps
$(DOC_DIR)/%.html: src/doc/%.md src/doc/html-headers.html src/doc/header.html src/doc/footer.html
@mkdir -p $(@D)
$(CFG_RUSTDOC) $< -o $(@D) $(DOC_OPTS)
$(DOC_DIR)/%: src/doc/%
@mkdir -p $(@D)
cp $< $@
OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64
OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64
OPENSSL_OS_i686-unknown-linux-gnu := linux-elf
OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4
OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4
OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4
OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64
OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf
OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64
OPENSSL_OS_x86_64-unknown-netbsd := BSD-x86_64
OPENSSL_CC_x86_64-unknown-linux-gnu := gcc
OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc
OPENSSL_CC_i686-unknown-linux-gnu := gcc
OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc
OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc
OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc
OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc
OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc
OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc
OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc
OPENSSL_AR_x86_64-unknown-linux-gnu := ar
OPENSSL_AR_x86_64-unknown-linux-musl := ar
OPENSSL_AR_i686-unknown-linux-gnu := ar
OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar
OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar
OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar
OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar
OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar
OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar
OPENSSL_AR_x86_64-unknown-netbsd := x86_64-unknown-netbsd-ar
SETARCH_i686-unknown-linux-gnu := setarch i386
OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32
define BUILD_OPENSSL
ifdef OPENSSL_OS_$(1)
ifdef CFG_ENABLE_NIGHTLY
OPENSSL_INSTALL_$(1) := $$(CFG_BUILD_DIR)/target/openssl/$(1)-install
target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \
| target/openssl/
mkdir -p target/openssl/$(1)
tar xf $$< -C target/openssl/$(1) --strip-components 1
(cd target/openssl/$(1) && \
CC=$$(OPENSSL_CC_$(1)) \
AR=$$(OPENSSL_AR_$(1)) \
$$(SETARCH_$(1)) ./Configure --prefix=$$(OPENSSL_INSTALL_$(1)) \
no-dso $$(OPENSSL_OS_$(1)) -fPIC $$(OPENSSL_CFLAGS_$(1))&& \
$(MAKE) -j10 && \
$(MAKE) install)
touch $$@
# variables read by various build scripts to find openssl
cargo-$(1): export OPENSSL_STATIC := 1
cargo-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1))
cargo-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib
cargo-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include
test-unit-$(1): export OPENSSL_STATIC := 1
test-unit-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1))
test-unit-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib
test-unit-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include
# build libz statically into the cargo we're producing
cargo-$(1): export LIBZ_SYS_STATIC := 1
else
target/openssl/$(1).stamp:
endif
else
target/openssl/$(1).stamp:
endif
endef
$(foreach target,$(CFG_TARGET),$(eval $(call BUILD_OPENSSL,$(target))))
target/openssl/openssl-$(OPENSSL_VERS).tar.gz: | target/openssl/
curl -o $(@) https://openssl.org/source/openssl-$(OPENSSL_VERS).tar.gz
sha256sum $(@) > $(@).sha256
test $(OPENSSL_SHA256) = `cut -d ' ' -f 1 $(@).sha256`
target/openssl/:
mkdir -p $(@)
# === Distribution
define DO_DIST_TARGET
dist-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
# One may wonder why some of the commands here are prefixed with `cd -P .`, and
# that's a good question! On some of the windows bots, PWD has a windows-style
# path, and that ends up choking the installation script in various ways.
# Prefixing commands with this `cd -P .` helps the bots to set the right PWD env
# var.
distcheck-$(1): dist-$(1)
rm -rf $$(TARGET_$(1))/distcheck
mkdir -p $$(TARGET_$(1))/distcheck
(cd $$(TARGET_$(1))/distcheck && tar xf ../dist/$$(PKG_NAME)-$(1).tar.gz)
cd -P . && $$(TARGET_$(1))/distcheck/$$(PKG_NAME)-$(1)/install.sh \
--prefix=$$(TARGET_$(1))/distcheck/install
$$(TARGET_$(1))/distcheck/install/bin/cargo -V > /dev/null
cd -P . && $$(TARGET_$(1))/distcheck/$$(PKG_NAME)-$(1)/install.sh \
--prefix=$$(TARGET_$(1))/distcheck/install --uninstall
[ -f $$(TARGET_$(1))/distcheck/install/bin/cargo$(X) ] && exit 1 || exit 0
prepare-image-$(1):
@[ -f $$(TARGET_$(1))/cargo$$(X) ] || echo 'Please run `make` first'
@[ -f $$(TARGET_$(1))/cargo$$(X) ]
rm -rf $$(IMGDIR_$(1))
mkdir -p $$(IMGDIR_$(1))/bin $$(IMGDIR_$(1))/lib/cargo \
$$(IMGDIR_$(1))/share/man/man1 \
$$(IMGDIR_$(1))/share/doc/cargo \
$$(IMGDIR_$(1))/share/zsh/site-functions \
$$(IMGDIR_$(1))/etc/bash_completion.d
cp $$(TARGET_$(1))/cargo$$(X) $$(IMGDIR_$(1))/bin
cp $(S)src/etc/man/*.1 $$(IMGDIR_$(1))/share/man/man1
cp $(S)src/etc/_cargo $$(IMGDIR_$(1))/share/zsh/site-functions/_cargo
cp $(S)src/etc/cargo.bashcomp.sh $$(IMGDIR_$(1))/etc/bash_completion.d/cargo
cp $(S)README.md $(S)LICENSE-MIT $(S)LICENSE-APACHE \
$(S)LICENSE-THIRD-PARTY \
$$(IMGDIR_$(1))/share/doc/cargo
prepare-overlay-$(1):
rm -Rf $$(OVERLAYDIR_$(1))
mkdir -p $$(OVERLAYDIR_$(1))
cp $(S)README.md $(S)LICENSE-MIT $(S)LICENSE-APACHE \
$(S)LICENSE-THIRD-PARTY \
$$(OVERLAYDIR_$(1))
echo "$(CFG_VERSION)" > $$(OVERLAYDIR_$(1))/version
$$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz: prepare-image-$(1) prepare-overlay-$(1)
sh $(S)src/rust-installer/gen-installer.sh \
--product-name=Rust \
--rel-manifest-dir=rustlib \
--success-message=Rust-is-ready-to-roll. \
--image-dir=$$(IMGDIR_$(1)) \
--work-dir=./$$(DISTDIR_$(1)) \
--output-dir=./$$(DISTDIR_$(1)) \
--non-installed-overlay=$$(OVERLAYDIR_$(1)) \
--package-name=$$(PKG_NAME)-$(1) \
--component-name=cargo \
--legacy-manifest-dirs=rustlib,cargo
rm -Rf $$(IMGDIR_$(1))
install-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
$$(PKGDIR_$(1))/install.sh \
--prefix="$$(CFG_PREFIX)" \
--destdir="$$(DESTDIR)" $$(MAYBE_DISABLE_VERIFY)
uninstall-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
$$(PKGDIR_$(1))/install.sh \
--prefix="$$(CFG_PREFIX)" \
--destdir="$$(DESTDIR)" \
--uninstall
endef
$(foreach target,$(CFG_TARGET),$(eval $(call DO_DIST_TARGET,$(target))))
dist: $(foreach target,$(CFG_TARGET),dist-$(target))
distcheck: $(foreach target,$(CFG_TARGET),distcheck-$(target))
install: $(foreach target,$(CFG_TARGET),install-$(target))
uninstall: $(foreach target,$(CFG_TARGET), uninstall-$(target))
# Setup phony tasks
.PHONY: all clean clean-all dist distcheck install uninstall test test-unit style
# Disable unnecessary built-in rules
.SUFFIXES: