]>
git.argeo.org Git - cc0/argeo-build.git/blob - jni.mk
2bbcf44ab732104599f0b34a961a0284795ab89c
1 ARGEO_BUILD_BASE
:= $(dir $(lastword
$(MAKEFILE_LIST
)))
2 include $(ARGEO_BUILD_BASE
)common.mk
4 # The following variables should be declared in the including Makefile:
5 # NATIVE_PACKAGE this native package name
6 # A2_CATEGORY the (single) a2 category the bundles will belong to
8 # The following variables have default values which can be overriden
9 # DEP_NATIVE space-separated logical names of named depdencies
10 # ADDITIONAL_INC additional includes
11 # ADDITIONAL_LIBS additional native libraries
13 ADDITIONAL_INC ?
= $(foreach dep
, $(DEP_NATIVE
), /usr
/include/$(dep
))
14 ADDITIONAL_LIBS ?
= $(foreach dep
, $(DEP_NATIVE
), -l
$(dep
))
16 A2_NATIVE_CATEGORY
=$(A2_OUTPUT
)/lib
/linux
/$(shell uname
-m
)/$(A2_CATEGORY
)
17 TARGET_EXEC
:= libJava_
$(NATIVE_PACKAGE
).so
19 LDFLAGS ?
= -shared
-fPIC
-Wl
,-soname
,$(TARGET_EXEC
).
$(MAJOR
).
$(MINOR
) $(ADDITIONAL_LIBS
)
27 BUILD_DIR
:= $(SDK_BUILD_BASE
)/jni
/$(NATIVE_PACKAGE
)
30 INC_DIRS
:= $(shell find
$(SRC_DIRS
) -type d
) $(JAVA_HOME
)/include $(JAVA_HOME
)/include/linux
$(ADDITIONAL_INC
)
32 all: $(A2_NATIVE_CATEGORY
)/$(TARGET_EXEC
)
35 $(RM
) $(BUILD_DIR
)/*.o
36 $(RM
) $(A2_NATIVE_CATEGORY
)/$(TARGET_EXEC
)
39 $(CP
) $(A2_NATIVE_CATEGORY
)/$(TARGET_EXEC
) $(A2_NATIVE_INSTALL_TARGET
)
42 $(RM
) $(A2_NATIVE_INSTALL_TARGET
)/$(TARGET_EXEC
)
45 SRCS
:= $(shell find
$(SRC_DIRS
) -name
'*.cpp' -or
-name
'*.c' -or
-name
'*.s')
46 # Objects (example.cpp to ./org_example_core/example.cpp.o)
47 OBJS
:= $(SRCS
:%=$(BUILD_DIR
)/%.o
)
48 # Dependencies (example.cpp.o to ./org_example_core/example.cpp.d)
50 # Add -I prefix to include directories
51 INC_FLAGS
:= $(addprefix -I
,$(INC_DIRS
))
52 # Generate dependencies makefiles
53 CPPFLAGS
:= $(INC_FLAGS
) -MMD
-MP
56 $(A2_NATIVE_CATEGORY
)/$(TARGET_EXEC
): $(OBJS
)
57 mkdir
-p
$(A2_NATIVE_CATEGORY
)
58 $(CC
) $(OBJS
) -o
$@
$(LDFLAGS
)
60 # Build step for C source
61 $(BUILD_DIR
)/%.c.o
: %.c
63 $(CC
) $(CPPFLAGS
) $(CFLAGS
) -c
$< -o
$@
65 # Build step for C++ source
66 $(BUILD_DIR
)/%.
cpp.o
: %.
cpp
68 $(CXX
) $(CPPFLAGS
) $(CXXFLAGS
) -c
$< -o
$@
70 # Include the .d makefiles. (- pefix suppress errors if not found)
73 .PHONY
: clean all install uninstall