57 # JVM:=The jvm used to run the javac/javah command |
57 # JVM:=The jvm used to run the javac/javah command |
58 # JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out |
58 # JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out |
59 # FLAGS:=Flags to be supplied to javac |
59 # FLAGS:=Flags to be supplied to javac |
60 # SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here |
60 # SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here |
61 # SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above. |
61 # SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above. |
62 define SetupJavaCompiler |
62 SetupJavaCompiler = $(NamedParamsMacroTemplate) |
63 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk)) |
63 define SetupJavaCompilerBody |
64 $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilerInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) |
|
65 endef |
|
66 |
|
67 define SetupJavaCompilerInner |
|
68 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE)) |
|
69 $(call LogSetupMacroEntry,SetupJavaCompiler($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
|
70 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk)) |
|
71 |
|
72 # The port file contains the tcp/ip on which the server listens |
64 # The port file contains the tcp/ip on which the server listens |
73 # and the cookie necessary to talk to the server. |
65 # and the cookie necessary to talk to the server. |
74 $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port |
66 $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port |
75 # You can use a different JVM to run the background javac server. |
67 # You can use a different JVM to run the background javac server. |
76 ifeq ($$($1_SERVER_JVM),) |
68 ifeq ($$($1_SERVER_JVM),) |
82 # Setup make rules for creating a jar archive. |
74 # Setup make rules for creating a jar archive. |
83 # |
75 # |
84 # Parameter 1 is the name of the rule. This name is used as variable prefix, |
76 # Parameter 1 is the name of the rule. This name is used as variable prefix, |
85 # and the targets generated are listed in a variable by that name. |
77 # and the targets generated are listed in a variable by that name. |
86 # |
78 # |
87 # Parameter 2 is a list of dependencies for the jar target. If left empty, |
|
88 # dependencies are searched using SRCS, which should not be empty. |
|
89 # |
|
90 # Remaining parameters are named arguments. These include: |
79 # Remaining parameters are named arguments. These include: |
|
80 # DEPENDENCIES:=List of dependencies for the jar target. If left empty, |
|
81 # dependencies are calculated automatically from the source files found. |
|
82 # For this to work, the source files must exist when the makefile is |
|
83 # parsed. |
91 # SRCS:=List of directories in where to find files to add to archive |
84 # SRCS:=List of directories in where to find files to add to archive |
92 # SUFFIXES:=File suffixes to include in jar |
85 # SUFFIXES:=File suffixes to include in jar |
93 # INCLUDES:=List of directories/packages in SRCS that should be included |
86 # INCLUDES:=List of directories/packages in SRCS that should be included |
94 # EXCLUDES:=List of directories/packages in SRCS that should be excluded |
87 # EXCLUDES:=List of directories/packages in SRCS that should be excluded |
95 # EXCLUDE_FILES:=List of files in SRCS that should be excluded |
88 # EXCLUDE_FILES:=List of files in SRCS that should be excluded |
100 # JARINDEX:=true means generate the index in the jar file. |
93 # JARINDEX:=true means generate the index in the jar file. |
101 # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically |
94 # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically |
102 # added to the archive. |
95 # added to the archive. |
103 # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. |
96 # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. |
104 # CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable |
97 # CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable |
105 define SetupArchive |
98 SetupArchive = $(NamedParamsMacroTemplate) |
106 $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) |
99 define SetupArchiveBody |
107 $(call EvalDebugWrapper,$(strip $1),$(call SetupArchiveInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) |
|
108 endef |
|
109 |
|
110 define SetupArchiveInner |
|
111 # NOTE: $2 is dependencies, not a named argument! |
|
112 $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE)) |
|
113 $(call LogSetupMacroEntry,SetupArchive($1),<dependencies>,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
|
114 $(if $(findstring $(LOG_LEVEL),trace), $(info *[2] <dependencies> = $(strip $2))) |
|
115 $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) |
|
116 |
100 |
117 $1_JARMAIN:=$(strip $$($1_JARMAIN)) |
101 $1_JARMAIN:=$(strip $$($1_JARMAIN)) |
118 $1_JARNAME:=$$(notdir $$($1_JAR)) |
102 $1_JARNAME:=$$(notdir $$($1_JAR)) |
119 $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest |
103 $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest |
120 $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess |
104 $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess |
169 $1_JARINDEX = true |
153 $1_JARINDEX = true |
170 endif |
154 endif |
171 # When this macro is run in the same makefile as the java compilation, dependencies are |
155 # When this macro is run in the same makefile as the java compilation, dependencies are |
172 # transfered in make variables. When the macro is run in a different makefile than the |
156 # transfered in make variables. When the macro is run in a different makefile than the |
173 # java compilation, the dependencies need to be found in the filesystem. |
157 # java compilation, the dependencies need to be found in the filesystem. |
174 ifneq (,$2) |
158 ifeq ($$($1_DEPENDENCIES), ) |
175 $1_DEPS:=$2 |
|
176 else |
|
177 # Add all source roots to the find cache since we are likely going to run find |
159 # Add all source roots to the find cache since we are likely going to run find |
178 # on these more than once. The cache will only be updated if necessary. |
160 # on these more than once. The cache will only be updated if necessary. |
179 $$(eval $$(call FillCacheFind, $$($1_FIND_LIST))) |
161 $$(eval $$(call FillCacheFind, $$($1_FIND_LIST))) |
180 $1_DEPS:=$$(filter $$(addprefix %,$$($1_SUFFIXES)), \ |
162 $1_DEPENDENCIES:=$$(filter $$(addprefix %,$$($1_SUFFIXES)), \ |
181 $$(call CacheFind,$$($1_SRCS))) |
163 $$(call CacheFind,$$($1_SRCS))) |
182 ifneq (,$$($1_GREP_INCLUDE_PATTERNS)) |
164 ifneq (,$$($1_GREP_INCLUDE_PATTERNS)) |
183 $1_DEPS:=$$(filter $$(addsuffix %,$$($1_GREP_INCLUDE_PATTERNS)),$$($1_DEPS)) |
165 $1_DEPENDENCIES:=$$(filter $$(addsuffix %,$$($1_GREP_INCLUDE_PATTERNS)),$$($1_DEPENDENCIES)) |
184 endif |
166 endif |
185 ifneq (,$$($1_GREP_EXCLUDE_PATTERNS)) |
167 ifneq (,$$($1_GREP_EXCLUDE_PATTERNS)) |
186 $1_DEPS:=$$(filter-out $$(addsuffix %,$$($1_GREP_EXCLUDE_PATTERNS)),$$($1_DEPS)) |
168 $1_DEPENDENCIES:=$$(filter-out $$(addsuffix %,$$($1_GREP_EXCLUDE_PATTERNS)),$$($1_DEPENDENCIES)) |
187 endif |
169 endif |
188 # Look for EXTRA_FILES in all SRCS dirs and as absolute paths. |
170 # Look for EXTRA_FILES in all SRCS dirs and as absolute paths. |
189 $1_DEPS+=$$(wildcard $$(foreach src, $$($1_SRCS), \ |
171 $1_DEPENDENCIES+=$$(wildcard $$(foreach src, $$($1_SRCS), \ |
190 $$(addprefix $$(src)/, $$($1_EXTRA_FILES))) $$($1_EXTRA_FILES)) |
172 $$(addprefix $$(src)/, $$($1_EXTRA_FILES))) $$($1_EXTRA_FILES)) |
191 ifeq (,$$($1_SKIP_METAINF)) |
173 ifeq (,$$($1_SKIP_METAINF)) |
192 $1_DEPS+=$$(call CacheFind,$$(wildcard $$(addsuffix /META-INF,$$($1_SRCS)))) |
174 $1_DEPENDENCIES+=$$(call CacheFind,$$(wildcard $$(addsuffix /META-INF,$$($1_SRCS)))) |
193 endif |
175 endif |
194 endif |
176 endif |
195 # The dependency list should never be empty |
177 # The dependency list should never be empty |
196 ifeq ($$(strip $$($1_DEPS)), ) |
178 ifeq ($$(strip $$($1_DEPENDENCIES)), ) |
197 $$(warning No dependencies found for $1) |
179 $$(warning No dependencies found for $1) |
198 endif |
180 endif |
199 |
181 |
200 # Utility macros, to make the shell script receipt somewhat easier to decipher. |
182 # Utility macros, to make the shell script receipt somewhat easier to decipher. |
201 |
183 |
286 $1_VARDEPS := $(JAR) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) $(RELEASE) $(COMPANY_NAME) \ |
268 $1_VARDEPS := $(JAR) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) $(RELEASE) $(COMPANY_NAME) \ |
287 $$($1_JARMAIN) $$($1_EXTRA_MANIFEST_ATTR) |
269 $$($1_JARMAIN) $$($1_EXTRA_MANIFEST_ATTR) |
288 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$(dir $$($1_JAR))_the.$$($1_JARNAME).vardeps) |
270 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$(dir $$($1_JAR))_the.$$($1_JARNAME).vardeps) |
289 |
271 |
290 # Here is the rule that creates/updates the jar file. |
272 # Here is the rule that creates/updates the jar file. |
291 $$($1_JAR) : $$($1_DEPS) $$($1_MANIFEST) $$($1_VARDEPS_FILE) |
273 $$($1_JAR) : $$($1_DEPENDENCIES) $$($1_MANIFEST) $$($1_VARDEPS_FILE) |
292 $(MKDIR) -p $$($1_BIN) |
274 $(MKDIR) -p $$($1_BIN) |
293 $$($1_GREP_INCLUDE_OUTPUT) |
275 $$($1_GREP_INCLUDE_OUTPUT) |
294 $$($1_GREP_EXCLUDE_OUTPUT) |
276 $$($1_GREP_EXCLUDE_OUTPUT) |
295 # If the vardeps file is part of the newer prereq list, it means that |
277 # If the vardeps file is part of the newer prereq list, it means that |
296 # either the jar file does not exist, or we need to recreate it from |
278 # either the jar file does not exist, or we need to recreate it from |
427 # EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file! |
409 # EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file! |
428 # "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found. |
410 # "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found. |
429 # HEADERS:=path to directory where all generated c-headers are written. |
411 # HEADERS:=path to directory where all generated c-headers are written. |
430 # DEPENDS:=Extra dependecy |
412 # DEPENDS:=Extra dependecy |
431 # DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit. |
413 # DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit. |
432 define SetupJavaCompilation |
414 SetupJavaCompilation = $(NamedParamsMacroTemplate) |
433 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) |
415 define SetupJavaCompilationBody |
434 $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilationInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) |
|
435 endef |
|
436 |
|
437 define SetupJavaCompilationInner |
|
438 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE)) |
|
439 $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) |
|
440 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) |
|
441 |
416 |
442 # Verify arguments |
417 # Verify arguments |
443 ifeq ($$($1_BIN),) |
418 ifeq ($$($1_BIN),) |
444 $$(error Must specify BIN (in $1)) |
419 $$(error Must specify BIN (in $1)) |
445 endif |
420 endif |
651 # for the types of files to be put into the jar. |
626 # for the types of files to be put into the jar. |
652 ifeq (,$$($1_SUFFIXES)) |
627 ifeq (,$$($1_SUFFIXES)) |
653 $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY) |
628 $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY) |
654 endif |
629 endif |
655 |
630 |
656 $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1), \ |
631 $$(eval $$(call SetupArchive,ARCHIVE_$1, \ |
|
632 DEPENDENCIES:=$$($1), \ |
657 SRCS:=$$($1_BIN), \ |
633 SRCS:=$$($1_BIN), \ |
658 SUFFIXES:=$$($1_SUFFIXES), \ |
634 SUFFIXES:=$$($1_SUFFIXES), \ |
659 EXCLUDE:=$$($1_EXCLUDES), \ |
635 EXCLUDE:=$$($1_EXCLUDES), \ |
660 INCLUDES:=$$($1_INCLUDES), \ |
636 INCLUDES:=$$($1_INCLUDES), \ |
661 EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS), \ |
637 EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS), \ |