Debian Codegraph @

Makefile

raw symbols SCIP
1 PATH := $(PATH):/sbin:/usr/sbin
2 IUCODE_TOOL ?= iucode_tool
3 IUC_FLAGS := -v
4 IUC_FINAL_FLAGS := -vv
5
6 # CUTDATE RANGE:
7 #
8 # This filter selects what we consider to be old microcode which
9 # should still be shipped even if Intel dropped them. Note that
10 # it is useless to ship microcodes for anything the distro doesn't
11 # really support anymore
12 #
13 # Watch out: check in the changelog, if this filter will add
14 # microcodes that look like they've been recalled, use
15 # IUC_OLDIES_EXCLUDE to avoid shipping the probably recalled
16 # microcode. Refer to IUC_EXCLUDE for IUC_OLDIES_EXCLUDE syntax.
17 #
18 # Last manual check: up to 2008-01-01
19 IUC_OLDIES_SELECT := "--date-before=2008-01-01"
20 IUC_OLDIES_EXCLUDE :=
21
22 # EXCLUDING MICROCODES:
23 #
24 # Always document reason. See iucode_tool(8) for -s !<sig> syntax
25 # Recalls might require use of .fw overrides to retain old version,
26 # instead of exclusions. Exclusions have the highest priority, and
27 # will remove microcode added by any other means, including override
28 # files (.fw files).
29 IUC_EXCLUDE :=
30
31 # 0x106c0: alpha hardware, seen in a very very old microcode data file
32 # 0x50656, 0xc06f1: QS steppings, removed by upstream 20250512
33 IUC_EXCLUDE += -s !0x106c0 -s !0x50656 -s !0xc06f1
34
35 # INCLUDING MICROCODES:
36 #
37 # This should be used to add a microcode from any of the regular
38 # microcode bundles, without the need for an override file. See
39 # iucode_tool(8) for -s <sig> syntax. Always document the reason,
40 # as per IUC_EXCLUDE.
41 IUC_INCLUDE :=
42
43 # Keep sorting order predictable or things will break
44 export LC_COLLATE=C
45
46 MICROCODE_REG_DBIN := $(patsubst microcode-%.d/,microcode-%.dbin,$(wildcard microcode-*.d/))
47 MICROCODE_REG_SOURCES := $(sort $(wildcard microcode-*.dat microcode-*.bin) $(MICROCODE_REG_DBIN))
48 MICROCODE_SUP_SOURCES := $(wildcard supplementary-ucode-*.bin supplementary-ucode-*.d/)
49 MICROCODE_OVERRIDES := $(wildcard *.fw)
50
51 MICROCODE_FINAL_REG_SOURCES :=
52 ifneq ($(IUC_OLDIES_SELECT),)
53 MICROCODE_FINAL_REG_SOURCES += microcode-oldies.pbin
54 endif
55 ifneq ($(IUC_INCLUDE),)
56 MICROCODE_FINAL_REG_SOURCES += microcode-includes.pbin
57 endif
58 MICROCODE_FINAL_REG_SOURCES += $(lastword $(MICROCODE_REG_SOURCES))
59
60 ifneq ($(MICROCODE_SUP_SOURCES),)
61 MICROCODE_FINAL_SOURCES := microcode-aux.pbin
62 else
63 MICROCODE_FINAL_SOURCES := $(MICROCODE_FINAL_REG_SOURCES)
64 endif
65 ifneq ($(MICROCODE_OVERRIDES),)
66 MICROCODE_FINAL_SOURCES += microcode-overrides.pbin
67 endif
68
69 all: intel-microcode.bin intel-microcode-64.bin
70
71 # When processing a directory that contains a single upstream
72 # microcode release (split over many binary microcode files), we need
73 # to group it into a single (temporary) bundle for downgrade mode to
74 # work as expected. Using iucode_tool (in the default --no-downgrade
75 # mode) to generate the temporary bundle ensures reproducibility,
76 # since it will sort out any conflicts in a predictable way.
77
78 microcode-%.dbin: microcode-%.d/
79 @echo
80 @echo Preprocessing microcode directory $^ into $@...
81 @$(IUCODE_TOOL) $(IUC_FLAGS) --overwrite -w "$@" $^
82
83 # When looking for "old" microcodes that we should ship even if they
84 # are not in the latest regular microcode bundle anymore, we use a
85 # date filter to select *signatures* of microcodes that should be
86 # included (instead of directly selecting the microcode itself).
87 #
88 # Then, the "latest" microcode (in source file order, due to the use
89 # of downgrade mode) for each such signatures will be selected,
90 # regardless of the date on the microcode itself.
91
92 microcode-oldies.pbin: $(MICROCODE_REG_SOURCES)
93 @echo
94 @echo Preprocessing older regular microcode...
95 @$(IUCODE_TOOL) $(IUC_FLAGS) \
96 $(IUC_OLDIES_SELECT) $(IUC_OLDIES_EXCLUDE) \
97 --loose-date-filtering --downgrade --overwrite -w "$@" $^
98
99 microcode-includes.pbin: $(MICROCODE_REG_SOURCES)
100 @echo
101 @echo Preprocessing force-included regular microcode...
102 @$(IUCODE_TOOL) $(IUC_FLAGS) -s! $(IUC_INCLUDE) \
103 --downgrade --overwrite -w "$@" $^
104
105 # When there are supplementary microcode bundles, they must be merged
106 # with the regular microcode in a separate step, since all such
107 # microcodes must have the same precedence. We use two intermediate
108 # bundles for this.
109 #
110 # The oldies and force-included microcodes are bundled together with
111 # the latest regular microcode bundle in microcode-regular.pbin. The
112 # precedence order for downgrading is:
113 #
114 # oldies < includes < latest regular microcode bundle
115 #
116 # The precedence order won't matter for oldies and includes, as they
117 # either have different microcode, or microcode with the same
118 # revision.
119 #
120 # Then, microcode-regular.pbin is merged with all supplementary
121 # microcode bundles, with the downgrade logic disabled in the
122 # microcode-aux.pbin target. The result will be used by the final
123 # target.
124 #
125 # When there are no supplementary microcode updates, we can do all the
126 # merging with the downgrade logic active in a single go in the final
127 # target.
128
129 microcode-regular.pbin: $(MICROCODE_FINAL_REG_SOURCES)
130 @echo
131 @echo Building microcode bundle for regular microcode...
132 @$(IUCODE_TOOL) $(IUC_FINAL_FLAGS) --downgrade --overwrite -w "$@" $^
133
134 microcode-aux.pbin: microcode-regular.pbin $(MICROCODE_SUP_SOURCES)
135 @echo
136 @echo Merging regular and supplementary microcode bundles...
137 @$(IUCODE_TOOL) $(IUC_FINAL_FLAGS) --overwrite -w "$@" $^
138
139 # The microcode overrides are bundled together to sort out any
140 # duplication and revision level issues.
141 microcode-overrides.pbin: $(MICROCODE_OVERRIDES)
142 @echo
143 @echo Preprocessing microcode overrides...
144 @$(IUCODE_TOOL) $(IUC_FLAGS) --overwrite -w "$@" $^
145
146 # Final target
147 intel-microcode.bin: $(MICROCODE_FINAL_SOURCES)
148 @echo
149 @echo Building final microcode bundle...
150 @$(IUCODE_TOOL) $(IUC_FINAL_FLAGS) $(IUC_EXCLUDE) \
151 --downgrade --overwrite -w "$@" $^
152
153 intel-microcode-64.bin: intel-microcode.bin
154 @echo
155 @echo Building stripped-down microcode bundle for x86-64 and x32...
156 @$(IUCODE_TOOL) $(IUC_FLAGS) \
157 $(shell sed -n -r -e '/^i.86/ { s/^[^ ]+ +/-s !/;s/ +\#.*//;p}' cpu-signatures.txt) $(IUC_EXCLUDE) \
158 --overwrite -w "$@" $^
159
160 # Aux. targets for packaging: make FWDIR=${PREFIX}/lib/firmware intel-ucode-fw/fw64
161 intel-ucode-fw: intel-microcode.bin
162 @test -d "$(FWDIR)" && \
163 $(IUCODE_TOOL) $(IUC_EXCLUDE) --overwrite --write-firmware="$(FWDIR)" $^
164
165 intel-ucode-fw64: intel-microcode-64.bin
166 @test -d "$(FWDIR)" && \
167 $(IUCODE_TOOL) $(IUC_EXCLUDE) --overwrite --write-firmware="$(FWDIR)" $^
168
169 .PHONY: intel-ucode-fw intel-ucode-fw64
170
171 distclean: clean
172 clean:
173 rm -f intel-microcode-64.bin intel-microcode.bin
174 rm -f microcode-overrides.pbin microcode-oldies.pbin microcode-includes.pbin microcode-regular.pbin microcode-aux.pbin
175 rm -f microcode-*.dbin
176
177 .PHONY: clean