rust-postgres/Makefile.in
2014-06-16 09:20:50 -07:00

92 lines
2.8 KiB
Makefile

export RUSTC := rustc
RUSTDOC := rustdoc
RUSTFLAGS := -O --cfg ndebug
BUILDDIR := build
INSTALL_DIR := %PREFIX%
###############################################################################
# Dependencies
###############################################################################
PHF_DIR := submodules/rust-phf
PHF := $(foreach file,$(shell $(MAKE) -s -C $(PHF_DIR) print-targets),$(PHF_DIR)/$(file))
PHF_STAMP := $(BUILDDIR)/phf.stamp
OPENSSL_DIR := submodules/rust-openssl
OPENSSL := $(foreach file,$(shell $(MAKE) -s -C $(OPENSSL_DIR) print-target),$(OPENSSL_DIR)/$(file))
OPENSSL_STAMP := $(BUILDDIR)/openssl.stamp
$(PHF): $(PHF_STAMP)
$(PHF_STAMP): | $(BUILDDIR)
$(MAKE) -C $(PHF_DIR)
touch $(PHF_STAMP)
$(OPENSSL): $(OPENSSL_STAMP)
$(OPENSSL_STAMP): | $(BUILDDIR)
$(MAKE) -C $(OPENSSL_DIR)
touch $(OPENSSL_STAMP)
###############################################################################
# Main targets
###############################################################################
POSTGRES_LIB_FILE := src/lib.rs
POSTGRES_LIB := $(foreach file,$(shell $(RUSTC) --crate-file-name $(POSTGRES_LIB_FILE)),$(BUILDDIR)/$(file))
POSTGRES_STAMP := $(BUILDDIR)/postgres.stamp
POSTGRES_TEST := $(BUILDDIR)/$(shell $(RUSTC) --test --crate-file-name $(POSTGRES_LIB_FILE))
POSTGRES_LIB_DEPS := $(BUILDDIR)/postgres.d
POSTGRES_TEST_DEPS := $(BUILDDIR)/postgres_test.d
LINK_ARGS := $(foreach file,$(OPENSSL),-L $(dir $(file))) $(foreach file,$(PHF),-L $(dir $(file)))
-include $(POSTGRES_LIB_DEPS)
-include $(POSTGRES_TEST_DEPS)
$(BUILDDIR):
mkdir -p $@
$(POSTGRES_LIB): $(POSTGRES_STAMP)
$(POSTGRES_STAMP): $(POSTGRES_LIB_FILE) $(PHF) $(OPENSSL) | $(BUILDDIR)
$(RUSTC) $(RUSTFLAGS) $(LINK_ARGS) --dep-info $(POSTGRES_LIB_DEPS) \
--out-dir $(@D) $<
touch $(POSTGRES_STAMP)
$(POSTGRES_TEST): $(POSTGRES_LIB_FILE) $(PHF) $(OPENSSL) | $(BUILDDIR)
$(RUSTC) $(RUSTFLAGS) $(LINK_ARGS) --dep-info $(POSTGRES_TEST_DEPS) \
--out-dir $(@D) --test $<
all: $(POSTGRES_LIB)
.DEFAULT_GOAL := all
.PHONY: all
###############################################################################
# Utility
###############################################################################
check-test: $(POSTGRES_TEST)
$(POSTGRES_TEST)
check-doc: $(POSTGRES_LIB)
$(RUSTDOC) $(LINK_ARGS) -L $(BUILDDIR) --test $(POSTGRES_LIB_FILE)
check: check-test check-doc
clean:
rm -rf $(BUILDDIR)
clean-deps:
$(MAKE) -C $(PHF_DIR) clean
$(MAKE) -C $(OPENSSL_DIR) clean
rm -f $(PHF_STAMP) $(OPENSSL_STAMP)
doc: $(OPENSSL) $(PHF)
$(RUSTDOC) $(LINK_ARGS) $(POSTGRES_LIB_FILE)
install: $(POSTGRES_LIB)
$(MAKE) -C $(PHF_DIR) install INSTALL_DIR=$(abspath $(INSTALL_DIR))
$(MAKE) -C $(PHF_DIR) install INSTALL_DIR=$(abspath $(INSTALL_DIR))
install $(POSTGRES_LIB) $(INSTALL_DIR)
.PHONY: check-test check-doc check clean clean-deps doc install