aboutsummaryrefslogtreecommitdiffstats
path: root/memdisk
diff options
context:
space:
mode:
authorLuciano Rocha <strange@nsk.no-ip.org>2007-05-23 21:50:16 +0100
committerH. Peter Anvin <hpa@zytor.com>2007-05-25 15:01:09 -0700
commit1d81d5e3944dd5ac912150bc705fa7259eade541 (patch)
treee2b2854cb4c660521d4e3b413c944816daaa800e /memdisk
parent7f2f6e3cec8eca7710acdd0b82b095834aecd400 (diff)
downloadsyslinux-elf-1d81d5e3944dd5ac912150bc705fa7259eade541.tar.gz
syslinux-elf-1d81d5e3944dd5ac912150bc705fa7259eade541.tar.xz
syslinux-elf-1d81d5e3944dd5ac912150bc705fa7259eade541.zip
Don't clobber /dev/null when compiling as root
Compiling as root is highly discouraged, but some people do it anyway. gcc_ok, however, can clobber /dev/null due to "-o /dev/null"; this is bad. Instead, write a temporary file and delete it.
Diffstat (limited to 'memdisk')
-rw-r--r--memdisk/Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/memdisk/Makefile b/memdisk/Makefile
index 72234cab..161a163e 100644
--- a/memdisk/Makefile
+++ b/memdisk/Makefile
@@ -12,8 +12,10 @@
VERSION := $(shell cat ../version)
-gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
- then echo $(1); else echo $(2); fi)
+TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+
+gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
+ then echo $(1); else echo $(2); fi; rm -f $$tmpf)
M32 := $(call gcc_ok,-m32,)
ALIGN := $(call gcc_ok,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)