CTAGS-LANG-MAKE(7)
π ctags-lang-make β tagging Make source code with Universal Ctags
okay bestie, gather round π«Ά this is a Universal Ctags manual page (section 7, so it's a "miscellaneous" one, iykyk) and it's all about the Make parser. Random notes. That's literally what the NAME says. Let's go. β¨
β¨ NAME β¨
ctags-lang-make β random notes about tagging Make source code with Universal Ctags π
πΈ SYNOPSIS πΈ
ctags ... --languages=+Make ...
ctags ... --language-force=Make ...
ctags ... --map-Make=+([Mm]akefile) --map-Make=+(GNUmakefile) ...
ctags ... --map-Make=+.mak --map-Make=+.mk ...
π¦ DESCRIPTION π¦
So this parser does two things, and honestly it eats:
- it pulls out macro and target definitions
- it also pulls out included files, but as references (not definitions, bestie, there's a difference and it MATTERS π)
π Examples π
Here's our little test file, "input.mak":
-include base.mak
SRC = hello.c
all: hello
hello: hello.o
hello.o: hello.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
and here's "output.tags" when you run it with --options=NONE --extras=+r --fields=+KlrE -o - input.mak:
SRC input.mak /^SRC = hello.c$/;" macro language:Make roles:def
all input.mak /^all: hello$/;" target language:Make roles:def
base.mak input.mak /^-include base.mak$/;" makefile language:Make roles:optional extras:reference
hello input.mak /^hello: hello.o$/;" target language:Make roles:def
hello.o input.mak /^hello.o: hello.c$/;" target language:Make roles:def
see how base.mak is giving roles:optional and extras:reference? not like the others. iconique. π
π EXTRACTING CPP MACRO DEFINTIONS DEFINED WITH -DFOO π
(yes that heading says DEFINTIONS, no I will not be fixing it, it's canon now π)
okay so real talk: with the -D option in a C compiler like gcc, a programmer can define a macro outside of C source files. And those options show up on a Makefile a lot. For an example:
CPPFLAGS = -DDEBUG
The Make parser has heuristics [DINMAKE] for extracting the macros defined with that option. And β plot twist β with the CppDef extra enabled, you can turn those heuristics on. slay. β¨
π Examples π
"input.mak":
-include base.mak
CFLAGS = -g -O2
CPPFLAGS = -DOUTPUT=stdout
SRC = hello.c
all: hello
hello: hello.o
hello.o: hello.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
and "output.tags" with --options=NONE --extras-Make=+{CppDef} --fields=+KlE -o - input.mak:
CFLAGS input.mak /^CFLAGS = -g -O2$/;" macro language:Make
CPPFLAGS input.mak /^CPPFLAGS = -DOUTPUT=stdout$/;" macro language:Make
OUTPUT input.mak /^CPPFLAGS = -DOUTPUT=stdout$/;" macro language:CPreProcessor extras:CppDef
SRC input.mak /^SRC = hello.c$/;" macro language:Make
all input.mak /^all: hello$/;" target language:Make
hello input.mak /^hello: hello.o$/;" target language:Make
hello.o input.mak /^hello.o: hello.c$/;" target language:Make
not OUTPUT sneaking in there with language:CPreProcessor and extras:CppDef like it owns the place π main character energy fr fr.
π VERSIONS π
β Change since "0.0" β
- New extra
CppDef[DINMAKE]
π«Ά SEE ALSO π«Ά
ctags(1)- [DINMAKE]
CONFIG_X86_X32_ABIis not visible (defined in Makefile, not C or Kconfig) <https://github.com/bootlin/elixir/issues/221> ( <https://github.com/bootlin/elixir/issues/221> )
okay that's the whole page, no cap, nothing skipped, every flag and every line of output is still right there where you left it π go tag some Makefiles bestie, you got this.
this whole thing comes from Universal Ctags, version 6.2.1 β bye π β¨
π¦ where this page comes from
- alpine 3.24: ctags-doc 6.2.1-r0 Β· GPL-2.0-or-later
- fedora 43: ctags 6.2.1-1.fc43 Β· GPL-2.0-or-later
- fedora 44: ctags 6.2.1-3.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms