# Copyright 2019 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy # of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. .PHONY: all all: Makefile debug CARGO_FLAGS = --features "$(FEATURES)" # TODO(jmmv): Should automatically reinvoke configure... but this is difficult # because we need to remember the flags originally passed by the user, and # we need to tell make to reload the Makefile somehow. Makefile: configure Makefile.in @echo "Makefile out of date; rerun ./configure with desired args" @false @IS_BMAKE@RUST_SRCS != find src -name "*.rs" @IS_GNUMAKE@RUST_SRCS = $(shell find src -name "*.rs") target/debug/sandboxfs: Cargo.toml $(RUST_SRCS) $(CARGO) build $(CARGO_FLAGS) .PHONY: debug debug: target/debug/sandboxfs .PHONY: release release: target/release/sandboxfs target/release/sandboxfs: Cargo.toml $(RUST_SRCS) $(CARGO) build $(CARGO_FLAGS) --release .PHONY: check check: check-unit check-integration check-unit: Cargo.toml $(RUST_SRCS) RUST_BACKTRACE=full $(CARGO) test $(CARGO_FLAGS) --verbose SANDBOXFS_BINARY = $$(pwd)/target/debug/sandboxfs @IS_BMAKE@GO_SRCS != find integration -name "*.go" @IS_GNUMAKE@GO_SRCS = $(shell find integration -name "*.go") check-integration: target/debug/sandboxfs $(GO_SRCS) @if [ -n "$(GOROOT)" ]; then \ set -x; \ GOPATH=$(GOPATH) GOROOT=$(GOROOT) $(GOROOT)/bin/go test \ -v -timeout=600s \ github.com/bazelbuild/sandboxfs/integration \ -features="$(FEATURES)" \ -sandboxfs_binary="$(SANDBOXFS_BINARY)" \ $(CHECK_INTEGRATION_FLAGS); \ else \ echo "WARNING: Go not enabled; integration tests not run"; \ fi .PHONY: lint lint: $(CARGO) clippy $(CARGO_FLAGS) --all-features --all-targets \ -- -D warnings @if [ -n "$(GOROOT)" ]; then \ set -x; \ PATH=$(GOPATH)/bin:$${PATH} GOPATH=$(GOPATH) GOROOT=$(GOROOT) \ $(GOROOT)/bin/go run \ github.com/bazelbuild/sandboxfs/admin/lint $(LINT_FILES); \ else \ echo "WARNING: Go not enabled; linter not run"; \ fi .PHONY: install install: target/release/sandboxfs install -m 0755 -d $(DESTDIR)$(PREFIX)/bin install -m 0755 -c target/release/sandboxfs \ $(DESTDIR)$(PREFIX)/bin/sandboxfs install -m 0755 -d $(DESTDIR)$(PREFIX)/share/man/man1 install -m 0644 -c man/sandboxfs.1 $(DESTDIR)$(PREFIX)/share/man/man1 install -m 0755 -d $(DESTDIR)$(PREFIX)/share/doc/sandboxfs install -m 0644 -c AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE \ NEWS.md README.md $(DESTDIR)$(PREFIX)/share/doc/sandboxfs .PHONY: clean clean: rm -rf $(CLEANFILES) .PHONY: distclean distclean: clean rm -rf $(DISTCLEANFILES)