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
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)
.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)
.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)
$(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 $@ $<
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
$(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 $<
$(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
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
.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
mbr_bin.c: mbr.bin
tidy dist:
- rm -f *.o *.elf *.lst
+ rm -f *.o *.elf *.lst .*.d
clean: tidy
$(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
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 - > $@
$(CC) $(LDFLAGS) -o $@ $^
tidy dist:
- rm -f *.o
+ rm -f *.o .*.d
clean: tidy
rm -f $(TARGETS)
install: installer
mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
install -m 755 $(TARGETS) $(ASIS) $(INSTALLROOT)$(BINDIR)
+
+-include .*.d
%.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