Skip to content

Instantly share code, notes, and snippets.

@alghanmi
Created June 11, 2014 23:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alghanmi/eb47fc6151bdb17be249 to your computer and use it in GitHub Desktop.
Save alghanmi/eb47fc6151bdb17be249 to your computer and use it in GitHub Desktop.
Sample Makefile for CS 104 homework question
IDIR =.
CC=g++
CFLAGS=-I$(IDIR) -std=c++11 -ggdb
ODIR=.
LDIR =../lib
LIBS=-lm
_DEPS = shape.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = shape.o shape1.o shape2.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.cpp $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
all: shape1 shape2
shape1: shape1.o shape.o
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
shape2: shape2.o shape.o
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ shape1 shape2 $(IDIR)/*~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment