History

[PATCH] kbuild: don't put temp files in source

The as-instr/ld-option need to create temporary files, but create them in the output directory, when compiling external modules. Reformat them a bit and use $(CC) instead of $(AS) as the former is used by kbuild to assemble files.

Roman Zippel committed 19 years ago

Commit 347a00f1 parent 15964861 file · +12 −7Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/Kbuild.include+12−7
@@ -56,6 +56,9 @@ endef · 55 unmodified lines
5656 # gcc support functions
5757 # See documentation in Documentation/kbuild/makefiles.txt
5858
59+# output directory for tests below
60+TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
61+
5962 # as-option
6063 # Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
6164
@@ -66,9 +69,11 @@ as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ · 4 unmodified lines
6669 # as-instr
6770 # Usage: cflags-y += $(call as-instr, instr, option1, option2)
6871
69−as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o astest$$$$.out ; \
70− then echo "$(2)"; else echo "$(3)"; fi; \
71− rm -f astest$$$$.out)
72+as-instr = $(shell if echo -e "$(1)" | \
73+ $(CC) $(AFLAGS) -c -xassembler - \
74+ -o $(TMPOUT)astest$$$$.out > /dev/null 2>&1; \
75+ then rm $(TMPOUT)astest$$$$.out; echo "$(2)"; \
76+ else echo "$(3)"; fi)
7277
7378 # cc-option
7479 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
@@ -97,10 +102,10 @@ cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \ · 22 unmodified lines
97102
98103 # ld-option
99104 # Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
100−ld-option = $(shell if $(CC) $(1) \
101− -nostdlib -o ldtest$$$$.out -xc /dev/null \
102− > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi; \
103− rm -f ldtest$$$$.out)
105+ld-option = $(shell if $(CC) $(1) -nostdlib -xc /dev/null \
106+ -o $(TMPOUT)ldtest$$$$.out > /dev/null 2>&1; \
107+ then rm $(TMPOUT)ldtest$$$$.out; echo "$(1)"; \
108+ else echo "$(2)"; fi)
104109
105110 ###
106111 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=