Honor user-overridable standard compiler variables.
Section: Portable make basics
Use standard macros
makefile
makefile
CC = c99
CFLAGS = -O2
LDFLAGS =
LDLIBS =
app: main.o util.o
$(CC) $(LDFLAGS) -o $@ main.o util.o $(LDLIBS)Explanation
Keeping `CC`, `CFLAGS`, `LDFLAGS`, and `LDLIBS` overridable is a long-standing portable convention.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Portable make basics
POSIX-style portable rule
Write simple, explicit file rules compatible with standard make.
Suffix rule
Use classic suffix rules when targeting very portable make implementations.
Use shell short-circuit safely
Stop on failure explicitly within one recipe line.
Avoid eval for POSIX portability
Prefer explicit rules over GNU metaprogramming.