Skip to content

Instantly share code, notes, and snippets.

@shiva-karthick
Last active November 7, 2018 05:18
Show Gist options
  • Save shiva-karthick/db8c4d11e443cf6d6385f6144f9ee380 to your computer and use it in GitHub Desktop.
Save shiva-karthick/db8c4d11e443cf6d6385f6144f9ee380 to your computer and use it in GitHub Desktop.
TARGET = a
LIBS = -lm
CC = gcc
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 $@
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