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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2019-07-03 20:43:36 +02:00
parent 32f75c87a0
commit 33394a9e9d
1 changed files with 2 additions and 2 deletions

View File

@ -327,12 +327,12 @@ endif
@$(check_echo) " [SP] $<" @$(check_echo) " [SP] $<"
$(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $< $(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $<
@echo " [CC] $@" @echo " [CC] $@"
$(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.o=%)-cflags)) \ $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst /,_,$(subst -,_,$(@:%.o=%)-cflags))) \
$($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
%.static.o: %.c %.static.o: %.c
@echo " [CC] $@" @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)) $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
all: $(progs_build) $(libs_build) $(BUILDDIRS) all: $(progs_build) $(libs_build) $(BUILDDIRS)