Skip to content

Instantly share code, notes, and snippets.

@jocafa
Created September 28, 2009 18:49
Show Gist options
  • Select an option

  • Save jocafa/195714 to your computer and use it in GitHub Desktop.

Select an option

Save jocafa/195714 to your computer and use it in GitHub Desktop.
libraries = glut GL GLU
frameworks = GLUT OpenGL Cocoa
OS = $(shell uname -s)
target = $(lastword $(filter-out Makefile,$(subst /, ,$(abspath Makefile))))
objects = $(patsubst %.c,%.o,$(wildcard *.c))
compile = gcc -Wall
fw = $(addprefix -framework ,$(frameworks))
libs = $(addprefix -l,$(libraries))
ifeq ($(OS),Darwin)
linkage = $(fw)
else
linkage = $(libs)
endif
compile = gcc -Wall
$(target): $(objects)
$(compile) $(linkage) -o $(target) $(objects)
all: $(target)
run: $(target)
./$(target)
.c.o:
$(compile) -c $< -o $@
clean:
rm -f $(target) $(objects)
.PHONY: clean run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment