common/makefiles/JavaCompilation.gmk

changeset 971
584dc2e95e04
parent 751
e5cf1735638c
child 972
f3697e0783e2
equal deleted inserted replaced
970:e885c762cedd 971:584dc2e95e04
161 161
162 # Utility macros, to make the shell script receipt somewhat easier to dechipher. 162 # Utility macros, to make the shell script receipt somewhat easier to dechipher.
163 163
164 # The capture contents macro finds all files (matching the patterns, typically 164 # The capture contents macro finds all files (matching the patterns, typically
165 # .class and .prp) that are newer than the jar-file, ie the new content to be put into the jar. 165 # .class and .prp) that are newer than the jar-file, ie the new content to be put into the jar.
166 # NOTICE: please leave the parentheses space separated otherwise the AIX build will break!
166 $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\ 167 $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\
167 (($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) -a -newer $$@ $$($1_GREP_INCLUDES) \ 168 ( ( $(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) -a -newer $$@ $$($1_GREP_INCLUDES) \
168 $$($1_GREP_EXCLUDES) | $(SED) 's|$$(src)/||g' &&\ 169 $$($1_GREP_EXCLUDES) | $(SED) 's|$$(src)/||g' &&\
169 $(ECHO) $$(subst $$(src)/,,$$($1_EXTRA_FILES))) > \ 170 $(ECHO) $$(subst $$(src)/,,$$($1_EXTRA_FILES) ) ) > \
170 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) 171 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE) )
171 # The capture metainf macro finds all files below the META-INF directory that are newer than the jar-file. 172 # The capture metainf macro finds all files below the META-INF directory that are newer than the jar-file.
172 ifeq (,$$($1_SKIP_METAINF)) 173 ifeq (,$$($1_SKIP_METAINF))
173 $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 ) $$(NEWLINE)) 174 $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 ) $$(NEWLINE))
174 endif 175 endif
175 # The capture deletes macro finds all deleted files and concatenates them. The resulting file 176 # The capture deletes macro finds all deleted files and concatenates them. The resulting file
176 # tells us what to remove from the jar-file. 177 # tells us what to remove from the jar-file.
177 $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\} >> $$($1_DELETES_FILE) \;) $$(NEWLINE)) 178 $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\} >> $$($1_DELETES_FILE) \;) $$(NEWLINE))
178 # The update contents macro updates the jar file with the previously capture contents. 179 # The update contents macro updates the jar file with the previously capture contents.
179 # xargs is used to trim the whitespace from the contents file, to see if it is empty. 180 # Use 'wc -w' to see if the contents file is empty.
180 $1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\ 181 $1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
181 (cd $$(src) && \ 182 (cd $$(src) && \
182 if [ -n "`$(CAT) _the.$$($1_JARNAME)_contents | $(XARGS)`" ]; then \ 183 if [ "`$(WC) -w _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'`" -gt "0" ]; then \
183 $(ECHO) " updating" `$(WC) -l _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \ 184 $(ECHO) " updating" `$(WC) -l _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
184 $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @_the.$$($1_JARNAME)_contents; \ 185 $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @_the.$$($1_JARNAME)_contents; \
185 fi) $$(NEWLINE)) 186 fi) $$(NEWLINE))
186 # The s-variants of the above macros are used when the jar is created from scratch. 187 # The s-variants of the above macros are used when the jar is created from scratch.
188 # NOTICE: please leave the parentheses space separated otherwise the AIX build will break!
187 $1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\ 189 $1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\
188 (($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \ 190 ( ( $(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \
189 $$($1_GREP_EXCLUDES) | $(SED) 's|$$(src)/||g' &&\ 191 $$($1_GREP_EXCLUDES) | $(SED) 's|$$(src)/||g' &&\
190 $$(subst $$(src)/,,$(ECHO) $$($1_EXTRA_FILES))) > \ 192 $$(subst $$(src)/,,$(ECHO) $$($1_EXTRA_FILES) ) ) > \
191 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) 193 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE) )
192 194
193 ifeq (,$$($1_SKIP_METAINF)) 195 ifeq (,$$($1_SKIP_METAINF))
194 $1_SCAPTURE_METAINF=$$(foreach src,$$($1_SRCS),\ 196 $1_SCAPTURE_METAINF=$$(foreach src,$$($1_SRCS),\
195 ($(FIND) $$(src)/META-INF -type f 2> /dev/null | $(SED) 's|$$(src)/||g' >> \ 197 ($(FIND) $$(src)/META-INF -type f 2> /dev/null | $(SED) 's|$$(src)/||g' >> \
196 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE)) 198 $$(src)/_the.$$($1_JARNAME)_contents) $$(NEWLINE))

mercurial