xref: /openbmc/linux/scripts/remove-stale-files (revision 3cbadd20)
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
271476fee5SMasahiro Yamada	for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
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
36*3cbadd20SMasahiro Yamada
37*3cbadd20SMasahiro Yamada	for f in firmware.c real2.S
38*3cbadd20SMasahiro Yamada	do
39*3cbadd20SMasahiro Yamada		rm -f arch/parisc/boot/compressed/${f}
40*3cbadd20SMasahiro Yamada	done
411476fee5SMasahiro Yamadafi
42