GNUmakefile: fix portability issues for out-of-tree and cross builds#342
Open
Ebola-Chan-bot wants to merge 1 commit intotermux:masterfrom
Open
GNUmakefile: fix portability issues for out-of-tree and cross builds#342Ebola-Chan-bot wants to merge 1 commit intotermux:masterfrom
Ebola-Chan-bot wants to merge 1 commit intotermux:masterfrom
Conversation
- Use $(VPATH) instead of $(SRC) in define_from_arch.h: the comment on line 4 says "the VPATH variable must point to the actual makefile directory", making $(VPATH) the designated source-directory variable. $(SRC) happens to resolve to the same value in normal builds, but $(VPATH) is semantically correct and consistent with the rest of the file (CPPFLAGS already uses -I$(VPATH)). - Use $< instead of $(SRC)$< in COMPILE macro: VPATH already resolves $< to the correct source path. $(SRC)$< duplicates the directory prefix in out-of-tree builds (e.g. ../../src/../../src/cli/cli.c). - Replace egrep with grep -E: egrep has been deprecated by POSIX (IEEE Std 1003.1-2024) and GNU grep now emits a warning. On some systems (e.g. MSYS2), egrep is a wrapper script whose shebang path may contain spaces, breaking $(shell) invocations. - Add READELF variable (?= $(CROSS_COMPILE)readelf) and use it in the loader-info.c rule instead of hardcoded readelf, matching the existing pattern for CC, STRIP, OBJCOPY, and OBJDUMP. - Use $(VPATH) prefix for loader-info.awk in the loader-info.c rule so out-of-tree builds can find the awk script.
There was a problem hiding this comment.
Pull request overview
Improves src/GNUmakefile portability and correctness for out-of-tree builds and cross-compilation by relying on VPATH-resolved paths and toolchain-prefixed utilities.
Changes:
- Use
$(VPATH)(not$(SRC)) for source-directory references where the Makefile declaresVPATHas the canonical makefile/source dir. - Fix out-of-tree compile path handling by compiling
$<directly (lettingVPATHresolve the correct source path). - Replace deprecated
egrepusage withgrep -E, and add a configurableREADELFfor cross builds (alsoVPATH-prefix the AWK script path).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five small fixes to make
GNUmakefilework correctly in out-of-tree builds (make -f /path/to/src/GNUmakefile) and cross-compilation setups where the toolchain has a$(CROSS_COMPILE)prefix.1. Fix source path duplication in
COMPILEmacroVPATHalready causesmaketo resolve$<to the full source path. Prepending$(SRC)duplicates the prefix in out-of-tree builds, producing paths like../../src/../../src/cli/cli.c.2. Use
$(VPATH)instead of$(SRC)indefine_from_arch.hThe comment on line 4 says "the VPATH variable must point to the actual makefile directory", making
$(VPATH)the designated source-directory variable.CPPFLAGSalready uses-I$(VPATH). This change alignsdefine_from_arch.hwith the rest of the file.3. Replace deprecated
egrepwithgrep -Eegrephas been deprecated by POSIX (IEEE Std 1003.1-2024) and GNU grep now emits a warning. On some systems (e.g. MSYS2/Git-for-Windows),egrepis a wrapper shell script whose shebang path may contain spaces, which breaks$(shell)invocations on native-Windows make implementations.4. Add
READELFvariableThis follows the existing pattern for
CC,STRIP,OBJCOPY, andOBJDUMP, which all use?=with$(CROSS_COMPILE)prefix. The hardcodedreadelfin theloader-info.crule is replaced with$(READELF).5. Use
$(VPATH)forloader-info.awkpathIn out-of-tree builds, the awk script is in the source tree, not the build directory. Without
$(VPATH),awk -f loader/loader-info.awkfails with "file not found".