- Timestamp:
- Feb 6, 2014 11:50:41 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/swig/java/Makefile
r4711 r4737 4 4 ifneq ($(findstring android,$(TARGET_NAME)),) 5 5 OS=android 6 # Set dummy JAVA_HOME as JNI is bundled in Android NDK, only need javac here 7 JAVA_HOME := $(dir $(shell which javac)) 6 8 else 7 9 ifneq ($(findstring darwin,$(TARGET_NAME)),) … … 27 29 # Get JDK location 28 30 ifeq ("$(JAVA_HOME)","") 29 # Get javac location to determine JDK location 30 JAVAC_PATH = $(shell which javac) 31 ifeq ("$(JAVAC_PATH)","") 32 $(error Cannot determine JDK location using 'which' command. Please define JAVA_HOME envvar) 31 32 verify_jdk = $(shell test -d $(1)/include && test -d $(1)/lib && \ 33 echo inclib1) \ 34 $(shell test -d $(1)/Headers && test -d $(1)/Libraries && \ 35 echo inclib2) \ 36 $(shell test -x $(1)/bin/javac && echo bin1) \ 37 $(shell test -x $(1)/Commands/javac && echo bin2) \ 38 $(shell test -x $(1)/javac && echo bin3) 39 40 get_java_inc = $(if $(findstring inclib1,$(1)),$(2)/include,\ 41 $(if $(findstring inclib2,$(1)),$(2)/Headers,)) 42 get_java_lib = $(if $(findstring inclib1,$(1)),$(2)/lib,\ 43 $(if $(findstring inclib2,$(1)),$(2)/Libraries,)) 44 get_java_bin = $(if $(findstring bin1,$(1)),$(2)/bin,\ 45 $(if $(findstring bin2,$(1)),$(2)/Commands,\ 46 $(if $(findstring bin3,$(1)),$(2),))) 47 48 49 # Check with 'which javac' 50 WHICH_JAVAC := $(shell which javac) 51 ifneq ($(WHICH_JAVAC),) 52 WHICH_JAVAC := $(dir $(realpath $(WHICH_JAVAC))) 53 WHICH_JAVAC := $(patsubst %/bin/,%,$(WHICH_JAVAC)) 54 TMP_RES := $(call verify_jdk,$(WHICH_JAVAC)) 55 ifneq ($(findstring inclib,$(TMP_RES)),) 56 JAVA_HOME := $(WHICH_JAVAC) 57 JAVA_INC := $(call get_java_inc,$(TMP_RES),$(JAVA_HOME)) 58 JAVA_LIB := $(call get_java_lib,$(TMP_RES),$(JAVA_HOME)) 59 endif 33 60 endif 34 61 35 JAVAC_PATH := $(realpath $(JAVAC_PATH)) 36 JAVA_BIN := $(dir $(JAVAC_PATH)) 37 JAVA_HOME := $(patsubst %/bin/,%,$(JAVA_BIN)) 62 # MacOS specifics 63 ifeq ($(OS)$(JAVA_HOME),darwin) 64 65 # Check with '/usr/libexec/java_home' 66 # (see https://developer.apple.com/library/mac/qa/qa1170/_index.html) 67 TMP_PATH := $(shell /usr/libexec/java_home) 68 ifneq ("$(TMP_PATH)","") 69 TMP_RES := $(call verify_jdk,$(TMP_PATH)) 70 ifneq ($(findstring inclib,$(TMP_RES)),) 71 JAVA_HOME := $(TMP_PATH) 72 JAVA_INC := $(call get_java_inc,$(TMP_RES),$(JAVA_HOME)) 73 JAVA_LIB := $(call get_java_lib,$(TMP_RES),$(JAVA_HOME)) 74 endif 75 endif 76 77 ifeq ($(JAVA_HOME),) 78 # Check '/System/Library/Frameworks/JavaVM.framework' 79 FIXED_PATH := /System/Library/Frameworks/JavaVM.framework 80 TMP_RES := $(call verify_jdk,$(FIXED_PATH)) 81 ifneq ($(findstring inclib,$(TMP_RES)),) 82 JAVA_HOME := $(FIXED_PATH) 83 JAVA_INC := $(call get_java_inc,$(TMP_RES),$(JAVA_HOME)) 84 JAVA_LIB := $(call get_java_lib,$(TMP_RES),$(JAVA_HOME)) 85 endif 86 endif 87 88 endif 89 90 ifneq ($(findstring bin,$(TMP_RES)),) 91 JAVA_BIN := $(call get_java_bin,$(TMP_RES),$(JAVA_HOME)) 92 endif 93 94 # $(info TMP_RES = $(TMP_RES)) 95 # $(info JAVA_HOME = $(JAVA_HOME)) 96 # $(info JAVA_INC = $(JAVA_INC)) 97 # $(info JAVA_LIB = $(JAVA_LIB)) 98 # $(info JAVA_BIN = $(JAVA_BIN)) 99 # $(error done) 100 101 ifeq ("$(JAVA_HOME)","") 102 $(error Cannot determine JDK include/library path. \ 103 Please define JAVA_HOME envvar) 104 endif 105 106 ifeq ("$(JAVA_BIN)","") 107 JAVA_BIN := $(JAVA_HOME)/bin 108 $(warning Cannot determine JDK binary path. Set to $(JAVA_BIN)) 109 endif 110 38 111 else 39 ifeq (exists, $(shell test -d $(JAVA_HOME)/bin && echo exists )) 112 113 JAVA_INC := $(JAVA_HOME)/include 114 JAVA_LIB := $(JAVA_HOME)/lib 115 ifeq (exists,$(shell test -d $(JAVA_HOME)/bin && echo exists)) 40 116 JAVA_BIN := $(JAVA_HOME)/bin 41 117 else 42 118 JAVA_BIN := $(JAVA_HOME) 43 119 endif 120 44 121 endif 122 123 # Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe) 124 MY_SWIG := swig 125 MY_JAVA := $(JAVA_BIN)/java 126 MY_JAVAC := $(JAVA_BIN)/javac 127 MY_JNI_CFLAGS := -I$(JAVA_INC) -I$(JAVA_INC)/win32 \ 128 -I$(JAVA_INC)/linux -I$(JAVA_INC)/darwin -I. 129 MY_JNI_LDFLAGS := -L$(JAVA_LIB) 45 130 46 131 # OS specific 47 132 ifeq ($(OS),Windows_NT) 48 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib-Wl,--kill-at133 MY_JNI_LDFLAGS += -Wl,--kill-at 49 134 else 50 MY_JNI_CFLAGS = -fPIC 51 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib 135 MY_JNI_CFLAGS += -fPIC 52 136 ifeq ($(OS),android) 53 MY_JNI_CFLAGS := $(MY_JNI_CFLAGS)-D__ANDROID__137 MY_JNI_CFLAGS+= -D__ANDROID__ 54 138 endif 55 139 endif 56 140 57 # Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe)58 MY_ SWIG = swig59 MY_ JDK = $(JAVA_HOME)60 ifneq ($(findstring bin,$(JAVA_BIN)),) 61 MY_JAVA = $(MY_JDK)/bin/java 62 MY_ JAVAC = $(MY_JDK)/bin/javac141 # Build settings 142 MY_CFLAGS := $(PJ_CXXFLAGS) $(MY_JNI_CFLAGS) $(CFLAGS) 143 MY_LDFLAGS := $(PJ_LDXXFLAGS) $(PJ_LDXXLIBS) $(MY_JNI_LDFLAGS) $(LDFLAGS) 144 MY_PACKAGE_NAME := org.pjsip.pjsua2 145 ifeq ($(OS),android) 146 MY_PACKAGE_PATH := android/src/$(subst .,/,$(MY_PACKAGE_NAME)) 63 147 else 64 MY_JAVA = $(MY_JDK)/java 65 MY_JAVAC = $(MY_JDK)/javac 66 endif 67 MY_JNI_CFLAGS := $(MY_JNI_CFLAGS) -I$(MY_JDK)/include -I$(MY_JDK)/include/win32 \ 68 -I$(MY_JDK)/include/linux -I$(MY_JDK)/include/darwin -I. 69 70 # Build settings 71 MY_CFLAGS = $(PJ_CXXFLAGS) $(MY_JNI_CFLAGS) $(CFLAGS) 72 MY_LDFLAGS = $(PJ_LDXXFLAGS) $(PJ_LDXXLIBS) $(MY_JNI_LDFLAGS) $(LDFLAGS) 73 MY_PACKAGE_NAME = org.pjsip.pjsua2 74 ifeq ($(OS),android) 75 MY_PACKAGE_PATH = android/src/$(subst .,/,$(MY_PACKAGE_NAME)) 76 else 77 MY_PACKAGE_PATH = $(OUT_DIR)/$(subst .,/,$(MY_PACKAGE_NAME)) 148 MY_PACKAGE_PATH := $(OUT_DIR)/$(subst .,/,$(MY_PACKAGE_NAME)) 78 149 endif 79 150 80 MY_APP_JAVA = android/src/$(subst .,/,$(MY_PACKAGE_NAME))/app/MyApp.java151 MY_APP_JAVA := android/src/$(subst .,/,$(MY_PACKAGE_NAME))/app/MyApp.java 81 152 82 153 .PHONY: all java install uninstall … … 85 156 86 157 $(LIBPJSUA2_SO): $(OUT_DIR)/pjsua2_wrap.o 87 $(PJ_CXX) -shared -o $(LIBPJSUA2_SO) $(OUT_DIR)/pjsua2_wrap.o $(MY_CFLAGS) $(MY_LDFLAGS) 158 $(PJ_CXX) -shared -o $(LIBPJSUA2_SO) $(OUT_DIR)/pjsua2_wrap.o \ 159 $(MY_CFLAGS) $(MY_LDFLAGS) 88 160 89 161 $(OUT_DIR)/pjsua2_wrap.o: $(OUT_DIR)/pjsua2_wrap.cpp Makefile 90 $(PJ_CXX) -c $(OUT_DIR)/pjsua2_wrap.cpp -o $(OUT_DIR)/pjsua2_wrap.o $(MY_CFLAGS) $(MY_LDFLAGS) 162 $(PJ_CXX) -c $(OUT_DIR)/pjsua2_wrap.cpp -o $(OUT_DIR)/pjsua2_wrap.o \ 163 $(MY_CFLAGS) 91 164 92 165 $(OUT_DIR)/pjsua2_wrap.cpp: ../pjsua2.i ../symbols.i $(SRCS) 93 166 mkdir -p $(MY_PACKAGE_PATH) 94 swig $(SWIG_FLAGS) -java -package $(MY_PACKAGE_NAME) -outdir $(MY_PACKAGE_PATH) -o $(OUT_DIR)/pjsua2_wrap.cpp ../pjsua2.i 167 swig $(SWIG_FLAGS) -java -package $(MY_PACKAGE_NAME) \ 168 -outdir $(MY_PACKAGE_PATH) \ 169 -o $(OUT_DIR)/pjsua2_wrap.cpp ../pjsua2.i 95 170 96 171 clean distclean realclean: 97 rm -rf $(LIBPJSUA2_SO) $(OUT_DIR)/* $(MY_PACKAGE_PATH)/*.java $(MY_PACKAGE_PATH)/*.class 172 rm -rf $(LIBPJSUA2_SO) $(OUT_DIR)/* \ 173 $(MY_PACKAGE_PATH)/*.java $(MY_PACKAGE_PATH)/*.class 98 174 99 175 java: $(MY_PACKAGE_PATH)/Error.class $(MY_PACKAGE_PATH)/test.class $(MY_PACKAGE_PATH)/sample.class … … 109 185 110 186 test: 111 @# Need to specify classpath and library path, alternatively, they can be set via112 @# CLASSPATH and java.library.path env settings187 @# Need to specify classpath and library path, alternatively, 188 @# they can be set via CLASSPATH and java.library.path env settings 113 189 $(MY_JAVA) -cp "$(OUT_DIR)" -Djava.library.path="$(OUT_DIR)" test 114 190 115 191 sample: 116 @# Need to specify classpath and library path, alternatively, they can be set via 117 @# CLASSPATH and java.library.path env settings 118 $(MY_JAVA) -cp "$(OUT_DIR)" -Djava.library.path="$(OUT_DIR)" org.pjsip.pjsua2.app.sample 192 @# Need to specify classpath and library path, alternatively, 193 @# they can be set via CLASSPATH and java.library.path env settings 194 $(MY_JAVA) -cp "$(OUT_DIR)" -Djava.library.path="$(OUT_DIR)" \ 195 org.pjsip.pjsua2.app.sample 119 196 120 197 install:
Note: See TracChangeset
for help on using the changeset viewer.