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

Makefile — first linesMakefile
# 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

Size
346 B (346 bytes)
MIME type
text/plain
SHA-256
048fde82a78e6adf36e5f210bfdb3c75f632764bef694ed5ac2e4c9f19ba0539
MD5
351f0766e0d1f15b24b50b81be895c60

Download from the command line

curl -L -o Makefile https://files.samplefiles.com/code/makefile/Makefile

Or check the download in your browser with the checksum calculator.