# CSCI-4972/6963 Advanced Computer Graphics, Spring 2007
# Simple Makefile for Homework 1
# for g++ on unix or cygwin platforms

SHELL = /bin/bash

# ===============================================================

default:
	@echo "Please specify a target (unix, cygwin_x, or cygwin)"

# Linux or FreeBSD
unix: CC                = g++ -g -O3 -Wall -pedantic
unix: INCLUDE_PATH      = -I/usr/X11R6/include -L/usr/local/include
unix: LIB_PATH          = -L/usr/X11R6/lib -L/usr/local/lib
unix: LIBS              = -lm -lGL -lGLU -lglut
unix: all

# Cygwin with X (probably software emulation)
cygwin_x: CC            = g++ -g -O3 -Wall -pedantic
cygwin_x: INCLUDE_PATH  = -I/usr/X11R6/include
cygwin_x: LIB_PATH      = -L/usr/X11R6/lib
cygwin_x: LIBS          = -lm -lGL -lGLU -lglut
cygwin_x: all

# Cygwin with native Windows libraries
cygwin: CC              = g++ -g -O3 -Wall -pedantic
cygwin: INCLUDE_PATH    = -I/usr/include/w32api 
cygwin: LIB_PATH        = -L/usr/lib/w32api
cygwin: LIBS            = -lm -lopengl32 -lglu32 -lglut32 
cygwin: all

# ===============================================================

SRCS	= main.cpp matrix.cpp image.cpp glCanvas.cpp camera.cpp
OBJS	= $(SRCS:.cpp=.o)
EXE	= ifs

# ===============================================================
# targets

.PHONY: all check-gcc depend clean

check-gcc:
	@(ver=`$(CC) --version | head -1 | awk '{print $$3}'`; \
	if [ $${ver:0:3} != 3.4 ]; then echo \
	"WARNING: this compiler ($$ver) may not be compatible with "\
	"g++ version 3.4.x, which will be used during grading."; fi)

all: check-gcc depend $(EXE) 

depend:
	$(CC) $(INCLUDE_PATH) -E -M $(SRCS) > Makefile.depend

clean: 
	rm -f *~ *bak *.o  $(EXE) Makefile.depend

# ===============================================================
# compilation rules

$(EXE): $(OBJS)
	$(CC) $(INCLUDE_PATH) -o $@ $(OBJS) $(LIB_PATH) $(LIBS) 

.cpp.o:
	$(CC) $(INCLUDE_PATH) $< -c -o $@

# ===============================================================

-include Makefile.depend
