Code · 1 file
Sample Makefile File
Makefiles drive builds with make, using targets, prerequisites, variables and pattern rules. The Makefile sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.
Makefile · 346 B
Sample Makefile file
An idiomatic Makefile example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.
CC0 · free for any use · Verified by an independent tool · Report a problem
# Sample Makefile — samplefiles.com
CC ?= cc
CFLAGS ?= -O2 -Wall -Wextra -std=c11
SRC := $(wildcard src/*.c)
OBJ := $(SRC:.c=.o)
BIN := sample
.PHONY: all clean test
all: $(BIN)
$(BIN): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
test: $(BIN)
./$(BIN) --self-test
clean:
rm -f $(OBJ) $(BIN)File details
Download from the command line
curl -L -o Makefile https://files.samplefiles.com/code/makefile/Makefilewget https://files.samplefiles.com/code/makefile/Makefilehttps://files.samplefiles.com/code/makefile/Makefileprintf '%s %s\n' 048fde82a78e6adf36e5f210bfdb3c75f632764bef694ed5ac2e4c9f19ba0539 Makefile | shasum -a 256 -cOr check the download in your browser with the checksum calculator.