# Copyright (C) 2012  Nathan (Acorn) Pooley
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License (gpl.txt) for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
# USA.
#
# You can contact the author, Nathan (Acorn) Pooley, by writing
# to Nathan (Acorn) Pooley, 949 Buckeye Drive, Sunnyvale, CA  94086, USA


TARGETS := glut_gl32_example

all: $(TARGETS)

ifeq ($(shell uname),Darwin)

  # NOTE: Not actually tested on mac yet.

  LIBS_GLUT := -framework GLUT
  LIBS_GLEW :=

  GL_CFLAGS :=
  GL_LIBS := -framework OpenGL

  GLUT_CFLAGS :=
  GLUT_LIBS := -framework GLUT

  GLEW_CFLAGS :=
  GLEW_LIBS :=
else

  GL_CFLAGS :=
  GL_LIBS := -lGL

  GLUT_CFLAGS :=
  GLUT_LIBS := -lglut

  GLEW_CFLAGS := `pkg-config --cflags glew`
  GLEW_LIBS := `pkg-config --libs glew`
endif

CFLAGS :=
CFLAGS += -g -Wall -Werror -m32
CFLAGS += $(GLEW_CFLAGS)
CFLAGS += $(GLUT_CFLAGS)
CFLAGS += $(GL_CFLAGS)

LDFLAGS := -g -Wall -Werror -m32

LIBS :=
LIBS += $(GLEW_LIBS)
LIBS += $(GLUT_LIBS)
LIBS += $(GL_LIBS)

CC = gcc

glut_gl32_example: glut_gl32_example.o
	$(CC) $(LDFLAGS) -o $@ $< $(LIBS)

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

.PHONY: clean
clean:
	-rm -f *.o *core* $(TARGETS)

