From: Michael Zucchi Date: Fri, 2 Aug 2019 05:20:46 +0000 (+0930) Subject: Tweaks to java.make. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=99e7b844db8621946d54b999c77a33969b938a55;p=zcl Tweaks to java.make. --- diff --git a/config.make b/config.make index efc723d..b9b97cf 100644 --- a/config.make +++ b/config.make @@ -2,13 +2,11 @@ TARGET ?= linux-amd64 JAVA_HOME ?= /usr/local/jdk-11.0.2 -JAVAFX_HOME ?= /usr/local/javafx-sdk-11.0.2 -FFMPEG_HOME ?= /opt/ffmpeg/4.0 # See also JAVACFLAGS --module-path -NATIVEZ_HOME=../nativez/bin/notzed.nativez/$(TARGET) +NATIVEZ_HOME=../nativez/bin/$(TARGET) -JAVACFLAGS += --module-path ../nativez/bin/notzed.nativez +JAVAMODPATH = $(NATIVEZ_HOME)/lib JAVACFLAGS += -source 11 JAVAC ?= javac diff --git a/java.make b/java.make index 7228203..657910d 100644 --- a/java.make +++ b/java.make @@ -49,8 +49,8 @@ # _JARFLAGS # _JMODFLAGS -# _JAVA Java sources. If not set it is found from src//classes/(*.java) -# _RESOURCES .jar resources. If not set it is found from src//classes/(not *.java) +# _JAVA Java sources. If not set it is found from src//classes/(*.java) +# _RESOURCES .jar resources. If not set it is found from src//classes/(not *.java) # _JAVA_GENERATED Java generated sources. These must be relative to the package name. # Variables for use in fragments @@ -127,17 +127,20 @@ # bin/gen//gen/ .c, exe files for generator free use # bin/gen//classes/ .java files from generator _JAVA_GENERATED +# Working files # bin/status/ marker files for makefile -# bin//.jar .jar modular - -# Native code - # bin///lib .so librareies for jmod _LIBRARIES = libname # bin///obj .o, .d files for library _SOURCES # bin///include .h files for jmod _HEADERS # bin///.jmod .jmod module +# Output files +# bin//lib/ modular jar files and shared libraries for GNU/linux dev +# bin//include/ header files for exported shared libraries +# bin//bin/ shared libraries for microsoft dev +# bin//jmods/ jmod files for 'jlink' use. + # ###################################################################### E:= @@ -167,6 +170,12 @@ $(1)_RESOURCES := $$(shell find src/$(1)/classes -type f \! -name '*.java') endif endef +java_libdir:=$(if $(filter windows-%,$(TARGET)),bin/$(TARGET)/bin,bin/$(TARGET)/lib) +java_bindir:=bin/$(TARGET)/bin +java_jardir:=bin/$(TARGET)/lib +java_incdir:=bin/$(TARGET)/include +java_jmoddir:=bin/$(TARGET)/jmods + $(foreach module,$(java_MODULES),$(eval $(call java_variables,$(module)))) # ###################################################################### @@ -192,20 +201,20 @@ $(1)_JAVA_generated = $$(addprefix $$($(1)_genjavadir)/,$$($(1)_JAVA_GENERATED)) bin/status/$(1).data: $$($(1)_RESOURCES) bin/status/$(1).classes: $(patsubst %,bin/status/%.classes,$($(1)_JDEPMOD)) $$($(1)_JAVA) $$($(1)_JAVA_generated) -jar $(1): bin/$(1)/$(1).jar $(if $(wildcard src/$(1)/jni/jni.make),bin/$(1)/$(TARGET)/$(1).jmod) +jar $(1): $(java_jardir)/$(1).jar $(java_jmoddir)/$(1).jmod bin: bin/status/$(1).classes bin/status/$(1).data -sources: bin/$(1)/$(1)-sources.zip +sources: $(java_jardir)/$(1)-sources.zip gen: $$($(1)_JAVA_generated) # Create modular jar -bin/$(1)/$(1).jar: bin/status/$(1).classes bin/status/$(1).data +$(java_jardir)/$(1).jar: bin/status/$(1).classes bin/status/$(1).data @install -d $$(@D) $(JAR) cf $$@ \ $(JARFLAGS) $$($(1)_JARFLAGS) \ -C bin/modules/$(1) . # Create a jmod -bin/$(1)/$(TARGET)/$(1).jmod: bin/status/$(1).classes bin/status/$(1).data +$(java_jmoddir)/$(1).jmod: bin/status/$(1).classes bin/status/$(1).data rm -f $$@ @install -d $$(@D) $$(JMOD) create \ @@ -214,12 +223,12 @@ bin/$(1)/$(TARGET)/$(1).jmod: bin/status/$(1).classes bin/status/$(1).data --class-path bin/modules/$(1) \ $$(if $$(wildcard bin/$(1)/$(TARGET)/include),--header-files bin/$(1)/$(TARGET)/include) \ $$(if $$(wildcard src/$(1)/legal),--legal-notices src/$(1)/legal) \ - $$(if $$(wildcard $$($(1)_bindir)),--cmds $$($(1)_bindir)) \ - $$(if $$(wildcard $$($(1)_libdir)),--libs $$($(1)_libdir)) \ + $$(if $$(wildcard bin/$(1)/$(TARGET)/bin),--cmds bin/$(1)/$(TARGET)/bin) \ + $$(if $$(wildcard bin/$(1)/$(TARGET)/lib),--libs bin/$(1)/$(TARGET)/lib) \ $$@ # Create an IDE source zip, paths have to match --module-source-path -bin/$(1)/$(1)-sources.zip: bin/status/$(1).classes +$(java_jardir)/$(1)-sources.zip: bin/status/$(1).classes @install -d $$(@D) jar -c -f $$@ -M \ $$(patsubst src/$(1)/classes/%,-C src/$(1)/classes %,$$(filter src/$(1)/classes/%,$$($(1)_JAVA))) \ @@ -246,6 +255,7 @@ bin/status/%.classes: @install -d $(@D) $(JAVAC) \ --module-source-path "src/*/classes:bin/gen/*/classes" \ + $(if $(JAVAMODPATH),--module-path $(subst $(S),:,$(JAVAMODPATH))) \ $(JAVACFLAGS) $($*_JAVACFLAGS) \ -h bin/inc \ -d bin/modules \ @@ -265,26 +275,35 @@ SO=$($(TARGET)_SO) LIB=$($(TARGET)_LIB) # functions to find cross-module stuff $(call library-path,modname,libname) -library-path=bin/$(1)/$(TARGET)/lib/$(LIB)$(2)$(SO) -library-dir=bin/$(1)/$(TARGET)/lib/ +library-path=$($(1)_libdir)/$(LIB)$(2)$(SO) +library-dir=$($(1)_libdir)/ define jni_library= # Rule for library $(2) in module $(1) $(2)_OBJS = $(foreach sx,$(SUFFIXES),$(patsubst %$(sx), $($(1)_objdir)/%.o, $(filter %$(sx),$($(2)_SOURCES)))) $(2)_SRCS = $(addprefix src/$(1)/jni/,$($(2)_SOURCES)) +$(2)_SO = $($(1)_libdir)/$(LIB)$(2)$(SO) $($(1)_libdir)/$(LIB)$(2)$(SO): $$($(2)_OBJS) $($(2)_LIBADD) $($(2)_DEPENDENCIES) @install -d $$(@D) $($(TARGET)_CC) -o $$@ -shared \ $($(TARGET)_LDFLAGS) $($(2)_LDFLAGS) $$($(2)_OBJS) $($(2)_LIBADD) $($(TARGET)_LDLIBS) $($(2)_LDLIBS) +$(java_libdir)/%: $($(1)_libdir)/% + install -DC $$< $$@ +$(java_bindir)/%: $($(1)_bindir)/% + install -DC $$< $$@ +$(java_incdir)/%: $($(1)_incdir)/% + install -DC $$< $$@ + $($(1)_objdir)/%.o: src/$(1)/jni/%.c bin/status/$(1).classes @install -d $$(@D) - $($(TARGET)_CC) -Isrc/$(1)/jni -Ibin/include/$(1) $($(TARGET)_CPPFLAGS) $($(2)_CPPFLAGS) \ + $($(TARGET)_CC) -Isrc/$(1)/jni -Ibin/include/$(1) -I$($(1)_jnidir) \ + $($(TARGET)_CPPFLAGS) $($(2)_CPPFLAGS) \ $($(TARGET)_CFLAGS) $($(2)_CFLAGS) -c -o $$@ $$< $($(1)_incdir)/%.h: src/$(1)/jni/%.h - install -D $$< $$@ + install -DC $$< $$@ $($(1)_objdir)/%.d: src/$(1)/jni/%.c bin/status/$(1).classes @install -d $$(@D) @@ -293,9 +312,14 @@ $($(1)_objdir)/%.d: src/$(1)/jni/%.c bin/status/$(1).classes $($(TARGET)_CPPFLAGS) $($(2)_CPPFLAGS) $$< -o $$@.d 2>/dev/null @sed 's,\($$*\.o\) *:,\1 $$@ : ,g' $$@.d > $$@ ; rm $$@.d -bin jni $(1) bin/$(1)/$(TARGET)/$(1).jmod: $($(1)_libdir)/$(LIB)$(2)$(SO) \ +bin jni $(1) $(java_jmoddir)/$(1).jmod: \ + $($(1)_libdir)/$(LIB)$(2)$(SO) \ + $(java_libdir)/$(LIB)$(2)$(SO) \ $(addprefix $($(1)_incdir)/,$($(2)_HEADERS)) \ - $(addprefix $($(1)_bindir)/,$($(2)_COMMANDS)) + $(addprefix $(java_incdir)/,$($(2)_HEADERS)) \ + $(addprefix $($(1)_bindir)/,$($(2)_COMMANDS)) \ + $(addprefix $(java_bindir)/,$($(2)_COMMANDS)) \ + $$(addprefix $($(1)_libdir)/,$$($(2)_LIBRARIES)) $(if $(filter clean dist gen,$(MAKECMDGOALS)),,-include $$($(2)_OBJS:.o=.d)) endef