Skip to content

Instantly share code, notes, and snippets.

@LinArcX
Created May 2, 2019 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LinArcX/c489f8e2211c6acac9fa59eaef9e91ea to your computer and use it in GitHub Desktop.
Save LinArcX/c489f8e2211c6acac9fa59eaef9e91ea to your computer and use it in GitHub Desktop.
TARGET = main
LIBS = -lm
CC = gcc
CFLAGS = -g -Wall
ODIR = ./build
SDIR = ./src
.PHONY: default all clean
default: $(ODIR)/$(TARGET)
all: default
OBJECTS = $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(wildcard $(SDIR)/*.c))
HEADERS = $(wildcard $(SDIR)/*.h)
$(ODIR)/%.o: $(SDIR)/%.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(ODIR)/$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@
clean:
-rm -f $(ODIR)/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment