]> git.argeo.org Git - lgpl/argeo-commons.git/blob - jni/jni.mk
Change Argeo Init branch in systemd
[lgpl/argeo-commons.git] / jni / jni.mk
1 TARGET_EXEC := libJava_$(NATIVE_PACKAGE).so
2
3 LDFLAGS = -shared -fPIC -Wl,-soname,$(TARGET_EXEC).$(MAJOR).$(MINOR) $(ADDITIONAL_LIBS)
4 CFLAGS = -O3 -fPIC
5
6 SRC_DIRS := .
7
8 #
9 # Generic Argeo
10 #
11 BUILD_DIR := $(SDK_BUILD_BASE)/jni/$(NATIVE_PACKAGE)
12
13 # Every folder in ./src will need to be passed to GCC so that it can find header files
14 INC_DIRS := $(shell find $(SRC_DIRS) -type d) $(JAVA_HOME)/include $(JAVA_HOME)/include/linux $(ADDITIONAL_INCLUDES)
15
16
17 .PHONY: clean all ide
18 all: $(SDK_BUILD_BASE)/jni/$(TARGET_EXEC)
19
20 # Find all the C and C++ files we want to compile
21 # Note the single quotes around the * expressions. Make will incorrectly expand these otherwise.
22 SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
23
24 # String substitution for every C/C++ file.
25 # As an example, hello.cpp turns into ./build/hello.cpp.o
26 OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
27
28 # String substitution (suffix version without %).
29 # As an example, ./build/hello.cpp.o turns into ./build/hello.cpp.d
30 DEPS := $(OBJS:.o=.d)
31
32 # Add a prefix to INC_DIRS. So moduleA would become -ImoduleA. GCC understands this -I flag
33 INC_FLAGS := $(addprefix -I,$(INC_DIRS))
34
35 # The -MMD and -MP flags together generate Makefiles for us!
36 # These files will have .d instead of .o as the output.
37 CPPFLAGS := $(INC_FLAGS) -MMD -MP
38
39 # The final build step.
40 $(SDK_BUILD_BASE)/jni/$(TARGET_EXEC): $(OBJS)
41 $(CC) $(OBJS) -o $@ $(LDFLAGS)
42
43 # Build step for C source
44 $(BUILD_DIR)/%.c.o: %.c
45 mkdir -p $(dir $@)
46 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
47
48 # Build step for C++ source
49 $(BUILD_DIR)/%.cpp.o: %.cpp
50 mkdir -p $(dir $@)
51 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
52
53 # Include the .d makefiles. The - at the front suppresses the errors of missing
54 # Makefiles. Initially, all the .d files will be missing, and we don't want those
55 # errors to show up.
56 -include $(DEPS)
57
58 # MAKEFILE_DIR := $(dir $(firstword $(MAKEFILE_LIST)))