Skip to content

Instantly share code, notes, and snippets.

@Kern--
Last active December 14, 2015 04:59
Show Gist options
  • Save Kern--/5032168 to your computer and use it in GitHub Desktop.
Save Kern--/5032168 to your computer and use it in GitHub Desktop.
A simple makefile
#Name of the executable
TARGET =
#objects that go into the executable
OBJS =
CC = gcc
CFLAGS = -g -Wall
DEBUGGER = gdb
#--------------#
# Default rule #
#--------------#
.PHONY: default
default: $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
#------------#
# Debug rule #
#------------#
.PHONY: debug
debug: CFLAGS += -DDEBUG -g
debug: default
$(DEBUGGER) $(TARGET)
#-----------------#
# Make a tarball #
# ----------------#
%.tar.gz:
tar cfvz $@ *.c *.h Makefile
#-------#
# Clean #
#-------#
.PHONY: clean
clean:
-rm -f $(TARGET)
-rm -f *.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment