Skip to content

Instantly share code, notes, and snippets.

@jkmartindale
Last active October 25, 2019 18:15
Show Gist options
  • Save jkmartindale/268f73ad447bd655ffdf4024511a6259 to your computer and use it in GitHub Desktop.
Save jkmartindale/268f73ad447bd655ffdf4024511a6259 to your computer and use it in GitHub Desktop.
Quickly get a binary for self-contained C source

Minimakefile

Quickly build a binary for self-contained source files. Useful for:

  • Following along in class
  • Poking at example code
  • Quick sketches

Usage:

make file=path/to/source/file.c
CC = gcc
CFLAGS = -c -O3 -Wall
EXECUTABLE = $(basename $(file))
auto: $(EXECUTABLE).o
$(CC) $(EXECUTABLE).o -o $(EXECUTABLE)
rm -f $(EXECUTABLE).o
.c.o:
$(CC) $(CFLAGS) $< -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment