Browse Source

added build option: USE_JAVAH - explicitly enable/disable use of javah over javac -h (if autodetect doesnt work correctly)

remotes/origin/master
heck 9 months ago
parent
commit
6d43f1745f
3 changed files with 17 additions and 9 deletions
  1. +14
    -8
      Makefile.conf
  2. +1
    -0
      local.conf.example
  3. +2
    -1
      src/Makefile

+ 14
- 8
Makefile.conf View File

@ -5,10 +5,12 @@
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
PLATFORM:=$(shell uname | tr A-Z a-z)
JAVAC_CMD=javac -encoding UTF-8
JAVAH_CMD=javah -encoding UTF-8
# DEV ENV PATHS & CFG
# The dev environment paths and configs are set to a default value which can be overridden by ./local.conf and overridden again by <subdir>/local.conf
######### Build Config Defaults #########
# The build settings are set to a default value which can be overridden by using ./local.conf
######### DEFAULTS #########
DEBUG=0
PREFIX=$(HOME)
YML2_PATH=$(PREFIX)/src/yml2
@ -19,14 +21,13 @@ ENGINE_INC_PATH=$(PREFIX)/include
AD_LIB_PATH=$(PREFIX)/lib
AD_INC_PATH=$(PREFIX)/include
### Guessing JAVA_HOME
ifeq ($(PLATFORM),linux)
JAVA_HOME=$(subst /bin,,$(dir $(realpath /usr/bin/javac)))
endif
JAVAC_CMD=javac -encoding UTF-8
JAVAH_CMD=javah -encoding UTF-8
######### Overrides from the config file(s) #########
ifneq ("$(wildcard $(HERE)local.conf)","")
@ -46,10 +47,15 @@ ifndef JAVA_HOME
$(error JAVA_HOME is not set!)
endif
# Old versions of a Java distribution have a `javah` binary, new versions do not. This checks whether or not `javah` can be found in the Java distribution found in the directory `$JAVA_HOME`.
DUMMY:=$(shell which $(JAVA_HOME)/bin/javah)
ifeq ($(.SHELLSTATUS),0)
OLD_JAVA=true
# Guessing USE_JAVAH
# cant be guessed earlier, because we depend on JAVA_HOME which can be set in the local.conf
# Old versions of a Java distribution have a `javah` binary, new version do not and the replacement is "javac -h"
# TODO: dont check for presence of javah, but check if javac -h is supported, because some java (RHEL) has javah but supports javac -h
ifndef USE_JAVAH
DUMMY:=$(shell which $(JAVA_HOME)/bin/javah)
ifeq ($(.SHELLSTATUS),0)
USE_JAVAH=1
endif
endif
JAVA_BIN_DIR=$(JAVA_HOME)/bin


+ 1
- 0
local.conf.example View File

@ -14,6 +14,7 @@
############ JAVA ##############
# JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
# USE_JAVAH=0 # keep the build from using javah
############ YML2 ##############
# YML2_PATH=$(HOME)/src/yml2


+ 2
- 1
src/Makefile View File

@ -33,6 +33,7 @@ $(info PLATFORM: $(PLATFORM))
$(info DEBUG: $(DEBUG))
$(info CXX: $(CXX))
$(info JAVA_HOME: $(JAVA_HOME))
$(info USE_JAVAH: $(USE_JAVAH))
$(info ENGINE_LIB_PATH: $(ENGINE_LIB_PATH))
$(info ENGINE_INC_PATH: $(ENGINE_INC_PATH))
$(info AD_LIB_PATH: $(AD_LIB_PATH))
@ -145,7 +146,7 @@ gen-jni-headers: codegen $(JNI_GENERATED_HH)
# "new" javac -h accepts list of java files
# While "old" (Java 8) javah needs a list of java classes (e.g. foundation.pEp.jniadapter.Message)
$(JNI_GENERATED_HH):
ifdef OLD_JAVA
ifeq ($(USE_JAVAH),1)
cd $(JAVA_BUILD_ROOT)/;$(JAVA_BIN_DIR)/$(JAVAH_CMD) -d ../../src/$(CXX_DIR) $(subst ${ },${space}\${\n}, $(subst /,.,$(subst $(JAVA_BUILD_ROOT),,$(basename $(sort $(wildcard $(JAVA_BUILD_ROOT)$(JAVA_PKG_BASENAME)*.class/))))))
else
cd $(JAVA_DIR);$(JAVA_BIN_DIR)/$(JAVAC_CMD) -d ../$(JAVA_BUILD_ROOT) -h ../$(CXX_DIR)/ $(JAVA_PKG_BASENAME)/*.java


Loading…
Cancel
Save