# Gentoo custom Makefile for the JNI portion of lz4-java # # Adapted from the logic for target "compile-jni" in build.xml, # but uses lz4 installed on the system. This Makefile respects # custom CFLAGS and LDFLAGS settings, whereas build.xml does not. # Java system properties read by build.xml PLATFORM ?= linux SRC ?= src BUILD ?= build JAVA_HOME ?= # Requires lz4-java-*-print-os-props.patch OS_ARCH := $(shell ant os-props 2>&1 > /dev/null && \ grep 'os\.arch=' os.properties | sed -e 's/os\.arch=//') MKDIR_P = mkdir -p SRC_DIR := $(SRC)/jni OBJS_DIR_PREFIX := $(BUILD)/objects OBJS_DIR := $(OBJS_DIR_PREFIX)/$(SRC_DIR) OUT_DIR := $(BUILD)/jni/net/jpountz/util/$(PLATFORM)/$(OS_ARCH) SRC_FILES := $(wildcard $(SRC_DIR)/*.c) OBJS := $(addprefix $(OBJS_DIR_PREFIX)/,$(SRC_FILES:.c=.o)) SONAME = liblz4-java.so # C compiler arguments may be obtained by running 'ant -v compile-jni', # as long as dev-java/cpptasks is in the classpath CFLAGS := -fPIC $(CFLAGS) $(OUT_DIR)/$(SONAME): $(OBJS) | $(OUT_DIR) # '-llz4' must be listed after this package's objects # https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed#Importance_of_linking_order $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname,$(SONAME) -o $@ $^ -llz4 $(OBJS_DIR_PREFIX)/%.o: %.c | $(OBJS_DIR) $(CC) $(CFLAGS) -c -o $@ \ -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/$(PLATFORM) \ -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(PLATFORM) \ -I$(BUILD)/jni-headers \ $< $(OUT_DIR): $(MKDIR_P) $@ $(OBJS_DIR): $(MKDIR_P) $@