Makefile::AST(3)

πŸ“¦
version 0.216 Β· 2 versions
, in fedora 43

✨ Makefile::AST ✨

okay bestie, so this is the manual page for Makefile::AST(3) β€” a lil' piece of the User Contributed Perl Documentation universe πŸ’– β€” and it's literally all about building an AST (abstract syntax tree, iykyk) for (GNU) makefiles. Buckle up πŸŽ€


🌸 DESCRIPTION 🌸

The whole structure of this (GNU) makefile AST is designed based on GNU make's data base listing output β€” the stuff you get when you run it with --print-data-base. So yeah, that's the blueprint. πŸ’…

This AST library ships with the following classes, and honestly? each one is doing its own iconic thing:

  • Makefile::AST β€” the main character πŸ‘‘ The primary class for ASTs. It gives you the interface for adding and querying nodes, like add_implicit_rule, apply_implicit_rules, add_explicit_rule, apply_explicit_rules, add_var, add_auto_var, get_var, plus a whole pile of other utility functions. We're talking method eval_var_value for computing the ultimate values of makefile variables, and methods enter_pad and leave_pad for local variable's scoping pad. So much utility, so much slay. ✨
  • Makefile::AST::Rule::Base β€” the base class for rule nodes in the AST. It's got properties like normal_prereqs, order_prereqs, commands, and colon. The blueprint queen. 🧚
  • Makefile::AST::Rule β€” this one represents the de-sugared form of simple rules and implicite rules after application. It inherits from Makefile::AST::Rule::Base and adds brand new properties: target and other_targets. Glow-up behavior, fr fr. πŸ¦‹
  • Makefile::AST::Rule::Implicit β€” the implicit rule nodes in the AST. Inherits from Makefile::AST::Rule::Base and adds new properties targets, match_anything, and is_terminal. Subtle but powerful. πŸ’œ
  • Makefile::AST::StemMatch β€” this class encapsulates the file pattern matching (file names containing %) and stem substitution algorithms. It's giving math genius energy. πŸ“
  • Makefile::AST::Variable β€” represents the makefile variable nodes in the AST, including name, value, flavor, and origin. The whole identity package. πŸ’…
  • Makefile::AST::Command β€” used to encapsulate information regarding makefile rule commands (e.g. command body, command modifiers @, -, +, and etc.) as a whole. All bundled up, cute and tidy. πŸŽ€

πŸ’€ LIMITATIONS AND TODO πŸ’€

Adding support for other flavors' makes into this AST library should make a huge amount of sense. The most interesting candiate is Microsoft's NMAKE. (yes, it says "candiate" in the original and I refuse to touch it, we respect the source 🫢)


🌈 CODE REPOSITORY 🌈

For the very latest version of this script, check out the source from

<http://github.com/agentzh/makefile-parser-pm>

There is anonymous access to all. no login, no gatekeeping, just vibes ✨


🫢 AUTHOR 🫢

Zhang "agentzh" Yichun <agentzh@gmail.com>


Copyright (c) 2007-2008 by Zhang "agentzh" Yichun (agentzh).

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


⭐ SEE ALSO ⭐

  • Makefile::AST::Evaluator
  • Makefile::Parser::GmakeDB
  • makesimple
  • pgmake-db
  • Makefile::DOM

ok that's the whole page bestie, every class, every property, every flag, no skips, no cuts πŸ’–

and for the cute sign-off: this was perl v5.42.0, dated 2025-07-25, and it's the Makefile::AST(3) page β€” go build something iconic with it, periodt. πŸ’…πŸŒΈβœ¨

πŸ“¦ where this page comes from