[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cdi-devel] [PATCH v2 1/9] Makefile: Heed Makefile.conf



On Thu, Apr 16, 2015 at 12:13:50AM +0200, Max Reitz wrote:
> + Apparently it is allowed to specify additional CFLAGS (as "CC_FLAGS")
>   in a file named Makefile.conf (formatted as a shell script) in a
>   driver's root directory; or at least ext2 just does this.
>   This patch makes the CDI Makefile take the additional flags from that
>   file into account, if present.
>   Thanks to this, the ext2 driver can be compiled.
> 
> Signed-off-by: Max Reitz <max@xxxxxxxxxx>

It builds fine for me, but I think now I know why...

lrwxrwxrwx 1 kevin users 16 21. Aug 2009  ext2/include -> libext2/include/


> diff --git a/Makefile b/Makefile
> index 5360efb..bc04e58 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -9,7 +9,9 @@ run_command = $(if $(V),$(2),@echo $(1);$(2))
>  all: $(OBJS)
>  
>  %.o: %.c
> -	$(call run_command,"CC $^",$(CC) $(CFLAGS) $(addprefix -I,$(addprefix $(dir $^),. include)) -c -o $@ $^)
> +	$(call run_command,"CC $^",$(CC) $(CFLAGS) \
> +		$(if $(shell if [ -f $(dir $^)/Makefile.conf ]; then echo .; fi),$(shell cd $(dir $^); echo -e "$$(< Makefile.conf)\necho \$$CC_FLAGS" | sh -s),) \

Not exactly sure why you need a make $(if) here when there is already a
shell if, but it looks as if it could work.

Someone would have to say something about portability, but I'll stay
quiet for now. ;-)

> +		$(addprefix -I,$(addprefix $(dir $^),. include)) -c -o $@ $^)
>  
>  clean:
>  	-rm $(OBJS) 2> /dev/null

Acked-by: Kevin Wolf <kevin@xxxxxxxxxx>