Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ INSTALL = install
CC ?= $(CROSS_COMPILE)gcc
LD = $(CC)
STRIP ?= $(CROSS_COMPILE)strip
READELF ?= $(CROSS_COMPILE)readelf
OBJCOPY ?= $(CROSS_COMPILE)objcopy
OBJDUMP ?= $(CROSS_COMPILE)objdump

Expand Down Expand Up @@ -86,7 +87,7 @@ OBJECTS += \
extension/fix_symlink_size/fix_symlink_size.o

define define_from_arch.h
$2$1 := $(shell $(CC) $1 -E -dM -DNO_LIBC_HEADER $(SRC)/arch.h | grep -w $2 | cut -f 3 -d ' ')
$2$1 := $(shell $(CC) $1 -E -dM -DNO_LIBC_HEADER $(VPATH)/arch.h | grep -w $2 | cut -f 3 -d ' ')
endef

$(eval $(call define_from_arch.h,,HAS_LOADER_32BIT))
Expand Down Expand Up @@ -169,7 +170,9 @@ BUILD_ID_NONE := $(shell if ld --build-id=none --version >/dev/null 2>&1; then e
######################################################################
# Build rules

COMPILE = $($(quiet)CC) $(CPPFLAGS) $(CFLAGS) -MD -c $(SRC)$< -o $@
# Use $< instead of $(SRC)$< because VPATH already resolves source paths.
# $(SRC)$< duplicates the prefix in out-of-tree builds.
COMPILE = $($(quiet)CC) $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $@
LINK = $($(quiet)LD) -o $@ $^ $(LDFLAGS)

OBJIFY = $($(quiet)GEN) \
Expand All @@ -186,7 +189,7 @@ proot: $(OBJECTS)

# Special case to compute which files depend on the auto-generated
# file "build.h".
USE_BUILD_H := $(patsubst $(SRC)%.c,%.o,$(shell egrep -sl 'include[[:space:]]+"build.h"' $(patsubst %.o,$(SRC)%.c,$(OBJECTS))))
USE_BUILD_H := $(patsubst $(SRC)%.c,%.o,$(shell grep -E -sl 'include[[:space:]]+"build.h"' $(patsubst %.o,$(SRC)%.c,$(OBJECTS))))
$(USE_BUILD_H): build.h

%.o: %.c
Expand Down Expand Up @@ -235,7 +238,7 @@ $(eval $(call build_loader,-m32))
endif

loader/loader-info.c: loader/loader
readelf -s $< | awk -f loader/loader-info.awk > $@
$(READELF) -s $< | awk -f $(VPATH)/loader/loader-info.awk > $@

######################################################################
# Dependencies
Expand Down
Loading