Last active
April 23, 2022 05:53
-
-
Save snim2/1419118 to your computer and use it in GitHub Desktop.
Makefile for multiple single file C programs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, I understand. So nothing else to embarrass with it. Well thank you