Patchwork flashrom dependencies

login
register
about
Submitter Stefan Reinauer
Date 2010-03-24 14:39:36
Message ID <4BAA2428.3020602@coresystems.de>
Download mbox | patch
Permalink /patch/1131/
State Superseded
Headers show

Comments

Stefan Reinauer - 2010-03-24 14:39:36
With the attached patch it is no longer necessary to have an extra
dependency step.
Carl-Daniel Hailfinger - 2010-03-30 03:12:26
Hi Stefan,

thanks for your patch. Review follows.

On 24.03.2010 15:39, Stefan Reinauer wrote:
> With the attached patch it is no longer necessary to have an extra
> dependency step.
> Create dependencies on the fly rather than in a separate step.
>
> Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
>
> --- Makefile	(revision 972)
> +++ Makefile	(working copy)
> @@ -244,17 +244,14 @@
>  TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
>  
>  %.o: %.c .features
> -	$(CC) $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
> +	$(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
>  
>  clean:
> -	rm -f $(PROGRAM) *.o
> +	rm -f $(PROGRAM) $(OBJS) $(OBJS:.o=.d)
>  
>   

Unfortunately, this breaks make clean (and therefore make distclean) for
non-default configurations because OBJS will only contain the currently
selected modules. You can reproduce this easily with

# make CONFIG_BITBANG_SPI=yes CONFIG_GFXNVIDIA=yes CONFIG_ATAHPT=yes
CONFIG_DEDIPROG=yes
# make clean
# ls *.o *.d
atahpt.d  atahpt.o  bitbang_spi.d  bitbang_spi.o  dediprog.d 
dediprog.o  gfxnvidia.d  gfxnvidia.o

Regards,
Carl-Daniel
Stefan Reinauer - 2010-03-30 07:48:00
On 3/30/10 5:12 AM, Carl-Daniel Hailfinger wrote:
> Unfortunately, this breaks make clean (and therefore make distclean) for
> non-default configurations because OBJS will only contain the currently
> selected modules. You can reproduce this easily with
>
> # make CONFIG_BITBANG_SPI=yes CONFIG_GFXNVIDIA=yes CONFIG_ATAHPT=yes
> CONFIG_DEDIPROG=yes
> # make clean

Yes, it assumes, that you specify the same build flags on make clean,
too. If that's not what you want, just change the $(OBJS)
stuff to *.o *.d. I initially decided against this as some people are
allergic when make clean does not only clean the stuff make created but
operates with wild cards.

Stefan

Patch

Index: Makefile
===================================================================
--- Makefile	(revision 972)
+++ Makefile	(working copy)
@@ -65,7 +65,7 @@ 
 
 PROGRAMMER_OBJS = udelay.o programmer.o
 
-all: pciutils features dep $(PROGRAM)
+all: pciutils features $(PROGRAM)
 
 # Set the flashrom version string from the highest revision number
 # of the checked out flashrom files.
@@ -244,17 +244,14 @@ 
 TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")
 
 %.o: %.c .features
-	$(CC) $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
+	$(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<
 
 clean:
-	rm -f $(PROGRAM) *.o
+	rm -f $(PROGRAM) $(OBJS) $(OBJS:.o=.d)
 
 distclean: clean
-	rm -f .dependencies .features .libdeps
+	rm -f .features .libdeps
 
-dep:
-	@$(CC) $(CPPFLAGS) $(SVNDEF) -MM *.c > .dependencies
-
 strip: $(PROGRAM)
 	$(STRIP) $(STRIP_ARGS) $(PROGRAM)
 
@@ -337,6 +334,6 @@ 
 djgpp-dos: clean
 	make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip WARNERROR=no OS_ARCH=DOS
 
-.PHONY: all clean distclean dep compiler pciutils features export tarball dos
+.PHONY: all clean distclean compiler pciutils features export tarball dos
 
--include .dependencies
+-include $(OBJS:.o=.d)