Quellcode durchsuchen

[build] Speed up rebuilding on header file changes

Split src_template into deps_template (which handles the definition of
foo_DEPS) and rules_template (which handles the rules referencing
foo_DEPS).  The rules_template is not affected by any included header
files and so does not need to be reprocessed following a change to an
included header file.

This reduces the time required to rebuild the Makefile rules following
a change to stdint.h by around 45%, at a cost of increasing the time
required to rebuild after a "make veryclean" by around 3%.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 14 Jahren
Ursprung
Commit
770317a57d
1 geänderte Dateien mit 62 neuen und 43 gelöschten Zeilen
  1. 62
    43
      src/Makefile.housekeeping

+ 62
- 43
src/Makefile.housekeeping Datei anzeigen

@@ -455,45 +455,52 @@ DEBUG_TARGETS	+= dbg%.o c s
455 455
 # using the following set of templates.  It would be cleaner to use
456 456
 # $(eval ...), but this function exists only in GNU make >= 3.80.
457 457
 
458
-# src_template : generate Makefile rules for a given source file
458
+# deps_template : generate dependency list for a given source file
459 459
 #
460 460
 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
461
-# $(2) is the full path to the .d file (e.g. "bin/deps/drivers/net/rtl8139.d")
462
-# $(3) is the source type (e.g. "c")
463
-# $(4) is the source base name (e.g. "rtl8139")
461
+# $(2) is the source type (e.g. "c")
462
+# $(3) is the source base name (e.g. "rtl8139")
464 463
 #
465
-define src_template
466
-
464
+define deps_template
467 465
 	@$(ECHO) "  [DEPS] $(1)"
468
-	@$(MKDIR) -p $(dir $(2))
469
-	@$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \
466
+	@$(MKDIR) -p $(BIN)/deps/$(dir $(1))
467
+	@$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
470 468
 		-Wno-error -M $(1) -MG -MP | \
471
-		sed 's/\.o\s*:/_DEPS =/' > $(2)
472
-	@$(ECHO_E) '\n$$(BIN)/$(4).o :' \
473
-		 '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
469
+		sed 's/\.o\s*:/_DEPS =/' > $(BIN)/deps/$(1).d
470
+endef
471
+
472
+# rules_template : generate rules for a given source file
473
+#
474
+# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
475
+# $(2) is the source type (e.g. "c")
476
+# $(3) is the source base name (e.g. "rtl8139")
477
+#
478
+define rules_template
479
+	@$(ECHO) "  [RULES] $(1)"
480
+	@$(MKDIR) -p $(BIN)/rules/$(dir $(1))
481
+	@$(ECHO_E) '\n$$(BIN)/$(3).o :' \
482
+		 '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
474 483
 		 '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
