[PATCH] to common/make/JavaCompilation.gmk Use $(TOOL) macros defined by configure and spec.gmk
Tim Bell
tim.bell at gmail.com
Mon Nov 28 08:05:41 PST 2011
Hi All
These changes in 'common/make/JavaCompilation.gmk' were started
because I needed to use the $(AWK) provided by configure. The
legacy awk found by default on Solaris was not doing the right thing,
instead throwing out errors like this:
awk: string too long near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
Once I converted awk to $(AWK), I did the same for sed, find, and so
forth in this file, ending up with minor changes to quite a few lines.
Fredrik, as build-infra committer, could you sponsor this?
I put a webrev here, if that is an easier way to get the changes:
http://cr.openjdk.java.net/~tbell/build-infra/webrev.00
Thanks-
Tim Bell
hg export -g 432:53b96caba8cb
# HG changeset patch
# User tbell
# Date 1322495967 28800
# Node ID 53b96caba8cb337f8ba075549bb01f7e0776a7cd
# Parent c8572af8c1d0cbee093f8695b8964dbd7823a1a2
Use $(TOOL) macros defined by configure and spec.gmk
Contributed-by: Tim Bell <tim.bell at gmail.com>
diff --git a/common/make/JavaCompilation.gmk b/common/make/JavaCompilation.gmk
--- a/common/make/JavaCompilation.gmk
+++ b/common/make/JavaCompilation.gmk
@@ -153,46 +153,46 @@
# The capture contents macro finds all files (matching the
patterns, typically
# *.class and *.prp) that are newer than the jar-file, ie the new
content to be put into the jar.
- $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),($(FIND) $$(src)
-type f -a \( $$($1_PATTERNS) \) -a -newer $$@ | sed 's|$$(src)/||g' >
$$(src)/_the.$$($1_JARNAME)_contents) && )
+ $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),($(FIND) $$(src)
-type f -a \( $$($1_PATTERNS) \) -a -newer $$@ | $(SED)
's|$$(src)/||g' > $$(src)/_the.$$($1_JARNAME)_contents) && )
# The capture metainf macro finds all files below the META-INF
directory that are newer than the jar-file.
ifeq (,$$($1_SKIP_METAINF))
- $1_CAPTURE_METAINF =$$(foreach src,$$($1_SRCS),($(FIND)
$$(src)/META-INF -type f -a -newer $$@ 2> /dev/null | sed
's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents ) && )
+ $1_CAPTURE_METAINF =$$(foreach src,$$($1_SRCS),($(FIND)
$$(src)/META-INF -type f -a -newer $$@ 2> /dev/null | $(SED)
's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents ) && )
endif
# The capture deletes macro finds all deleted files and
concatenates them. The resulting file
# tells us what to remove from the jar-file.
- $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src)
-name _the.package.deleted -newer $$@ -exec sed 's|$$(src)||g' \{\} >>
$$($1_DELETES_FILE) \;) &&)
+ $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src)
-name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\}
>> $$($1_DELETES_FILE) \;) &&)
# The capture pubapi notifications scans for pubapi change
notifications. If such notifications are
# found, then we will build the classes leading up to the jar
again, to take into account the new timestamps
# on the changed pubapi files.
$1_CAPTURE_PUBAPI_NOTIFICATIONS=$$(foreach src,$$($1_SRCS),\
- (cd $$(src) && \
+ ($(CD) $$(src) && \
$(FIND) . -name _the.package.api.notify -exec
dirname \{\} \; >> $$($1_PUBAPI_NOTIFICATIONS_FILE) ; \
true) &&)
# The capture nativeapi macro scans for native api change
notificiations. If such notifications are
# found, then we will run javah on the changed classes. It also
collects all classes with native methods
# to be used to find out which classes no longer has native
methods, to trigger deletion of those .h files.
$1_CAPTURE_NATIVEAPI=$$(foreach src,$$($1_SRCS),\
- (cd $$(src) && \
- $(FIND) . -name _the.package.native.notify | sed
's/package.native.notify/package.native/' | \
- xargs cat | grep '^TYPE ' | sed
's/.*TYPE //' >> $$($1_NATIVEAPI_NOTIFICATIONS_FILE) ; \
- $(FIND) . -name _the.package.native -exec cat
\{\} \; | $(SED) -n 's/^TYPE //p' >> $$($1_NATIVEAPI_FILE) ; \
+ ($(CD) $$(src) && \
+ $(FIND) . -name _the.package.native.notify |
$(SED) 's/package.native.notify/package.native/' | \
+ $(XARGS) $(CAT) | $(GREP) '^TYPE ' |
$(SED) 's/.*TYPE //' >> $$($1_NATIVEAPI_NOTIFICATIONS_FILE) ; \
+ $(FIND) . -name _the.package.native -exec $(CAT)
\{\} \; | $(SED) -n 's/^TYPE //p' >> $$($1_NATIVEAPI_FILE) ; \
true) &&)
# The update contents macro updates the jar file with the
previously capture contents.
$1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
- (cd $$(src) && \
+ ($(CD) $$(src) && \
if [ -s _the.$$($1_JARNAME)_contents ]; then \
- echo " updating" `wc -l
_the.$$($1_JARNAME)_contents | awk '{ print $$$$1 }'` files && \
+ $(ECHO) " updating" `$(WC) -l
_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
$(JAR) uf $$@ @_the.$$($1_JARNAME)_contents; \
fi) &&)
# The s-variants of the above macros are used when the jar is
created from scratch.
$1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\
- ($(FIND) $$(src) -type f -a \( $$($1_PATTERNS) \)
| sed 's|$$(src)/||g' > $$(src)/_the.$$($1_JARNAME)_contents) && )
+ ($(FIND) $$(src) -type f -a \( $$($1_PATTERNS) \)
| $(SED) 's|$$(src)/||g' > $$(src)/_the.$$($1_JARNAME)_contents) && )
ifeq (,$$($1_SKIP_METAINF))
$1_SCAPTURE_METAINF=$$(foreach src,$$($1_SRCS),\
- ($(FIND) $$(src)/META-INF -type f 2> /dev/null |
sed 's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents) && )
+ ($(FIND) $$(src)/META-INF -type f 2> /dev/null |
$(SED) 's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents) && )
endif
$1_SUPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
- (cd $$(src) && $(JAR) uf $$@
@$$(src)/_the.$$($1_JARNAME)_contents) &&)
+ ($(CD) $$(src) && $(JAR) uf $$@
@$$(src)/_the.$$($1_JARNAME)_contents) &&)
# The TOUCH macro is used to make sure all timestamps are
identical for package files and the pubapi files.
# If we do not do this, we get random recompilations, the next
time we run make, since the order of package building is random,
# ie independent of package --dependes on-> public api of another
package. This is of course
@@ -206,56 +206,56 @@
# Here is the rule that creates/updates the jar file.
$$($1_JAR) : $2
$(MKDIR) -p $$($1_BIN)
- echo $$($1_MANIFEST) > $$($1_MANIFEST_FILE)
+ $(ECHO) $$($1_MANIFEST) > $$($1_MANIFEST_FILE)
+if [ -s $$@ ]; then \
- rm -rf $$($1_PUBAPI_NOTIFICATIONS_FILE) && \
+ $(RM) -r $$($1_PUBAPI_NOTIFICATIONS_FILE) && \
$$($1_CAPTURE_PUBAPI_NOTIFICATIONS) \
if [ -s $$($1_PUBAPI_NOTIFICATIONS_FILE) ]; then \
- echo Public api change detected in: && \
- cat $$($1_PUBAPI_NOTIFICATIONS_FILE) | tr '/' '.' | sed 's|^..||g'
| sed 's|\.$$$$||g' | awk '{print " "$$$$1}' && \
+ $(ECHO) Public api change detected in: && \
+ $(CAT) $$($1_PUBAPI_NOTIFICATIONS_FILE) | $(TR) '/' '.' | $(SED)
's|^..||g' | $(SED) 's|\.$$$$||g' | $(AWK) '{print " "$$$$1}' && \
$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name
_the.package.api.notify $(FIND_DELETE); true) &&) \
$(MAKE) -f $(word 1,$(MAKEFILE_LIST)) $$($1_JAR) ; \
else \
- echo Modifying $$($1_NAME) && \
+ $(ECHO) Modifying $$($1_NAME) && \
$$($1_CAPTURE_CONTENTS) \
$$($1_CAPTURE_METAINF) \
- rm -f $$($1_DELETES_FILE) && \
+ $(RM) $$($1_DELETES_FILE) && \
$$($1_CAPTURE_DELETES) \
- cat $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) && \
+ $(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) && \
if [ -s $$($1_DELETESS_FILE) ]; then \
- echo " deleting" `wc -l $$($1_DELETESS_FILE) | awk '{ print
$$$$1 }'` files && \
- $(ZIP) -q -d $$@ `cat $$($1_DELETESS_FILE)` ; \
+ $(ECHO) " deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{
print $$$$1 }'` files && \
+ $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
fi && \
$$($1_UPDATE_CONTENTS) true && \
$$($1_TOUCH_API_FILES) true && \
- rm -rf $$($1_NATIVEAPI_NOTIFICATIONS_FILE) $$($1_NATIVEAPI_FILE) && \
+ $(RM) -r $$($1_NATIVEAPI_NOTIFICATIONS_FILE) $$($1_NATIVEAPI_FILE) && \
$$($1_CAPTURE_NATIVEAPI) true && \
if [ "x$$($1_JAVAH)" != "x" ] && [ -s
$$($1_NATIVEAPI_NOTIFICATIONS_FILE) ]; then \
- echo Native api change detected in: && cat
$$($1_NATIVEAPI_NOTIFICATIONS_FILE) && \
+ $(ECHO) Native api change detected in: && $(CAT)
$$($1_NATIVEAPI_NOTIFICATIONS_FILE) && \
$$($1_JVM) $$($1_JAVAH)
"-Xbootclasspath/p:$$($1_JAR)" -d $$($1_HEADERS)
@$$($1_NATIVEAPI_NOTIFICATIONS_FILE) ; \
fi && \
- touch $$($1_NATIVEAPI_FILE)_prev ; \
+ $(TOUCH) $$($1_NATIVEAPI_FILE)_prev ; \
($(GREP) -xvf $$($1_NATIVEAPI_FILE) $$($1_NATIVEAPI_FILE)_prev >
$$($1_NATIVEAPI_FILE)_deleted; true) && \
- cp $$($1_NATIVEAPI_FILE) $$($1_NATIVEAPI_FILE)_prev && \
+ $(CP) $$($1_NATIVEAPI_FILE) $$($1_NATIVEAPI_FILE)_prev && \
if [ -s $$($1_NATIVEAPI_FILE)_deleted ]; then \
- echo Native methods dropped from classes: && cat
$$($1_NATIVEAPI_FILE)_deleted && \
- $(RM) `cat $$($1_NATIVEAPI_FILE)_deleted | sed -e 's|\.|_|g' -e
's|.*|$$($1_HEADERS)/&.h $$($1_HEADERS)/&_*|'` ; \
+ $(ECHO) Native methods dropped from classes: && $(CAT)
$$($1_NATIVEAPI_FILE)_deleted && \
+ $(RM) `$(CAT) $$($1_NATIVEAPI_FILE)_deleted | $(SED) -e
's|\.|_|g' -e 's|.*|$$($1_HEADERS)/&.h $$($1_HEADERS)/&_*|'` ; \
fi && \
$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name
_the.package.api.notify $(FIND_DELETE); true) &&) true ; \
fi ; \
else \
- echo Creating $$($1_NAME) && $(JAR) cfm $$@ $$($1_MANIFEST_FILE) && \
+ $(ECHO) Creating $$($1_NAME) && $(JAR) cfm $$@ $$($1_MANIFEST_FILE) && \
$$($1_SCAPTURE_CONTENTS) \
$$($1_SCAPTURE_METAINF) \
$$($1_SUPDATE_CONTENTS) \
$$($1_TOUCH_API_FILES) true && \
- rm -rf $$($1_NATIVEAPI_NOTIFICATIONS_FILE) $$($1_NATIVEAPI_FILE) && \
+ $(RM) -r $$($1_NATIVEAPI_NOTIFICATIONS_FILE) $$($1_NATIVEAPI_FILE) && \
$$($1_CAPTURE_NATIVEAPI) true && \
if [ "x$$($1_JAVAH)" != "x" ] && [ -s $$($1_NATIVEAPI_FILE) ]; then \
- echo Generating native api headers for `cat $$($1_NATIVEAPI_FILE)
| wc -l` classes && \
+ $(ECHO) Generating native api headers for `$(CAT)
$$($1_NATIVEAPI_FILE) | $(WC) -l` classes && \
$(RM) $$($1_HEADERS)/*.h && \
$$($1_JVM) $$($1_JAVAH) "-Xbootclasspath/p:$$($1_JAR)" -d
$$($1_HEADERS) @$$($1_NATIVEAPI_FILE) && \
- cp $$($1_NATIVEAPI_FILE) $$($1_NATIVEAPI_FILE)_prev ; \
+ $(CP) $$($1_NATIVEAPI_FILE) $$($1_NATIVEAPI_FILE)_prev ; \
fi && \
$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name "*.notify"
$(FIND_DELETE); true) &&) true ; \
fi;
@@ -263,7 +263,7 @@
endef
define append_to
- echo "$1" >> $2
+ $(ECHO) "$1" >> $2
endef
define SetupZipArchive
@@ -300,9 +300,9 @@
# I.e. the zip -i and -x options should match the filtering done
in the makefile.
$$($1_ZIP) : $$($1_ALL_SRCS)
$(MKDIR) -p $$(@D)
- echo Updating $$($1_NAME)
- $$(foreach i,$$($1_SRC),(cd $$i && $(ZIP) -qru $$@ .
$$($1_ZIP_INCLUDES) $$($1_ZIP_EXCLUDES) -x \*_the.\*) ;) true
- touch $$@
+ $(ECHO) Updating $$($1_NAME)
+ $$(foreach i,$$($1_SRC),($(CD) $$i && $(ZIP) -qru $$@ .
$$($1_ZIP_INCLUDES) $$($1_ZIP_EXCLUDES) -x \*_the.\*) ;) true
+ $(TOUCH) $$@
endef
define add_file_to_copy
@@ -407,12 +407,12 @@
# The next command rewrites the deps output from javac into a
proper makefile dependency.
# The dependencies are always to an .api file generated by the
pubapi option above.
# This is necessary since java package dependencies are almost
always circular.
- $2_APPEND_DEPS:=(cat $$($2_PACKAGE_BDIR)_the.package.deps | tr
'.' '/' | awk '{ print "$4/" $$$$3 }' | sort >
$$($2_PACKAGE_BDIR)_the.package.ddd && $(GREP) -f
$$($2_PACKAGE_BDIR)_the.package.ddd $5 | awk '{ print "$(dir
$2)_the.package : " $$$$1 "_the.package.api" }' >
$$($2_PACKAGE_BDIR)_the.package.dddd ; true)
+ $2_APPEND_DEPS:=($(CAT) $$($2_PACKAGE_BDIR)_the.package.deps |
$(TR) '.' '/' | $(AWK) '{ print "$4/" $$$$3 }' | sort >
$$($2_PACKAGE_BDIR)_the.package.ddd && $(GREP) -f
$$($2_PACKAGE_BDIR)_the.package.ddd $5 | $(AWK) '{ print "$(dir
$2)_the.package : " $$$$1 "_the.package.api" }' >
$$($2_PACKAGE_BDIR)_the.package.dddd ; true)
else
# If not using dependencies, use $2 as fallback to trigger
regeneration of javah header files.
# This will generate a surplus of header files, but this does
not hurt compilation.
$2_NATIVEAPICHANGE_TRIGGER:=$2
- $2_FETCH_NATIVEAPICHANGE_CLASSES:=cat
$$($2_PACKAGE_BDIR)_the.package.now|grep -v '\$$$$'|sed -e
's|$4/||g'|sed 's|.class||g'| tr '/' '.'
+ $2_FETCH_NATIVEAPICHANGE_CLASSES:=$(CAT)
$$($2_PACKAGE_BDIR)_the.package.now|$(GREP) -v '\$$$$'|$(SED) -e
's|$4/||g'|$(SED) 's|.class||g'| $(TR) '/' '.'
endif
# The _the.package file is dependent on the java files inside the package.
@@ -422,19 +422,19 @@
$(MKDIR) -p $$($2_PACKAGE_BDIR)
$(RM) $2.tmp
$$(call ListPathsSafely,$2_PACKAGE_SRCS,\n, >> $2.tmp)
- echo $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | tr ' ' '\n'
> $$($2_PACKAGE_BDIR)_the.package.prev
- rm -f $$($2_PACKAGE_BDIR)*.class $$($2_PACKAGE_BDIR)*.notify
$$($2_PACKAGE_BDIR)*.deleted
- echo Compiling `wc $2.tmp | tr -s ' ' | cut -f 2 -d ' '` files in
package $(patsubst $4/%/,%,$(dir $2.tmp))
+ $(ECHO) $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | $(TR) ' '
'\n' > $$($2_PACKAGE_BDIR)_the.package.prev
+ $(RM) $$($2_PACKAGE_BDIR)*.class $$($2_PACKAGE_BDIR)*.notify
$$($2_PACKAGE_BDIR)*.deleted
+ $(ECHO) Compiling `$(WC) $2.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '`
files in package $(patsubst $4/%/,%,$(dir $2.tmp))
$9 $$($2_REMOTE) $$($2_DEPS) $$($2_PUBAPI) $$($2_NATIVEAPI) $(10)
-implicit:none -sourcepath "$$($2_SRCROOTSC)" -d $4 @$2.tmp
- echo $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | tr ' ' '\n'
> $$($2_PACKAGE_BDIR)_the.package.now
+ $(ECHO) $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | $(TR) ' '
'\n' > $$($2_PACKAGE_BDIR)_the.package.now
($(GREP) -xvf $$($2_PACKAGE_BDIR)_the.package.now
$$($2_PACKAGE_BDIR)_the.package.prev >
$$($2_PACKAGE_BDIR)_the.package.deleted;true)
- echo $1_CLASSES += `cat $$($2_PACKAGE_BDIR)_the.package.now` | \
- sed 's/\$$$$/\$$$$\$$$$/g' > $$($2_PACKAGE_BDIR)_the.package.d
- echo $1_JAVAS += $$($2_PACKAGE_SRCS) >> $$($2_PACKAGE_BDIR)_the.package.d
- echo $2_NOTIFIED:=true > $$($2_PACKAGE_BDIR)_the.package.notify
+ $(ECHO) $1_CLASSES += `$(CAT) $$($2_PACKAGE_BDIR)_the.package.now` | \
+ $(SED) 's/\$$$$/\$$$$\$$$$/g' > $$($2_PACKAGE_BDIR)_the.package.d
+ $(ECHO) $1_JAVAS += $$($2_PACKAGE_SRCS) >> $$($2_PACKAGE_BDIR)_the.package.d
+ $(ECHO) $2_NOTIFIED:=true > $$($2_PACKAGE_BDIR)_the.package.notify
$$($2_APPEND_DEPS)
$$($2_COPY_FILES)
- mv -f $2.tmp $2
+ $(MV) -f $2.tmp $2
endef
define remove_string
@@ -592,16 +592,16 @@
$(MKDIR) -p $$(@D)
$(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp
$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
- echo Compiling `wc $$($1_BIN)/_the.batch.tmp | tr -s ' ' | cut -f 2
-d ' '` files in batch $1
+ $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' |
$(CUT) -f 2 -d ' '` files in batch $1
($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) -implicit:none -sourcepath
"$$($1_SRCROOTSC)" -d $$($1_BIN) @$$($1_BIN)/_the.batch.tmp && \
$$(if $$($1_JAVAH),\
- cat $$($1_BIN)/_the.batch.tmp | $(XARGS) $(GREP) -E
"[[:space:]]native[[:space:]].*;|ForceNativeHeader" |\
+ $(CAT) $$($1_BIN)/_the.batch.tmp | $(XARGS) $(GREP) -E
"[[:space:]]native[[:space:]].*;|ForceNativeHeader" |\
$(GREP) -v '*' | $(GREP) -v '//' | $(CUT) -f 1 -d ':' |
$(SORT) -u |\
$(SED) $$(REWRITE_INTO_CLASSES) >
$$($1_BIN)/_the.batch.natives && \
if test -s $$($1_BIN)/_the.batch.natives; then \
$$($1_JVM) $$($1_JAVAH) "-Xbootclasspath/p:$$($1_BIN)"
-d $$($1_HEADERS) @$$($1_BIN)/_the.batch.natives ; \
fi &&) \
- mv $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
+ $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
else
# Ok, we have a modern javac server running!
# Since a single Java file can generate zero to an infinity
number of .class files
@@ -650,7 +650,7 @@
# $$(info MESSED UP PACKAGES $$($1_FOO))
# endif
- $$(shell $(RM) -f $$(addsuffix _the.package,$$(sort
$$($1_PKGS_MISSING_CLASSES) \
+ $$(shell $(RM) $$(addsuffix _the.package,$$(sort
$$($1_PKGS_MISSING_CLASSES) \
$$($1_PKGS_SUPERFLUOUS_CLASSES) \
$$($1_PKGS_MISSING_JAVAS))))
@@ -679,5 +679,3 @@
endif
endef
-
-
More information about the build-infra-dev
mailing list