Skip to content

Instantly share code, notes, and snippets.

@fbs
Created January 14, 2011 18:43
Show Gist options
  • Save fbs/780025 to your computer and use it in GitHub Desktop.
Save fbs/780025 to your computer and use it in GitHub Desktop.
A simple makefile
# TOOLS
CPP = g++
CC = gcc
# MORE TOOLS
SIZE = size
OBJCOPY = objcopy
OBJDUMP = objdump
#PROJECT RELATED STUFF
NAME = todo-list
#FLAGS
CFLAGS = -Wall
#LDFLAGS =
#DEBUG FLAGS
DFLAGS = -ggdb
#PROJECT FILES
CSRC = src/fileio.c src/main.c src/search.c src/todo.c
#CPPSRC
#ASMSRC
#OBJECT FILES
OBJ = $(CSRC:.c=.o)
#STUFF TO CLEAN
CLEAN += $(OBJ)
.PHONY: all release clean size debug
all: debug size
clean:
rm -rf $(CLEAN)
debug: $(OBJ)
$(CC) $(DFLAGS) $(CFLAGS) $(LDFLAGS) -o debug/$(NAME) $(OBJ)
release: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o release/$(NAME) $(OBJ)
size: debug #need to fix this, should also work with build
$(SIZE) debug/$(NAME)
$(COBJ): %.o : %.c
$(CC) $(CFLAGS) -c -o build/$@ $<
#compile into build directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment