| 1 |
PATH := $(PATH):/sbin:/usr/sbin |
| 2 |
IUCODE_TOOL ?= iucode_tool |
| 3 |
IUC_FLAGS := -v |
| 4 |
IUC_FINAL_FLAGS := -vv |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
IUC_OLDIES_SELECT := "--date-before=2008-01-01" |
| 20 |
IUC_OLDIES_EXCLUDE := |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
IUC_EXCLUDE := |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
IUC_EXCLUDE += -s !0x106c0 -s !0x50656 -s !0xc06f1 |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
IUC_INCLUDE := |
| 42 |
|
| 43 |
|
| 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 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
microcode-%.dbin: microcode-%.d/ |
| 79 |
@echo |
| 80 |
@echo Preprocessing microcode directory $^ into $@... |
| 81 |
@$(IUCODE_TOOL) $(IUC_FLAGS) --overwrite -w "$@" $^ |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 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 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 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 |
|
| 140 |
|
| 141 |
microcode-overrides.pbin: $(MICROCODE_OVERRIDES) |
| 142 |
@echo |
| 143 |
@echo Preprocessing microcode overrides... |
| 144 |
@$(IUCODE_TOOL) $(IUC_FLAGS) --overwrite -w "$@" $^ |
| 145 |
|
| 146 |
|
| 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 |
|
| 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 |