Skip to content

Instantly share code, notes, and snippets.

@elPytel
Created January 19, 2023 15:52
Show Gist options
  • Save elPytel/0713817a132884c659d363e2f6d75f2b to your computer and use it in GitHub Desktop.
Save elPytel/0713817a132884c659d363e2f6d75f2b to your computer and use it in GitHub Desktop.
Simple Makefile
TARGET = app
CC = clang
LIBS = -lm
CFLAGS = -g -Wall
.PHONY: default all clean
default: $(TARGET)
all: default
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
HEADERS = $(wildcard *.h)
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@
run: $(TARGET)
./$(TARGET)
clean:
-rm -f *.o
-rm -f $(TARGET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment