Q: simple way to get line number in a GNUmakefile
Basile Starynkevitch <[email protected]> Tue, 02 Dec 2025 17:15:42 +0100
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Message-ID | <[email protected]> |
Hello all,
I am French and using GNU make (with GNU guile) version GNU Make 4.4.1 on a=
Debian Testing (or Ubuntu) computer with x86-64.=20
Is there a simple way to get the current line number (in a similar way of _=
_LINE__ in C++ code) in a GNUmakefile?
Maybe adding a $(__LINE__) and $(__FILE__) GNUmakefile functions?
In other words, adding a GNU make feature so that the following GNUmakefile=
example:
.PHONY: tell-lines
tell-lines:
printf "tell-lines at %s:%d\n" $(__LINE__) $(__FILE__)
when invoked as make tell-lines is outputing
tell-lines at GNUmakefile:4
I could even try to implement it if adding that feature is simple (less tha=
n a day of coding on Linux) if given some concrete guidance.....
Respectful regards
NB: this is useful in the RefPerSys free software project - it has an ugly =
GNUmakefile (and I don't want to use generators like cmake)
--=20
Basile STARYNKEVITCH basile AT starynkevitch DOT net
8 rue de la Fa=C3=AFencerie http://starynkevitch.net/=
Basile/ =20
92340 Bourg-la-Reine https://github.com/bstarynk
France https://github.com/RefPerSys/RefPerSy=
s
https://orcid.org/0000-0003-0908-5250