aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-05 00:12:37 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-05 00:12:37 +0200
commitbeb6c2acc2ffc7b1f826f2e4ca953dc6391f664b (patch)
treed335cb403cd9126264e8f391175dbf789e249ccd /Makefile
parentflags to use to acces jni headers (diff)
downloadjlibgamma-beb6c2acc2ffc7b1f826f2e4ca953dc6391f664b.tar.gz
jlibgamma-beb6c2acc2ffc7b1f826f2e4ca953dc6391f664b.tar.bz2
jlibgamma-beb6c2acc2ffc7b1f826f2e4ca953dc6391f664b.tar.xz
makefile can build library + add .c files with all prototypes
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 25 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index c8c4397..b6eb10a 100644
--- a/Makefile
+++ b/Makefile
@@ -52,7 +52,7 @@ endif
# Platform dependent flags
ifeq ($(PLATFORM),w32)
SHARED = -mdll
-LDSO = -Wl,-soname,jlibgamma.$(SO).$(LIB_MAJOR)
+LDSO = -Wl,-soname,libgamma-java.$(SO).$(LIB_MAJOR)
PIC =
else
ifeq ($(PLATFORM),osx)
@@ -61,7 +61,7 @@ LDSO =
PIC = -fPIC
else
SHARED = -shared
-LDSO = -Wl,-soname,jlibgamma.$(SO).$(LIB_MAJOR)
+LDSO = -Wl,-soname,libgamma-java.$(SO).$(LIB_MAJOR)
PIC = -fPIC
endif
endif
@@ -82,7 +82,10 @@ JAVA_WARN = -Xlint:all
# Addition flags to use when compiling C code with JNI support
-JNI_FLAGS=-I$(JAVA_HOME)/include
+CC_JNI_FLAGS = -I$(JAVA_HOME)/include
+
+# Addition flags to use when linking natvie objets with JNI support
+LD_JNI_FLAGS =
# Flags to use when compiling C code
CC_FLAGS = -std=$(STD) $(C_OPTIMISE) $(CFLAGS) $(PIC) $(CPPFLAGS) $(WARN)
@@ -108,7 +111,10 @@ JAVA_H = AdjustmentMethod CRTC GammaRamps LibgammaException Partition Ramp Site
all: lib
.PHONY: lib
-lib: jar headers
+lib: jar so
+
+.PHONY: so
+so: bin/libgamma-java.$(SO).$(LIB_VERSION) bin/libgamma-java.$(SO).$(LIB_MAJOR) bin/libgamma-java.$(SO)
.PHONY: jar
jar: bin/jlibgamma.jar
@@ -133,6 +139,21 @@ obj/libgamma_%.h: obj/libgamma/%.class
$(JAVAH) -classpath obj -jni -d obj \
$$(echo "$<" | sed -e 's:^obj/::' -e 's:.class$$::' | sed -e 's:/:.:g')
+obj/libgamma_%.o: src/libgamma_%.c obj/libgamma_%.h
+ $(CC) $(CC_FLAGS) $(CC_JNI_FLAGS) -iquote"obj" -c -o $@ $<
+
+bin/libgamma-java.$(SO).$(LIB_VERSION): $(foreach O,$(JAVA_H),obj/libgamma_$(O).o)
+ @mkdir -p bin
+ $(CC) $(LD_FLAGS) $(LD_JNI_FLAGS) $(SHARED) $(LDSO) -o $@ $<
+
+bin/libgamma-java.$(SO).$(LIB_MAJOR):
+ @mkdir -p bin
+ ln -sf libgamma-java.$(SO).$(LIB_VERSION) $@
+
+bin/libgamma-java.$(SO):
+ @mkdir -p bin
+ ln -sf libgamma-java.$(SO).$(LIB_VERSION) $@
+
.PHONY: clean
clean: