Source: http://stackoverflow.com/a/1484873

# Thanks to Joey Adams for the boost!

# Name of the executable
TARGET = exo-sha-1

# Librairies
LIBS = -lcrypto

# Compiler
CC = gcc

# Extra parameters
CFLAGS = -std=c99 -c -Wall

# Basically explicit ignore
.PHONY: default all clean

# Aliases
default: $(TARGET)
all: default

# Useful files
OBJECTS = $(patsubst %.c,%.o,exo-sha-1.c sha.c)

# Headers
HEADERS = sha.h

# Create machine code
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@

# Won’t be deleted if shit happens ¯\_(ツ)_/¯
.PRECIOUS: $(TARGET) $(OBJECTS)

# Do the magic
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@

# Remove the dust
clean:
-rm -f *.o
-rm -f $(TARGET)