Skip to content

Instantly share code, notes, and snippets.

@disconnect3d
Last active November 17, 2022 01:58
Show Gist options
  • Save disconnect3d/fba8310068a7a6cab221145f8a8fab62 to your computer and use it in GitHub Desktop.
Save disconnect3d/fba8310068a7a6cab221145f8a8fab62 to your computer and use it in GitHub Desktop.
Minimal & universal makefile for C language
CC=gcc
CFLAGS=-Wall -Wextra -Wpedantic
LDFLAGS=
SOURCES=$(wildcard *.c )
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=exec
all: $(EXECUTABLE)
./$(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o $(EXECUTABLE)
$(OBJECTS): $(SOURCES)
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm $(EXECUTABLE) $(OBJECTS)
@AVividLight
Copy link

Thank you for this!

@DmitryLedentsov
Copy link

perfect!

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