xref: /openbmc/linux/scripts/remove-stale-files (revision d8357e3b)
11476fee5SMasahiro Yamada#!/bin/sh
21476fee5SMasahiro Yamada
31476fee5SMasahiro Yamadaset -e
41476fee5SMasahiro Yamada
51476fee5SMasahiro Yamada# When you move, remove or rename generated files, you probably also update
61476fee5SMasahiro Yamada# .gitignore and cleaning rules in the Makefile. This is the right thing
71476fee5SMasahiro Yamada# to do. However, people usually do 'git pull', 'git bisect', etc. without
81476fee5SMasahiro Yamada# running 'make clean'. Then, the stale generated files are left over, often
91476fee5SMasahiro Yamada# causing build issues.
101476fee5SMasahiro Yamada#
111476fee5SMasahiro Yamada# Also, 'git status' shows such stale build artifacts as untracked files.
121476fee5SMasahiro Yamada# What is worse, some people send a wrong patch to get them back to .gitignore
131476fee5SMasahiro Yamada# without checking the commit history.
141476fee5SMasahiro Yamada#
151476fee5SMasahiro Yamada# So, when you (re)move generated files, please move the cleaning rules from
161476fee5SMasahiro Yamada# the Makefile to this script. This is run before Kbuild starts building
171476fee5SMasahiro Yamada# anything, so people will not be annoyed by such garbage files.
181476fee5SMasahiro Yamada#
191476fee5SMasahiro Yamada# This script is not intended to grow endlessly. Rather, it is a temporary scrap
201476fee5SMasahiro Yamada# yard. Stale files stay in this file for a while (for some release cycles?),
211476fee5SMasahiro Yamada# then will be really dead and removed from the code base entirely.
221476fee5SMasahiro Yamada
231476fee5SMasahiro Yamada# These were previously generated source files. When you are building the kernel
241476fee5SMasahiro Yamada# with O=, make sure to remove the stale files in the output tree. Otherwise,
251476fee5SMasahiro Yamada# the build system wrongly compiles the stale ones.
261476fee5SMasahiro Yamadaif [ -n "${building_out_of_srctree}" ]; then
27251cc826SMasahiro Yamada	for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c ashldi3.S bswapsdi2.S font.c lib1funcs.S hyp-stub.S
281476fee5SMasahiro Yamada	do
291476fee5SMasahiro Yamada		rm -f arch/arm/boot/compressed/${f}
301476fee5SMasahiro Yamada	done
31f78b25eeSMasahiro Yamada
32f78b25eeSMasahiro Yamada	for f in uart-ath79.c ashldi3.c bswapdi.c bswapsi.c
33f78b25eeSMasahiro Yamada	do
34f78b25eeSMasahiro Yamada		rm -f arch/mips/boot/compressed/${f}
35f78b25eeSMasahiro Yamada	done
363cbadd20SMasahiro Yamada
373cbadd20SMasahiro Yamada	for f in firmware.c real2.S
383cbadd20SMasahiro Yamada	do
393cbadd20SMasahiro Yamada		rm -f arch/parisc/boot/compressed/${f}
403cbadd20SMasahiro Yamada	done
411476fee5SMasahiro Yamadafi
42340a0253SMasahiro Yamada
43*d8357e3bSMasahiro Yamadarm -f arch/riscv/purgatory/kexec-purgatory.c
44*d8357e3bSMasahiro Yamada
45340a0253SMasahiro Yamadarm -f scripts/extract-cert
462d17bd24SMasahiro Yamada
472d17bd24SMasahiro Yamadarm -f arch/x86/purgatory/kexec-purgatory.c
48