From 33394a9e9dd2cb367819d28a7c7ea9a512ba4aeb Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 3 Jul 2019 20:43:36 +0200 Subject: [PATCH] btrfs-progs: build: support per-file CFLAGS located in directories Our build allows easy definition of CFLAGs that apply only to a given file, like cmds_restore_cflags and cmds-restore.c . This is done by series of transformations that convert the file name to a variable name, when that is defined it's used. To support files in directories outside of the top level we need to convert the / too. The function 'subst' supports only a single string, so they have to be nested. Signed-off-by: David Sterba --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c75df1cf..e0cef2f1 100644 --- a/Makefile +++ b/Makefile @@ -327,12 +327,12 @@ endif @$(check_echo) " [SP] $<" $(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $< @echo " [CC] $@" - $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.o=%)-cflags)) \ + $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst /,_,$(subst -,_,$(@:%.o=%)-cflags))) \ $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) %.static.o: %.c @echo " [CC] $@" - $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \ + $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst /,_,$(subst -,_,$(@:%.static.o=%)-cflags))) \ $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) all: $(progs_build) $(libs_build) $(BUILDDIRS)