294 endif |
294 endif |
295 endef |
295 endef |
296 |
296 |
297 ### Convenience functions from Main.gmk |
297 ### Convenience functions from Main.gmk |
298 |
298 |
299 # Cleans the component given as $1 |
299 # Cleans the dir given as $1 |
300 define CleanComponent |
300 define CleanDir |
301 @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." |
301 @$(PRINTF) "Cleaning $(strip $1) build artifacts ..." |
302 @($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) |
302 @($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) |
303 @$(PRINTF) " done\n" |
303 @$(PRINTF) " done\n" |
304 endef |
304 endef |
305 |
305 |
|
306 define Clean-gensrc |
|
307 @$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..." |
|
308 @$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1) |
|
309 @$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(strip $1) |
|
310 @$(PRINTF) " done\n" |
|
311 endef |
|
312 |
|
313 define Clean-java |
|
314 @$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..." |
|
315 @$(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1) |
|
316 @$(RM) -r $(SUPPORT_OUTPUTDIR)/misc/$(strip $1) |
|
317 @$(PRINTF) " done\n" |
|
318 @$(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..." |
|
319 @$(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1) |
|
320 @$(PRINTF) " done\n" |
|
321 endef |
|
322 |
|
323 define Clean-native |
|
324 @$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..." |
|
325 @$(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1) |
|
326 @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1) |
|
327 @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1) |
|
328 @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1) |
|
329 @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1) |
|
330 @$(PRINTF) " done\n" |
|
331 endef |
|
332 |
|
333 define Clean-include |
|
334 @$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..." |
|
335 @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1) |
|
336 @$(PRINTF) " done\n" |
|
337 endef |
|
338 |
|
339 define CleanModule |
|
340 $(call Clean-gensrc, $1) |
|
341 $(call Clean-java, $1) |
|
342 $(call Clean-native, $1) |
|
343 $(call Clean-include, $1) |
|
344 endef |
|
345 |
|
346 |
306 ################################################################################ |
347 ################################################################################ |
307 |
348 |
308 MAKE_DIR_LIST := $(JDK_TOPDIR)/make |
349 MAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) |
309 |
350 MAKE_MAKEDIR_LIST := make |
310 # Find all modules that has a makefile for a certain build phase |
351 |
311 # Param 1: Make subdir to look in |
352 # Helper macro for DeclareRecipesForPhase |
312 # Param 2: File prefix to look for |
353 # Declare a recipe for calling the module and phase specific makefile. |
313 FindModulesWithMakefileFor = $(sort $(foreach d, $(MAKE_DIR_LIST), \ |
354 # If there are multiple makefiles to call, create a rule for each topdir |
314 $(patsubst $d/$(strip $1)/$(strip $2)-%.gmk,%, \ |
355 # that contains a makefile with the target $module-$suffix-$repodir, |
315 $(wildcard $d/$(strip $1)/$(strip $2)-*.gmk)))) |
356 # (i.e: java.base-gensrc-jdk) |
316 |
357 # Normally there is only one makefile, and the target will just be |
317 # Declare a recipe for calling such a makefile |
358 # $module-$suffix |
318 # Param 1: Module name |
359 # Param 1: Name of list to add targets to |
319 # Param 2: Suffix for rule |
360 # Param 2: Module name |
320 # Param 3: Make subdir |
361 # Param 3: Topdir |
321 # Param 4: Makefile prefix |
|
322 define DeclareRecipeForModuleMakefile |
362 define DeclareRecipeForModuleMakefile |
323 $$(strip $1)-$$(strip $2): |
363 ifeq ($$($1_MULTIPLE_MAKEFILES), true) |
324 +($(CD) $$(dir $$(firstword $$(wildcard $$(addsuffix /$$(strip $3)/$$(strip $4)-$$(strip $1).gmk, \ |
364 $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) |
325 $(MAKE_DIR_LIST))))) \ |
365 $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) |
|
366 |
|
367 $2-$$($1_TARGET_SUFFIX)-$$(notdir $3): |
|
368 else |
|
369 $2-$$($1_TARGET_SUFFIX): |
|
370 endif |
|
371 $(ECHO) $(LOG_INFO) "Building $$@" |
|
372 ifeq ($$($1_USE_WRAPPER), true) |
|
373 +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \ |
|
374 -f ModuleWrapper.gmk \ |
|
375 $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ |
|
376 $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ |
|
377 MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX)) |
|
378 else |
|
379 +($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \ |
|
380 $3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \ |
326 && $(MAKE) $(MAKE_ARGS) \ |
381 && $(MAKE) $(MAKE_ARGS) \ |
327 -f $$(strip $4)-$$(strip $1).gmk \ |
382 -f $$($1_FILE_PREFIX)-$2.gmk \ |
328 $$(addprefix -I, $$(wildcard $(MAKE_DIR_LIST) \ |
383 $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ |
329 $$(addsuffix /$$(strip $3), $(MAKE_DIR_LIST)))) \ |
384 $$(addsuffix /$3, $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ |
330 MODULE=$$(strip $1)) |
385 MODULE=$2) |
|
386 endif |
|
387 |
|
388 endef |
|
389 |
|
390 # Helper macro for DeclareRecipesForPhase |
|
391 # Param 1: Name of list to add targets to |
|
392 # Param 2: Module name |
|
393 define DeclareRecipesForPhaseAndModule |
|
394 $1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \ |
|
395 $$(patsubst $$d/%, $$d, $$(filter $$d/%, \ |
|
396 $$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \ |
|
397 $$(foreach s, $(MAKE_MAKEDIR_LIST), \ |
|
398 $$(addsuffix /$$s, $(MAKE_TOPDIR_LIST)))))))))) |
|
399 |
|
400 # Only declare recipes if there are makefiles to call |
|
401 ifneq ($$($1_$2_TOPDIRS), ) |
|
402 $$(foreach d, $$($1_$2_TOPDIRS), \ |
|
403 $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d))) |
|
404 $1 += $2-$$($1_TARGET_SUFFIX) |
|
405 $1_MODULES += $2 |
|
406 endif |
|
407 endef |
|
408 |
|
409 # Declare recipes for a specific module and build phase if there are makefiles |
|
410 # present for the specific combination. |
|
411 # Param 1: Name of list to add targets to |
|
412 # Named params: |
|
413 # TARGET_SUFFIX : Suffix of target to create for recipe |
|
414 # MAKE_SUBDIR : Subdir for this build phase |
|
415 # FILE_PREFIX : File prefix for this build phase |
|
416 # USE_WRAPPER : Set to true to use ModuleWrapper.gmk |
|
417 # CHECK_MODULES : List of modules to try |
|
418 # MULTIPLE_MAKEFILES : Set to true to handle makefils for the same module in |
|
419 # phase in multiple repos |
|
420 # Exported variables: |
|
421 # $1_MODULES : All modules that had rules generated |
|
422 # $1_TARGETS : All targets generated |
|
423 define DeclareRecipesForPhase |
|
424 $(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE)) |
|
425 $(if $(8),$(error Internal makefile error: Too many arguments to \ |
|
426 DeclareRecipesForPhase, please update MakeHelper.gmk)) |
|
427 |
|
428 $$(foreach m, $$($(strip $1)_CHECK_MODULES), \ |
|
429 $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m))) |
|
430 |
|
431 $(strip $1)_TARGETS := $$($(strip $1)) |
331 endef |
432 endef |
332 |
433 |
333 ################################################################################ |
434 ################################################################################ |
334 |
435 |
335 endif # _MAKEHELPERS_GMK |
436 endif # _MAKEHELPERS_GMK |