2014-01-21 06:23:57 +00:00
|
|
|
export RUSTC = rustc
|
|
|
|
RUSTDOC = rustdoc
|
2014-02-11 03:20:53 +00:00
|
|
|
export RUSTFLAGS = -O -g --cfg ndebug
|
2014-01-21 06:23:57 +00:00
|
|
|
BUILDDIR = build
|
|
|
|
INSTALL_DIR = %PREFIX%
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Reconfiguration
|
|
|
|
###############################################################################
|
|
|
|
CONFIGURE_ARGS = %CONFIGURE_ARGS%
|
|
|
|
|
|
|
|
NEED_GIT_RECONFIG = $(shell git submodule status | grep -c '^\(+|-\)')
|
|
|
|
|
|
|
|
ifeq ($(NEED_GIT_RECONFIG),0)
|
|
|
|
else
|
|
|
|
.PHONY: config.stamp
|
|
|
|
endif
|
|
|
|
|
|
|
|
Makefile: config.stamp
|
|
|
|
|
|
|
|
config.stamp: configure Makefile.in
|
|
|
|
./configure $(CONFIGURE_ARGS)
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Dependencies
|
|
|
|
###############################################################################
|
|
|
|
PHF_DIR = submodules/rust-phf
|
|
|
|
PHF = $(foreach file,$(shell $(MAKE) -s -C $(PHF_DIR) print-targets),$(PHF_DIR)/$(file))
|
|
|
|
OPENSSL_DIR = submodules/rust-openssl
|
2014-02-09 23:55:31 +00:00
|
|
|
OPENSSL = $(foreach file,$(shell $(MAKE) -s -C $(OPENSSL_DIR) print-target),$(OPENSSL_DIR)/$(file))
|
2014-01-21 06:23:57 +00:00
|
|
|
|
|
|
|
$(PHF): config.stamp
|
|
|
|
$(MAKE) -C $(PHF_DIR)
|
|
|
|
touch $(PHF)
|
|
|
|
|
|
|
|
$(OPENSSL): config.stamp
|
|
|
|
$(MAKE) -C $(OPENSSL_DIR)
|
|
|
|
touch $(OPENSSL)
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Main targets
|
|
|
|
###############################################################################
|
2014-02-03 04:28:59 +00:00
|
|
|
POSTGRES_LIB_FILE = src/lib.rs
|
2014-02-09 23:55:31 +00:00
|
|
|
POSTGRES_LIB = $(foreach file,$(shell $(RUSTC) --crate-file-name $(POSTGRES_LIB_FILE)),$(BUILDDIR)/$(file))
|
2014-01-21 06:23:57 +00:00
|
|
|
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
|
|
|
|
|
2014-02-09 23:55:31 +00:00
|
|
|
LINK_ARGS = $(foreach file,$(OPENSSL),-L $(dir $(file))) $(foreach file,$(PHF),-L $(dir $(file)))
|
2014-01-21 06:23:57 +00:00
|
|
|
|
|
|
|
-include $(POSTGRES_LIB_DEPS)
|
|
|
|
-include $(POSTGRES_TEST_DEPS)
|
|
|
|
|
|
|
|
$(BUILDDIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
$(POSTGRES_LIB): $(POSTGRES_LIB_FILE) $(PHF) $(OPENSSL) | $(BUILDDIR)
|
|
|
|
$(RUSTC) $(RUSTFLAGS) $(LINK_ARGS) --dep-info $(POSTGRES_LIB_DEPS) \
|
|
|
|
--out-dir $(@D) $<
|
|
|
|
|
|
|
|
$(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: $(POSTGRES_TEST)
|
|
|
|
$(POSTGRES_TEST)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(BUILDDIR)
|
|
|
|
|
|
|
|
clean-deps:
|
|
|
|
$(MAKE) -C $(PHF_DIR) clean
|
|
|
|
$(MAKE) -C $(OPENSSL_DIR) clean
|
|
|
|
|
|
|
|
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 clean doc install
|