aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-04-27 20:58:14 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-04-27 20:58:14 -0700
commitfe9385228a7845e98485c925031ee5a46f5dfd3b (patch)
tree93f63bc09e86b3f8c0139e87a017f3c0f015eccb
parentf2dc4e108dbec03b05f8629626b0006454e6195e (diff)
downloadsyslinux-fe9385228a7845e98485c925031ee5a46f5dfd3b.tar.gz
syslinux-fe9385228a7845e98485c925031ee5a46f5dfd3b.tar.xz
syslinux-fe9385228a7845e98485c925031ee5a46f5dfd3b.zip
Unify dependency generation
Make the dependency generation more common; have a general pattern in MCONFIG, and use it in rules (not in CFLAGS). For NASM source, in order to stay compatible with old versions of NASM, run NASM twice; newer versions of NASM is capable of generating dependencies simultaneously like gcc can, but that would break compatibility with older distros. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--MCONFIG7
-rw-r--r--com32/MCONFIG18
-rw-r--r--core/Makefile21
-rw-r--r--dos/Makefile10
-rw-r--r--extlinux/Makefile6
-rw-r--r--linux/Makefile6
-rw-r--r--mbr/Makefile8
-rw-r--r--mtools/Makefile6
-rw-r--r--utils/Makefile6
-rw-r--r--win32/Makefile6
10 files changed, 46 insertions, 48 deletions
diff --git a/MCONFIG b/MCONFIG
index 3fd3946d..daeb9d4c 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -54,3 +54,10 @@ GZIPPROG = gzip
PNGTOPNM = pngtopnm
com32 = $(topdir)/com32
+
+# Common stanza to make gcc generate .*.d dependency files
+MAKEDEPS = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
+
+# Dependencies that exclude system headers; use whenever we use
+# header files from the platform.
+UMAKEDEPS = -Wp,-MT,$@,-MMD,$(dir $@).$(notdir $@).d
diff --git a/com32/MCONFIG b/com32/MCONFIG
index 599cfb67..e02ec67c 100644
--- a/com32/MCONFIG
+++ b/com32/MCONFIG
@@ -35,10 +35,12 @@ endif
CFLAGS = $(GCCOPT) -W -Wall -march=i386 \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) \
- -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
-SFLAGS = $(GCCOPT) -D__COM32__ -march=i386 \
- -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+SFLAGS = $(GCCOPT) -W -Wall -march=i386 \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+
LDFLAGS = -m elf_i386 -T $(com32)/lib/com32.ld
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
@@ -54,11 +56,11 @@ C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
.PRECIOUS: %.o
%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(SFLAGS) -c -o $@ $<
.PRECIOUS: %.o
%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
.PRECIOUS: %.elf
%.elf: %.o $(LIBS) $(C_LIBS)
@@ -66,11 +68,11 @@ C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
.PRECIOUS: %.lo
%.lo: %.S
- $(CC) $(LNXSFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(LNXSFLAGS) -c -o $@ $<
.PRECIOUS: %.lo
%.lo: %.c
- $(CC) $(LNXCFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(LNXCFLAGS) -c -o $@ $<
.PRECIOUS: %.lnx
%.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
diff --git a/core/Makefile b/core/Makefile
index 16e21dc0..1bd13e75 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -72,6 +72,7 @@ iso%.bin: iso%.elf checksumiso.pl
$(OBJCOPY) -O binary $< $@
%.o: %.asm kwdhash.gen ../version.gen
+ ( $(NASM) -DDEPEND $(NINCLUDE) -o $@ -M $< && echo '' ) > .$@.d; true
$(NASM) $(NASMOPT) -f elf -g -F stabs -DDATE_STR="'$(DATE)'" \
-DHEXDATE="$(HEXDATE)" \
-l $(@:.o=.lsr) -o $@ $<
@@ -111,28 +112,14 @@ install-all: install install-lib
netinstall: installer
tidy dist:
- rm -f codepage.cp *.o *.elf stupid.* patch.offset
+ rm -f codepage.cp *.o *.elf stupid.* patch.offset .depend .*.d
rm -f *.lsr *.lst *.map *.sec
rm -f $(OBSOLETE)
clean: tidy
spotless: clean
- rm -f $(BTARGET) *.bin *_bin.c .depend
-
-# Note: the extra echo '' is to deal with old versions of NASM which
-# did not properly terminate the dependency list.
-.depend:
- rm -f .depend
- for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done ; true
- for nsrc in $(NASMSRC) ; do \
- ( $(NASM) -DDEPEND $(NINCLUDE) -o \
- `echo $$nsrc | sed -e 's/\.asm/\.o/'` -M $$nsrc ; \
- echo '' ) >> .depend ; done ; true
-
-depend:
- rm -f .depend
- $(MAKE) .depend
+ rm -f $(BTARGET) *.bin *_bin.c
# Include dependencies file
--include .depend
+-include .*.d
diff --git a/dos/Makefile b/dos/Makefile
index da73a6d5..afcb1465 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -60,15 +60,15 @@ syslinux.com: syslinux.elf
$(OBJCOPY) -O binary $< $@
%.o: %.c
- $(CC) -Wp,-MT,$@,-MD,.$@.d $(CFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
%.i: %.c
- $(CC) $(CFLAGS) -E -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
%.s: %.c
- $(CC) $(CFLAGS) -S -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
%.o: %.S
- $(CC) -Wp,-MT,$@,-MD,.$@.d $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
%.s: %.S
- $(CC) $(CFLAGS) -E -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $<
%.com: %.asm
$(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
diff --git a/extlinux/Makefile b/extlinux/Makefile
index d915e5a9..48105338 100644
--- a/extlinux/Makefile
+++ b/extlinux/Makefile
@@ -50,10 +50,10 @@ extlinux: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
%.o: %.c
- $(CC) -Wp,-MT,$@,-MMD,.$@.d $(CFLAGS) -c -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
%.i: %.c
- $(CC) $(CFLAGS) -E -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -E -o $@ $<
%.s: %.c
- $(CC) $(CFLAGS) -S -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -S -o $@ $<
-include .*.d *.tmp
diff --git a/linux/Makefile b/linux/Makefile
index 00fa0765..a469cefd 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -52,10 +52,10 @@ syslinux-nomtools: syslinux
ln -f $< $@
%.o: %.c
- $(CC) -Wp,-MT,$@,-MMD,.$@.d $(CFLAGS) -c -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
%.i: %.c
- $(CC) $(CFLAGS) -E -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -E -o $@ $<
%.s: %.c
- $(CC) $(CFLAGS) -S -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -S -o $@ $<
-include .*.d *.tmp
diff --git a/mbr/Makefile b/mbr/Makefile
index 6cd677c0..e0695843 100644
--- a/mbr/Makefile
+++ b/mbr/Makefile
@@ -24,13 +24,13 @@ all: mbr.bin altmbr.bin gptmbr.bin isohdpfx.bin \
.PRECIOUS: %.o
%.o: %.S adjust.h
- $(CC) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
%_c.o: %.S adjust.h
- $(CC) $(SFLAGS) -Wa,-a=$*_c.lst -DCTRL_80 -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*_c.lst -DCTRL_80 -c -o $@ $<
%_f.o: %.S adjust.h
- $(CC) $(SFLAGS) -Wa,-a=$*_f.lst -DFORCE_80 -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*_f.lst -DFORCE_80 -c -o $@ $<
.PRECIOUS: %.elf
%.elf: %.o mbr.ld
@@ -44,7 +44,7 @@ all: mbr.bin altmbr.bin gptmbr.bin isohdpfx.bin \
mbr_bin.c: mbr.bin
tidy dist:
- rm -f *.o *.elf *.lst
+ rm -f *.o *.elf *.lst .*.d
clean: tidy
diff --git a/mtools/Makefile b/mtools/Makefile
index b0f0a194..b5517805 100644
--- a/mtools/Makefile
+++ b/mtools/Makefile
@@ -34,10 +34,10 @@ syslinux: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
%.o: %.c
- $(CC) -Wp,-MT,$@,-MMD,.$@.d $(CFLAGS) -c -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
%.i: %.c
- $(CC) $(CFLAGS) -E -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -E -o $@ $<
%.s: %.c
- $(CC) $(CFLAGS) -S -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -S -o $@ $<
-include .*.d *.tmp
diff --git a/utils/Makefile b/utils/Makefile
index de8c9992..179d5da6 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -26,7 +26,7 @@ ASIS = keytab-lilo lss16toppm md5pass ppmtolss16 sha1pass syslinux2ansi
all: $(TARGETS)
%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
mkdiskimage: mkdiskimage.in ../mbr/mbr.bin bin2hex.pl
$(PERL) bin2hex.pl < ../mbr/mbr.bin | cat mkdiskimage.in - > $@
@@ -40,7 +40,7 @@ gethostip: gethostip.o
$(CC) $(LDFLAGS) -o $@ $^
tidy dist:
- rm -f *.o
+ rm -f *.o .*.d
clean: tidy
rm -f $(TARGETS)
@@ -52,3 +52,5 @@ installer: all
install: installer
mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
install -m 755 $(TARGETS) $(ASIS) $(INSTALLROOT)$(BINDIR)
+
+-include .*.d
diff --git a/win32/Makefile b/win32/Makefile
index bb7cb34e..964b74c5 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -78,10 +78,10 @@ syslinux.exe: $(OBJS)
%.o: %.c
- $(WINCC) -Wp,-MT,$@,-MMD,.$@.d $(WINCFLAGS) -c -o $@ $<
+ $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -c -o $@ $<
%.i: %.c
- $(WINCC) $(WINCFLAGS) -E -o $@ $<
+ $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -E -o $@ $<
%.s: %.c
- $(WINCC) $(WINCFLAGS) -S -o $@ $<
+ $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -S -o $@ $<
-include .*.d *.tmp