btrfs-progs: build: add basic support for subdirectory build

Add explicit target file names and set the top source directory.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-09-23 16:06:57 +02:00
parent 8d8de7c2e5
commit 605ed50b8c
1 changed files with 5 additions and 2 deletions

View File

@ -51,6 +51,8 @@ DEBUG_CFLAGS_DEFAULT = -O0 -U_FORTIFY_SOURCE -ggdb3
DEBUG_CFLAGS_INTERNAL = DEBUG_CFLAGS_INTERNAL =
DEBUG_CFLAGS := DEBUG_CFLAGS :=
TOPDIR := $(shell pwd)
# Common build flags # Common build flags
CFLAGS = @CFLAGS@ \ CFLAGS = @CFLAGS@ \
-include config.h \ -include config.h \
@ -58,6 +60,7 @@ CFLAGS = @CFLAGS@ \
-D_XOPEN_SOURCE=700 \ -D_XOPEN_SOURCE=700 \
-fno-strict-aliasing \ -fno-strict-aliasing \
-fPIC \ -fPIC \
-I$(TOPDIR) \
$(EXTRAWARN_CFLAGS) \ $(EXTRAWARN_CFLAGS) \
$(DEBUG_CFLAGS_INTERNAL) \ $(DEBUG_CFLAGS_INTERNAL) \
$(EXTRA_CFLAGS) $(EXTRA_CFLAGS)
@ -231,7 +234,7 @@ else
endif endif
%.o.d: %.c %.o.d: %.c
$(Q)$(CC) -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(CFLAGS) $< $(Q)$(CC) -MD -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(CFLAGS) $<
# #
# Pick from per-file variables, btrfs_*_cflags # Pick from per-file variables, btrfs_*_cflags
@ -240,7 +243,7 @@ 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 $< $($(subst -,_,$(@:%.o=%)-cflags)) $(Q)$(CC) $(CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.o=%)-cflags))
%.static.o: %.c %.static.o: %.c
@echo " [CC] $@" @echo " [CC] $@"