harfbuzz-sys 0.3.4

Rust bindings to the HarfBuzz text shaping engine
Documentation
FLAGS = -fPIC

ifeq (armv7-linux-androideabi,$(TARGET))
	# Reset TARGET variable because armv7 target name used by Rust is not 
	# the same as the target name needed for the CXX toolchain.
	TARGET = arm-linux-androideabi
	FLAGS += -march=armv7-a -mfpu=neon --target=$(TARGET)
endif

ifneq ($(HOST),$(TARGET))
  CXX ?= $(TARGET)-g++
  CC ?= $(TARGET)-gcc
  AR ?= $(TARGET)-ar
else
  CXX ?= g++
  CC ?= gcc
  AR ?= ar
endif

ifeq ($(DEBUG),true)
  FLAGS += -g
else
  FLAGS += -O2
endif

CFLAGS += $(FLAGS)
CXXFLAGS += $(FLAGS)

CONFIGURE_FLAGS = \
	--prefix=$(OUT_DIR) \
	--host=$(TARGET) \
	--enable-static \
	--disable-shared \
	--without-icu \
	--without-freetype \
	--without-glib \
	--with-coretext=auto

# Create a unique temporary build directory
BUILD_DIR := $(shell mktemp -d $(OUT_DIR)/rust_build.XXXXX)

all:
	# Copy source files to BUILD_DIR to avoid changing originals.
	cp -a $(CARGO_MANIFEST_DIR)/harfbuzz/* $(BUILD_DIR)
	# Touch in BUILD_DIR avoid regenerating files.
	$(MAKE) -f $(CARGO_MANIFEST_DIR)/makefile.touch touch HARFBUZZ="$(BUILD_DIR)"
	# Configure and build in BUILD_DIR, install from BUILD_DIR into OUT_DIR.
	cd $(BUILD_DIR) && \
	  ./configure $(CONFIGURE_FLAGS) CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CPPFLAGS="$(CPPFLAGS)" && \
	  make -j$(NUM_JOBS) && \
	  make install
	# Remove the no-longer-needed BUILD_DIR to save space.
	rm -rf $(BUILD_DIR)

.PHONY: all