Skip to content

Instantly share code, notes, and snippets.

@snim2
Last active April 23, 2022 05:53
Show Gist options
  • Save snim2/1419118 to your computer and use it in GitHub Desktop.
Save snim2/1419118 to your computer and use it in GitHub Desktop.
Makefile for multiple single file C programs
#
# Minimal Makefile which compiles multiple C files into individual executables.
#
#
# - Sarah Mount, November 2011
#
CC=gcc
RM=rm
CFLAGS=-c -Wall -O3
LDFLAGS=-lm
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
EXECS=$(SOURCES:%.c=%)
.PHONY: all
all: $(OBJECTS) $(EXECS)
.c.o:
$(CC) $(CFLAGS) $< -o $@
.o.:
$(CC) $^ $(LDFLAGS) -o $@
.PHONY: clean
clean:
-@ $(RM) *.o
-@ $(RM) $(EXECS)
@jv813yh
Copy link

jv813yh commented Mar 5, 2021

Oh, I understand. So nothing else to embarrass with it. Well thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment