Skip to content

Instantly share code, notes, and snippets.

@c4pt0r
Last active September 29, 2015 03:58
Show Gist options
  • Save c4pt0r/1543525 to your computer and use it in GitHub Desktop.
Save c4pt0r/1543525 to your computer and use it in GitHub Desktop.
my makefile template 2
CC = gcc
CFLAGS = -c -Wall -g -Os
LD = $(CC)
LDFLAGS = -lfoo
TARGET = MyProject
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(LD) -o $@ $^ $(LDFLAGS)
# You don't even need to be explicit here,
# compiling C files is handled automagically by Make.
%.o: %.c
$(CC) $(CFLAGS) $^ -o $@
clean:
rm $(TARGET) $(OBJECTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment