Преглед на файлове

[build] Use $(xxx_DEPS) for additional dependency information

Some objects (embedded.o, rootcert.o, and clientcert.o) define
additional dependencies on external files, using syntax such as:

    $(BIN)/clientcert.o : $(CERT_LIST)

This dependency can be missed when using debug builds.  For example,
if DEBUG=clientcert is used, then the relevant object is
$(BIN)/clientcert.dbg1.o rather than $(BIN)/clientcert.o.

Fix by adding dependencies to $(clientcert_DEPS) instead:

    clientcert_DEPS += $(CERT_LIST)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown преди 12 години
родител
ревизия
0e59417cec
променени са 1 файла, в които са добавени 95 реда и са изтрити 95 реда
  1. 95
    95
      src/Makefile.housekeeping

+ 95
- 95
src/Makefile.housekeeping Целия файл

@@ -517,95 +517,6 @@ RULE_S_to_s	= $(Q)$(PREPROCESS_S) $< > $@
517 517
 
518 518
 DEBUG_TARGETS	+= dbg%.o c s
519 519
 
520
-# We automatically generate rules for any file mentioned in AUTO_SRCS
521
-# using the following set of templates.  It would be cleaner to use
522
-# $(eval ...), but this function exists only in GNU make >= 3.80.
523
-
524
-# deps_template : generate dependency list for a given source file
525
-#
526
-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
527
-# $(2) is the source type (e.g. "c")
528
-# $(3) is the source base name (e.g. "rtl8139")
529
-#
530
-define deps_template
531
-	@$(ECHO) "  [DEPS] $(1)"
532
-	@$(MKDIR) -p $(BIN)/deps/$(dir $(1))
533
-	@$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
534
-		-Wno-error -M $(1) -MG -MP | \
535
-		sed 's/\.o\s*:/_DEPS =/' > $(BIN)/deps/$(1).d
536
-endef
537
-
538
-# rules_template : generate rules for a given source file
539
-#
540
-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
541
-# $(2) is the source type (e.g. "c")
542
-# $(3) is the source base name (e.g. "rtl8139")
543
-#
544
-define rules_template
545
-	@$(ECHO) "  [RULES] $(1)"
546
-	@$(MKDIR) -p $(BIN)/rules/$(dir $(1))
547
-	@$(ECHO_E) '\n$$(BIN)/$(3).o :' \
548
-		 '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
549
-		 '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
550
-		 '\n\t$$(RULE_$(2))\n' \
551
-		 '\nBOBJS += $$(BIN)/$(3).o\n' \
552
-		 $(foreach TGT,$(DEBUG_TARGETS), \
553
-		    $(if $(RULE_$(2)_to_$(TGT)), \
554
-		    '\n$$(BIN)/$(3).$(TGT) :' \
555
-		    '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
556
-		    '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
557
-		    '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
558
-		    '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
559
-		 '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
560
-		 '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
561
-	@$(if $(findstring drivers/,$(1)),\
562
-	   $(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r)
563
-endef
564
-
565
-# Rule to generate the dependency list file
566
-#
567
-$(BIN)/deps/%.d : % $(MAKEDEPS)
568
-	$(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
569
-
570
-# Calculate and include the list of dependency list files
571
-#
572
-AUTO_DEPS	= $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
573
-ifdef NEED_DEPS
574
-ifneq ($(AUTO_DEPS),)
575
--include $(AUTO_DEPS)
576
-endif
577
-endif
578
-autodeps :
579
-	@$(ECHO) $(AUTO_DEPS)
580
-VERYCLEANUP	+= $(BIN)/deps
581
-
582
-# Rule to generate the rules file
583
-#
584
-$(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
585
-	$(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
586
-
587
-# Calculate and include the list of rules files
588
-#
589
-AUTO_RULES	= $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
590
-ifdef NEED_DEPS
591
-ifneq ($(AUTO_RULES),)
592
--include $(AUTO_RULES)
593
-endif
594
-endif
595
-autorules :
596
-	@$(ECHO) $(AUTO_RULES)
597
-VERYCLEANUP	+= $(BIN)/rules
598
-
599
-# The following variables are created by the rules files
600
-#
601
-bobjs :
602
-	@$(ECHO) $(BOBJS)
603
-drivers :
604
-	@$(ECHO) $(DRIVERS)
605
-.PHONY : drivers
606
-roms :
607
-	@$(ECHO) $(ROMS)
608
-
609 520
 # List of embedded images included in the last build of embedded.o.
610 521
 # This is needed in order to correctly rebuild embedded.o whenever the
611 522
 # list of objects changes.
@@ -630,7 +541,7 @@ EMBED_ALL	:= $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
630 541
 		     EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
631 542
 			     \"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
632 543
 
633
-$(BIN)/embedded.o : $(EMBEDDED_FILES) $(EMBEDDED_LIST)
544
+embedded_DEPS += $(EMBEDDED_FILES) $(EMBEDDED_LIST)
634 545
 
635 546
 CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
636 547
 
@@ -658,7 +569,7 @@ TRUSTED_FPS	:= $(foreach CERT,$(TRUSTED_CERTS),\
658 569
 			 $(shell $(OPENSSL) x509 -in $(CERT) -noout -sha256 \
659 570
 				 -fingerprint))))$(COMMA))
660 571
 
661
-$(BIN)/rootcert.o : $(TRUSTED_FILES) $(TRUSTED_LIST)
572
+rootcert_DEPS += $(TRUSTED_FILES) $(TRUSTED_LIST)
662 573
 
663 574
 CFLAGS_rootcert = $(if $(TRUSTED_FPS),-DTRUSTED="$(TRUSTED_FPS)")
664 575
 
@@ -686,12 +597,12 @@ ifdef CERT
686 597
 $(CERT_INC) : $(CERT) $(CERT_LIST)
687 598
 	$(Q)$(OPENSSL) x509 -in $< -outform DER -out $@
688 599
 
689
-$(BIN)/clientcert.o : $(CERT_INC)
600
+clientcert_DEPS += $(CERT_INC)
690 601
 endif
691 602
 
692 603
 CLEANUP += $(CERT_INC)
693 604
 
694
-$(BIN)/clientcert.o : $(CERT_LIST)
605
+clientcert_DEPS += $(CERT_LIST)
695 606
 
696 607
 CFLAGS_clientcert += $(if $(CERT),-DCERTIFICATE="\"$(CERT_INC)\"")
697 608
 
@@ -719,12 +630,12 @@ ifdef KEY
719 630
 $(KEY_INC) : $(KEY) $(KEY_LIST)
720 631
 	$(Q)$(OPENSSL) rsa -in $< -outform DER -out $@
721 632
 
722
-$(BIN)/clientcert.o : $(KEY_INC)
633
+clientcert_DEPS += $(KEY_INC)
723 634
 endif
724 635
 
725 636
 CLEANUP += $(KEY_INC)
726 637
 
727
-$(BIN)/clientcert.o : $(KEY_LIST)
638
+clientcert_DEPS += $(KEY_LIST)
728 639
 
729 640
 CFLAGS_clientcert += $(if $(KEY),-DPRIVATE_KEY="\"$(KEY_INC)\"")
730 641
 
@@ -736,6 +647,95 @@ $(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
736 647
 
737 648
 $(BIN)/clientcert.o : override CC := env CCACHE_DISABLE=1 $(CC)
738 649
 
650
+# We automatically generate rules for any file mentioned in AUTO_SRCS
651
+# using the following set of templates.  It would be cleaner to use
652
+# $(eval ...), but this function exists only in GNU make >= 3.80.
653
+
654
+# deps_template : generate dependency list for a given source file
655
+#
656
+# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
657
+# $(2) is the source type (e.g. "c")
658
+# $(3) is the source base name (e.g. "rtl8139")
659
+#
660
+define deps_template
661
+	@$(ECHO) "  [DEPS] $(1)"
662
+	@$(MKDIR) -p $(BIN)/deps/$(dir $(1))
663
+	@$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
664
+		-Wno-error -M $(1) -MG -MP | \
665
+		sed 's/\.o\s*:/_DEPS +=/' > $(BIN)/deps/$(1).d
666
+endef
667
+
668
+# rules_template : generate rules for a given source file
669
+#
670
+# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
671
+# $(2) is the source type (e.g. "c")
672
+# $(3) is the source base name (e.g. "rtl8139")
673
+#
674
+define rules_template
675
+	@$(ECHO) "  [RULES] $(1)"
676
+	@$(MKDIR) -p $(BIN)/rules/$(dir $(1))
677
+	@$(ECHO_E) '\n$$(BIN)/$(3).o :' \
678
+		 '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
679
+		 '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
680
+		 '\n\t$$(RULE_$(2))\n' \
681
+		 '\nBOBJS += $$(BIN)/$(3).o\n' \
682
+		 $(foreach TGT,$(DEBUG_TARGETS), \
683
+		    $(if $(RULE_$(2)_to_$(TGT)), \
684
+		    '\n$$(BIN)/$(3).$(TGT) :' \
685
+		    '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
686
+		    '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
687
+		    '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
688
+		    '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
689
+		 '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
690
+		 '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
691
+	@$(if $(findstring drivers/,$(1)),\
692
+	   $(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r)
693
+endef
694
+
695
+# Rule to generate the dependency list file
696
+#
697
+$(BIN)/deps/%.d : % $(MAKEDEPS)
698
+	$(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
699
+
700
+# Calculate and include the list of dependency list files
701
+#
702
+AUTO_DEPS	= $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
703
+ifdef NEED_DEPS
704
+ifneq ($(AUTO_DEPS),)
705
+-include $(AUTO_DEPS)
706
+endif
707
+endif
708
+autodeps :
709
+	@$(ECHO) $(AUTO_DEPS)
710
+VERYCLEANUP	+= $(BIN)/deps
711
+
712
+# Rule to generate the rules file
713
+#
714
+$(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
715
+	$(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
716
+
717
+# Calculate and include the list of rules files
718
+#
719
+AUTO_RULES	= $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
720
+ifdef NEED_DEPS
721
+ifneq ($(AUTO_RULES),)
722
+-include $(AUTO_RULES)
723
+endif
724
+endif
725
+autorules :
726
+	@$(ECHO) $(AUTO_RULES)
727
+VERYCLEANUP	+= $(BIN)/rules
728
+
729
+# The following variables are created by the rules files
730
+#
731
+bobjs :
732
+	@$(ECHO) $(BOBJS)
733
+drivers :
734
+	@$(ECHO) $(DRIVERS)
735
+.PHONY : drivers
736
+roms :
737
+	@$(ECHO) $(ROMS)
738
+
739 739
 # Generate error usage information
740 740
 #
741 741
 $(BIN)/%.einfo : $(BIN)/%.o

Loading…
Отказ
Запис