CTAGS-LANG-MAKE(7)

πŸ“¦
version 6.2.1 Β· 4 versions
, in alpine 3.24, fedora 43, fedora 44

πŸ’… 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 🫢


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