blob: 8d59aa8df84a543d418682fddae21b4d0dfa2c7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# 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)
# '--as-needed' causes test failure
LDFLAGS := $(LDFLAGS) -Wl,--no-as-needed
$(OUT_DIR)/$(SONAME): $(OBJS) | $(OUT_DIR)
$(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) $@
|