.. | .. |
---|
104 | 104 | override LDFLAGS = |
---|
105 | 105 | endif |
---|
106 | 106 | |
---|
107 | | -ifneq ($(O),) |
---|
108 | | - BUILD := $(O)/kselftest |
---|
| 107 | +top_srcdir ?= ../../.. |
---|
| 108 | + |
---|
| 109 | +ifeq ("$(origin O)", "command line") |
---|
| 110 | + KBUILD_OUTPUT := $(O) |
---|
| 111 | +endif |
---|
| 112 | + |
---|
| 113 | +ifneq ($(KBUILD_OUTPUT),) |
---|
| 114 | + # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot |
---|
| 115 | + # expand a shell special character '~'. We use a somewhat tedious way here. |
---|
| 116 | + abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) |
---|
| 117 | + $(if $(abs_objtree),, \ |
---|
| 118 | + $(error failed to create output directory "$(KBUILD_OUTPUT)")) |
---|
| 119 | + # $(realpath ...) resolves symlinks |
---|
| 120 | + abs_objtree := $(realpath $(abs_objtree)) |
---|
| 121 | + BUILD := $(abs_objtree)/kselftest |
---|
109 | 122 | else |
---|
110 | | - ifneq ($(KBUILD_OUTPUT),) |
---|
111 | | - BUILD := $(KBUILD_OUTPUT)/kselftest |
---|
112 | | - else |
---|
113 | | - BUILD := $(shell pwd) |
---|
114 | | - DEFAULT_INSTALL_HDR_PATH := 1 |
---|
115 | | - endif |
---|
| 123 | + BUILD := $(CURDIR) |
---|
| 124 | + DEFAULT_INSTALL_HDR_PATH := 1 |
---|
116 | 125 | endif |
---|
117 | 126 | |
---|
118 | 127 | # Prepare for headers install |
---|
119 | | -top_srcdir ?= ../../.. |
---|
120 | 128 | include $(top_srcdir)/scripts/subarch.include |
---|
121 | 129 | ARCH ?= $(SUBARCH) |
---|
122 | 130 | export KSFT_KHDR_INSTALL_DONE := 1 |
---|