475
-		 '\n\t$$(RULE_$(3))\n' \
476
-		 '\nBOBJS += $$(BIN)/$(4).o\n' \
484
+		 '\n\t$$(RULE_$(2))\n' \
485
+		 '\nBOBJS += $$(BIN)/$(3).o\n' \
477 486
 		 $(foreach TGT,$(DEBUG_TARGETS), \
478
-		    $(if $(RULE_$(3)_to_$(TGT)), \
479
-		    '\n$$(BIN)/$(4).$(TGT) :' \
480
-		    '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
487
+		    $(if $(RULE_$(2)_to_$(TGT)), \
488
+		    '\n$$(BIN)/$(3).$(TGT) :' \
489
+		    '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
481 490
 		    '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
482
-		    '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
483
-		    '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
484
-		 '\n$(2) : $$($(4)_DEPS)\n' \
485
-		 '\nTAGS : $$($(4)_DEPS)\n' \
486
-		>> $(2)
487
-	@$(PERL) $(PARSEROM) $(1) >> $(2)
488
-
491
+		    '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
492
+		    '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
493
+		 '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
494
+		 '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
495
+	@$(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r
489 496
 endef
490 497
 
491
-# Rule to generate the Makefile rules files to be included
498
+# Rule to generate the dependency list file
492 499
 #
493
-$(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
494
-	$(if $(filter $(AUTO_SRCS),$<),$(call src_template,$<,$@,$(subst .,,$(suffix $<)),$(basename $(notdir $<))),@$(ECHO) 'ERROR: $< is not an AUTO_SRC' ; exit 1)
500
+$(BIN)/deps/%.d : % $(MAKEDEPS)
501
+	$(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
495 502
 
496
-# Calculate and include the list of Makefile rules files
503
+# Calculate and include the list of dependency list files
497 504
 #
498 505
 AUTO_DEPS	= $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
499 506
 ifdef NEED_DEPS
@@ -505,7 +512,24 @@ autodeps :
505 512
 	@$(ECHO) $(AUTO_DEPS)
506 513
 VERYCLEANUP	+= $(BIN)/deps
507 514
 
508
-# The following variables are created by the Makefile rules files
515
+# Rule to generate the rules file
516
+#
517
+$(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
518
+	$(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
519
+
520
+# Calculate and include the list of rules files
521
+#
522
+AUTO_RULES	= $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
523
+ifdef NEED_DEPS
524
+ifneq ($(AUTO_RULES),)
525
+-include $(AUTO_RULES)
526
+endif
527
+endif
528
+autorules :
529
+	@$(ECHO) $(AUTO_RULES)
530
+VERYCLEANUP	+= $(BIN)/rules
531
+
532
+# The following variables are created by the rules files
509 533
 #
510 534
 bobjs :
511 535
 	@$(ECHO) $(BOBJS)
@@ -807,36 +831,31 @@ automedia :
807 831
 # media_template : create Makefile rules for specified media
808 832
 #
809 833
 # $(1) is the media name (e.g. "rom")
810
-# $(2) is the full path to the .d file (e.g. "bin/deps/rom.media.d")
811 834
 #
812 835
 define media_template
813
-
814
-	@$(ECHO) "  [MEDIADEPS] $(1)"
815
-	@$(MKDIR) -p $(dir $(2))
836
+	@$(ECHO) "  [MEDIARULES] $(1)"
837
+	@$(MKDIR) -p $(BIN)/rules/$(dir $(1))
816 838
 	@$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
817 839
 		  '\n\t$$(QM)$(ECHO) "  [FINISH] $$@"' \
818 840
 		  '\n\t$$(Q)$$(CP) $$< $$@' \
819 841
 		  '\n\t$$(Q)$$(PAD_$(1))' \
820 842
 		  '\n\t$$(Q)$$(FINALISE_$(1))' \
821
-		> $(2)
822
-
843
+		> $(BIN)/rules/$(1).media.r
823 844
 endef
824 845
 
825 846
 # Rule to generate the Makefile rules to be included
826 847
 #
827
-$(BIN)/deps/%.media.d : $(MAKEDEPS)
828
-	$(if $(filter $(AUTO_MEDIA),$*), \
829
-		$(call media_template,$*,$@), \
830
-		@$(ECHO) 'ERROR: $* is not an AUTO_MEDIA' ; exit 1)
848
+$(BIN)/rules/%.media.r : $(MAKEDEPS)
849
+	$(call media_template,$*)
831 850
 
832 851
 # Calculate and include the list of Makefile rules files
833 852
 #
834
-MEDIA_DEPS		= $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
835
-mediadeps :
836
-	@$(ECHO) $(MEDIA_DEPS)
853
+MEDIA_RULES		= $(patsubst %,$(BIN)/rules/%.media.r,$(AUTO_MEDIA))
854
+mediarules :
855
+	@$(ECHO) $(MEDIA_RULES)
837 856
 ifdef NEED_DEPS
838
-ifneq ($(MEDIA_DEPS),)
839
--include $(MEDIA_DEPS)
857
+ifneq ($(MEDIA_RULES),)
858
+-include $(MEDIA_RULES)
840 859
 endif
841 860
 endif
842 861
 

Laden…
Abbrechen
Speichern