objtree is defined and exported by the top-level Makefile. I prefer not to override it. There is no need to pass the absolute path of objtree. PKGBUILD can detect it by itself.
Unified · Split
| @@ -147,8 +147,7 @@ snap-pkg: · 146 unmodified lines | ||
| 147 | 147 | PHONY += pacman-pkg |
| 148 | 148 | pacman-pkg: |
| 149 | 149 | @ln -srf $(srctree)/scripts/package/PKGBUILD $(objtree)/PKGBUILD |
| 150 | − +objtree="$(realpath $(objtree))" \ | |
| 151 | − BUILDDIR="$(realpath $(objtree))/pacman" \ | |
| 150 | + +BUILDDIR="$(realpath $(objtree))/pacman" \ | |
| 152 | 151 | CARCH="$(UTS_MACHINE)" \ |
| 153 | 152 | KBUILD_MAKEFLAGS="$(MAKEFLAGS)" \ |
| 154 | 153 | KBUILD_REVISION="$(shell $(srctree)/scripts/build-version)" \ |
| @@ -40,7 +40,9 @@ _prologue() { · 39 unmodified lines | ||
| 40 | 40 | # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. |
| 41 | 41 | # Bypass this override with a custom variable. |
| 42 | 42 | export MAKEFLAGS="${KBUILD_MAKEFLAGS}" |
| 43 | − cd "${objtree}" | |
| 43 | + | |
| 44 | + # Kbuild works in the output directory, where this PKGBUILD is located. | |
| 45 | + cd "$(dirname "${BASH_SOURCE[0]}")" | |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | 48 | build() { |