MAKEPP_BUILTIN(1)

πŸ“¦ version 2.0.98.5, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’… MAKEPP_BUILTIN β€” built-in rules for makepp ✨

okay bestie, sit down, hydrate, because this page is about the literal magic trick makepp pulls: it can compile and link your whole program even when you gave it, like, zero rules. not a single one. 🫢


🌸 DESCRIPTION 🌸

So here's the tea: makepp may be able to figure out how to compile and link your program even if you specify no rules at all β€” or if you don't even have a Makeppfile. 😭 iconic behavior honestly.

After every Makeppfile is loaded, makepp also loads a set of default rules. (These rules are special in that they do not override any other rules in the Makeppfile.) The default rule database is stored in the file makepp_builtin_rules.mk in the makepp distribution or library directory, so you can always look at that to see exactly what the default rules are. go look, it's right there, i'll wait πŸ’–

Makepp's builtin rules are almost the same as the rules in GNU make, except that it has no rules for some of the rare languages that GNU make has rules for. (This is deliberate; I often ran into trouble with GNU make on several projects that accidentally reused some of the suffixes that GNU make assigned to those rare languages.) The rules use the same variables as GNU make, with some possibly useful additions. Makepp is smarter than GNU make about inferring which compiler to use, and which other objects and libraries to link in. lowkey a glow-up ✨


πŸŽ€ Default variable values

Makepp supplies default values for a number of variables. Most of these are typically used in rules, and are indeed used in the default rules. Their values can be overridden by assigning to these variables in your Makeppfile or on the command line. πŸ’…

These variables are documented in Predefined Variables in makepp_variables. If you have any questions about what any variable evaluates to, you can always put a line like either of these lines in your Makeppfile:

dummy := $(print $(CC))
&echo -- $(CC)              # Must be indented less than previous rule.

which simply prints the value of the $(CC) variable when the Makeppfile is loaded. (Incidentally, this is a useful way to debug any expression that you're not sure is right.) not me giving you a debug hack for free 🧚


πŸ”₯ Compilation rules

In simplified form, here is approximately what the compilation rules look like. If you change the values of any of the indicated variables, the compilation command is changed as expected. slay, it just listens to you πŸ’œ

#
# For C programs:
#
%.o: %.c
    $(CC) $(CFLAGS) $(CPPFLAGS) -c $(input) -o $(output)

#
# For C++ programs:
#
%.o: %.cxx # and also %.cc, %.cpp, %.c++, and %.C
    $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(input) -o $(output)

#
# For Fortran programs:
#
%.o: %.f
    $(FC) $(FFLAGS) -c $(input) -o $(output)

#
# Yacc and lex:
#
%.c: %.y
    $(YACC) $(YFLAGS) $(input)
    &mv -f y.tab.c $(output)

%.c: %.l
    $(LEX) $(LFLAGS) -t $(input) -o $(output)

If you're curious about the exact details, you can look in the file makepp_builtin_rules.mk in the makepp distribution. the receipts are all there, bestie πŸ“œ


Makepp also knows how to link programs, too. Makepp attempts to be more clever than the standard Unix make when it comes to figuring out a link command. Suppose you are trying to build the target program xyz. Makepp will try to build this from xyz.o, and (unlike the standard Unix make) it will also attempt to infer whether any other objects or libraries need to be linked in. main character energy fr fr πŸ‘‘

The link rule looks something like this:

xyz: $(infer_objects xyz.o, *.o)
    $(infer_linker $(inputs)) $(inputs) $(LDFLAGS) $(LDLIBS) $(LIBS) -o $(output)

$(infer_objects) attempts to infer what other .o files need to be linked in based on what .h files are included. detective work, but make it build systems πŸ•΅οΈβ€β™€οΈ

The inferred linker is a special bit of magic that turns into $(CC) if all the sources are C code, $(CXX) if any of the sources are C++, or $(F77) if any of the sources are Fortran. literally shape-shifting ✨


πŸ’€ Turning off the built-in rules

If you don't like the built-in rules, don't use them. If they don't work for you, your built is probably sufficiently complicated that you need your own custom Makeppfile anyway. no offense, it's just the vibes 🌸

To turn off the builtin rules, you can add a line like this to your Makeppfile:

makepp_no_builtin = 1

If you do use them, but not the fairly expensive builtin linker rules, you can turn those off with:

makepp_no_builtin_linker = 1

For backward compatibility, makepp also turns off its default rules if you include this line somewhere in your Makeppfile:

.SUFFIXES:

You can turn off builtin rules for every Makeppfile in the entire build by specifying the --no-builtin-rules option on the command line. big red button, press responsibly πŸ”΄


heads up bestie: if you turn the builtin rules off, makepp is not gonna magically compile things for you anymore. the vibes get very DIY. you have been warned πŸ’–

okay that's the whole page, and yes it's from the Makepp manual, page MAKEPP_BUILTIN(1), brought to you by perl v5.32.0 and dated 2021-01-06. bye bestie, go build something iconic πŸ¦‹πŸŽ€πŸ’œ

πŸ“¦ where this page comes from