Skip to content

Commit fd5f0cd

Browse files
Jan BeulichSam Ravnborg
authored andcommitted
kbuild: Do not overwrite makefile as anohter user
Change the conditional of the outputmakefile rule to be evaluated entirely in make, and add a conditional to not touch the generated makefile when e.g. running 'make install' as root while the build was done as non-root. Also adjust the comment describing this, and move the message printing and redirection to mkmakefile. Signed-off-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent cc873e1 commit fd5f0cd

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎Makefile‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,14 @@ scripts_basic:
344344
scripts/basic/%: scripts_basic ;
345345

346346
PHONY += outputmakefile
347-
# outputmakefile generate a Makefile to be placed in output directory, if
348-
# using a seperate output directory. This allows convinient use
349-
# of make in output directory
347+
# outputmakefile generates a Makefile in the output directory, if using a
348+
# separate output directory. This allows convenient use of make in the
349+
# output directory.
350350
outputmakefile:
351-
$(Q)if test ! $(srctree) -ef $(objtree); then \
352-
$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
353-
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) \
354-
> $(objtree)/Makefile; \
355-
echo ' GEN $(objtree)/Makefile'; \
356-
fi
351+
ifneq ($(KBUILD_SRC),)
352+
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
353+
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
354+
endif
357355

358356
# To make sure we do not include .config for any of the *config targets
359357
# catch them early, and hand them over to scripts/kconfig/Makefile

‎scripts/mkmakefile‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
# $4 - patchlevel
1111

1212

13-
cat << EOF
13+
test ! -r $2/Makefile -o -O $2/Makefile || exit 0
14+
echo " GEN $2/Makefile"
15+
16+
cat << EOF > $2/Makefile
1417
# Automatically generated by $0: don't edit
1518
1619
VERSION = $3

0 commit comments

Comments
 (0)